Cryptocurrencies are blockchain cash, but the same decentralised approach can be taken to computer code — resulting in apps that run trustlessly and automatically, with no chance of failure.

Bitcoin has established blockchain technology as a trustless way of sending cash online. But ‘cash’ in this context simply means information. That information can represent other things too, giving the blockchain a far wider set of use cases than financial transfers alone. In addition to making peer-to-peer payments, it’s also possible to write and run software on the blockchain.

Smart Contracts

Ethereum was the first smart contracts platform, and is still the best known and largest by market cap. It features so-called ‘Turing-complete’ smart contracts — which means that theoretically Ethereum can be used to run any programme. There are many projects being developed on Ethereum, from multi-sig wallets to sophisticated e-commerce platforms that aim to replace marketplaces like Amazon and eBay with a decentralised model.

Whilst Ethereum’s approach to smart contracts makes them extremely powerful, they’re also inaccessible to the vast majority of everyday users. Anyone who wants to create any smart contract functionality has to know how to programme them. Moreover, the costs of getting it wrong can be enormous. There have been a number of thefts and exploits as a result of badly-written smart contracts, some resulting in tens of millions of dollars in lost funds.

The Waves Approach

Waves is taking a different approach to smart contracts. Whilst the platform is ultimately planning to develop highly-versatile Turing complete contracts, their initial iteration will include limited functionality. The idea is to release smart contracts that cover the most popular use cases, built into the client so that everyone can deploy them, regardless of whether they have any programming knowledge or understanding of smart contracts themselves.

This basic functionality will include account controls such as multi-sig accounts and the ability to lock tokens for a certain amount of time, to prevent them being moved. This will cover the majority of everyday usage safely.

Once this mass-use functionality has been thoroughly tested, Waves will release Turing-complete smart contracts. Like Ethereum’s smart contracts, these can be used for just about any use case. Also, smart accounts will be introduced.

Smart Accounts

A conventional account can only sign transactions before sending them to the blockchain. The idea of a smart account is the following: before the transaction is submitted for inclusion in the next block, the account checks if the transaction meets certain requirements, defined in a script. The script is attached to the account so the account can validate every transaction before confirming it.

The main requirement for our smart accounts is that they can be run for the price of normal transactions with a predefined fee, without any additional ‘gas’ or other costs. This will be possible due to the statically predictable execution time. Since Waves has been built on top of an account-based model like Ethereum or Nxt (instead of Bitcoin’s input/output system), we can set security scripts on accounts.

In our vision, smart accounts cannot send transactions themselves or transfer funds according to given conditions but can read data from the blockchain (for example, the height of a block or signatures from the transaction) and return the result of a predicate obtained on the basis of this data.

The language of smart accounts should be as simple as possible so that it is accessible to beginners or ordinary users who are not familiar with a particular language paradigm. Language grammar will be human-readable and user-friendly. We are consciously not going to provide users with the ability to write functions, recursions, and loops of indefinite nesting. We have explained earlier that we avoid constructions whose complexity cannot be predicted in advance and that cannot be executed in a definite number of steps. That is the reason why we also have no collections or ‘for each’ constructions.

Smart Assets

If we plan to apply constraints on all operations for a specific asset, we cannot use a smart account. In our paradigm, we have smart assets for this purpose: the script will be attached to the asset and will work in a similar way. Transactions for such assets are valid only if the script returns True. For example, a script can verify proofs from a transaction, check if a notary/escrow approves the transaction, and that operations with the asset aren't locked for a specified time. The script for the token is invoked upon the following operations with an asset:

TransferTransaction

MassTransferTransaction

ReissueTransaction

BurnTransaction

Use Cases

The main focus for the first version of smart accounts will be different security, integration, and crowdfunding cases. An example of a security use case is multi-signature accounts. A multi-signature account is useful for contracts that need to be jointly owned, or shared, or when binding an agreement between multiple parties, or all of these. With its help, counterparties who do not trust each other can freeze a certain amount of tokens on the blockchain until the condition of having the required number of participants’ signatures is fulfilled.

The next group of use cases is integration, such as Oracles. An Oracle is the application that is responsible for connection to a given data source. It can place externally-sourced data on the blockchain as a series of transactions, but cannot change the data in them. Other people can receive money from a given account if this data meets the right conditions. Conversely, if we want to remove a third party from an operation, a smart contract can be involved in the creation of an Atomic Swap — the next step in decentralisation. An Atomic Swap is a direct trade between two users of different cryptocurrencies, the honesty of which is guaranteed by a single contract in all relevant blockchains that cancels the transfer of funds back to the participants if the agreed exchange has not taken place. (‘Atomic’ in this definition means that an operation will either be performed completely, or it will not be executed at all.)

Crowd sale processes like selling tokens on an exchange can be implemented trustlessly on Waves DEX without smart contracts. However, smart accounts can help investors after an ICO. For example, they can be used to control fund use via escrow, token holder voting, etc.

You can download the whitepaper on the Waves Smart Contracts and read more about them on our website.

Join Waves Community

Read Waves News channel

Follow Waves Twitter

Subscribe to Waves Facebook