What is Smart Account

The functionality of a regular account only allows you to verify that the transaction released from it was actually sent from this account.

Аttaching an account script to an account extends its functionality. It enables checking outgoing transactions for compliance with the conditions specified in the script. An account with a script attached to it is called a smart account. Only those transactions that have been validated can be sent from the smart account. For example, an account owner can set a rule according to which transactions can be sent from the address only if the blockchain height exceeds N. Another example — an account owner can allow sending only certain types of transactions. Or disable any validation other than the rule that all transactions sent from the address should be considered valid.

The following parameters can be used for checks:

Attaching an Account Script to an Account

As we mentioned before, an account without a script validates transactions using the transaction validation mechanism. The operation of this mechanism is equivalent to the operation of the following script:

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

To attach your own script to an account, you need to send a set script transaction from it. Only one script can be attached to an account. “Detaching” a script from a smart account or replacing the old account script with a new one is possible unless the old script forbids it. To "detach" a script or replace it with a new one, you will need to send a new set script transaction. The transaction fee for setting the script is 0.01 WAVES.

Account Script Structure


The directive should be placed at the very beginning of the script. Review the example directive:


The given directive consists of three annotations and provides the compiler with the following information:

  • the script will use the third version of the library of standard functions
  • the type of script content is Expression
  • the script context will be the account context. In particular, this means that this variable type will be Address.

If the directive is missing, then default annotations values will be used:



The expression checks the transactions sent by the account for compliance with the specified conditions. If the conditions are not met, the transaction will not be sent. Possible results of the expression are

  • true (transaction is allowed)
  • false (transaction is not allowed)
  • error

An account script may contain several expressions.

Smart Account Script Examples

Buying or Selling only BTC

An account with the script below can make sales transactions only in relation to BTC:

let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'
let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
match tx {
   case o: Order =>
      sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && (o.assetPair.priceAsset == BTCId || o.assetPair.amountAsset == BTCId)
   case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )

Purchase of a Certain Asset

The script below allows making purchases from your account

  • only a given asset
  • for a given price only
  • only for WAVES
let myAssetId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'

match tx {
   case o: Order =>
      sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && o.assetPair.priceAsset == null && o.assetPair.amountAsset == myAssetId && o.price == 500000 && o.amount == 1000 && o.orderType == Buy
   case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )

Smart Account Fees

If the transaction is sent from a smart account, the transaction fee is increased by 0.004 WAVES. So if the transaction fee is 0.001 WAVES, the owner of the smart account will pay 0.001 + 0.004 = 0.005 WAVES.

results matching ""

    No results matching ""