RIDE Smart Contracts

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

For any given account, a check is performed on all transactions originating from the account’s address. An account with a published script is called a smart account. For any given token assets, a check is performed on all transactions using that token asset. A token asset with a published script is called a smart asset. Only one 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 scripts on the Waves Enterprise blockchain platform (you can read more about RIDE language on the WAVES portal). Scripts written in RIDE check conditions use the following data:

  • Outgoing transaction details.

  • Details of the account on behalf of which transactions are made.

  • Details of the third accounts balance.

  • Details of the blockchain height.

The principle of script operation is pattern matching. The script specifies transaction types and checks them for compliance with conditions under which corresponding transactions can be executed. Scrips can also permit or ban transactions regardless of conditions. Also there are such options:

  • ban transaction regardless of conditions,

  • permit regardless of conditions.

Operations with permitted and banned transactions specify transaction types and use 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

Scripts do not modify transactions. They only verify that conditions are met.

Complexity of scripts

RIDE is not a Turing-complete language, which imposes limitations on how complex a script’s logic can be. This helps guarantee network performance. For complex business processes, the mechanics of which do not fit into one script, a combination of several scripts for several addresses can be used, or a combination of scripts for token assets and addresses. The Waves team is actively developing RIDE features, and in the near future, nested functions that can facilitate more complex tasks will be available to developers.

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 guarantees that transaction authorship is unalienable. For example, a script which is installed on each address by default 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)

These script mechanics enhance proof verification capabilities. A transaction can be signed by another user or multiple users on behalf of the address from which it was sent. This is necessary because a contract can only check transactions originating from its own 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 proof verification is not explicitly specified in your script, it is not executed. Accordingly, when a transaction’s body is generated manually, it is possible to send transactions on behalf of an address using 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 using 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 update the data stored, which the script addresses. Configuring proof verification on a smart account allows multiple users to collaborate on data on a smart account in different ways.

Important

Keys are unique for each address. Only one value corresponds to one address key. Publishing a new value for an existing key will result in the value being overwritten. The history and the author of changes can be tracked in the blockchain.