Built-in variables

A built-in variable is a variable of the script context.

List of built-in variables

# Name Description
1 Buy Order type
2 height Blockchain height at the script execution time
3 lastBlock Information about the last block of the blockchain at the script execution time
4 nil Variable that contains an empty list.
The variable is used for creating lists. For example, instead of:

    let a = [5,6]

you can write:

    let b = 5::6::nil

Lists are created using both methods. The first method is a syntactic sugar
5
  1. NOALG
  2. MD5
  3. SHA1
  4. SHA224
  5. SHA256
  6. SHA384
  7. SHA512
  8. SHA3224
  9. SHA3256
  10. SHA3384
  11. SHA3512
Variables that are passed as the first parameter to the rsaVerify function
6 Sell Order type
7 this Transaction sender address or information about the token
8 tx Transaction or order
9 unit Variable that contains an object of Unit type. The variable is used by the programmer to acquire an object of Unit type.
Example 1
the deposit function transfers 5 WAVELETs to the account, that called this function.

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}

@Callable(inv)
func deposit() = {
  TransferSet([
    ScriptTransfer(inv.caller, 5, unit) # Transfer 5 WAVELETs to the inv.caller account. Instead of the token ID the unit is specified
  ])
}

WAVES does not have a token ID; the unit is passed instead of the ID.
Example 2
The assetInfo function requests information about the token by its ID. Next, the isDefined function checks that a token with this ID exists on the blockchain.

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ACCOUNT #-}

let asset = assetInfo(base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS')
token.isDefined()

Instead of calling the isDefined function, you may use the equality with unit.

asset != unit
# Expression asset != unit is equivalent to the expression token.isDefined()

results matching ""

    No results matching ""