RIDE Smart Contracts

Smart Contract is a script that checks transactions for compliance with conditions. Scripts extend the logic of blockchain to meet your business tasks. The fee for smart contract is fixed. The script can be published for both an account and token assets issued by you.

For an account, all transactions originating from this address will be checked. An account with a published script is called a Smart Account. For token assets, all transactions with these token assets will be checked. A token asset with a published script is called a Smart Asset. Only 1 script can be assigned to one account. Accordingly, any installed script replaces the previous one, including the “default script”.

RIDE

The RIDE language is used for creating a script in the Waves Enterprise blockchain (about RIDE language you can read on the WAVES portal https://docs.wavesplatform.com). Scripts written in RIDE use the following data when checking conditions:

  • Outgoing transaction details.
  • Details of account on behalf of which transactions are made.
  • Details of third accounts balance.
  • Details of blockchain height.

The principle of the script operation is pattern matching. The script specifies transaction types and checks them for compliance with conditions under which corresponding transactions can be executed. Also, the following features are available:

  • ban transaction regardless of conditions,
  • permit regardless of conditions.

Operations with permissions and bans per transaction types are possible both by specifying specific transaction types and using the “everything but” principle. The script is set by the Setscript transaction, so permission, prohibition or verification for compliance with conditions must be explicitly specified.

Important

The script does not modify the transaction, it only verifies that the conditions are met.

Complexity of scripts

RIDE is not a Turing-complete language, which imposes limitations on the available complexity of logic. Computational complexity is constrained from the top to guarantee network performance. For complex business processes, the mechanics of which does not fit into one script, a combination of several scripts (for several addresses, respectively), or a combination of scripts for token assets and address can be used. We are actively developing RIDE features, and in the near future nested functions expanding its capabilities in terms of complexity of tasks to be implemented will appear in the language.

Signatures and default script

Each transaction in the blockchain has a cryptographic proof of integrity based on the signature of the transaction by the sender’s private key. This also guarantees that transaction authorship is unalienable. For a better understanding of the mechanism, imagine that “by default” a script is installed on each address, which verifies the only condition for each outgoing transaction — the signature of the sender’s address.

Example of a default script code:

sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPk)

The script mechanics enhances proof verification capabilities. A transaction can be signed by multiple users or other than on behalf of the address from which it was sent. This is necessary because the contract checks only transactions originating from its address. Accordingly, the user generates a transaction on behalf of the contract, signs it with his proof and successfully passes the script test.

Important

If the proof verification is not explicitly specified in your script, it is not executed. Accordingly, when the transaction body is generated manually, it is possible to send transactions on behalf of an address with a script with another address proof.

Account data

Data can be stored in the key-value format on addresses in the Waves Enterprise blockchain. The data stored on the address is available for viewing at the request return data from address by key. The data is placed on the address when sending a data transaction. Since RIDE scripts are stateless, data transactions form an updated data storage which the script addresses. Configuring proof verification on a smart account allows multiple users to collaborate on data on a smart account. For example, with document flow statuses.

Important

Keys are unique for the address. Only one value corresponds to one address key. When publishing a new value for an existing key, it will be overwritten. The history and the author of changes can be tracked in the blockchain.