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
  • CEILING
  • DOWN
  • FLOOR
  • HALFDOWN
  • HALFEVEN
  • HALFUP
  • UP
Rounding methods used in the log and pow functions
3 height Blockchain height at the script execution time
4 lastBlock Information about the last block of the blockchain at the script execution time
5 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
6
  • NOALG
  • MD5
  • SHA1
  • SHA224
  • SHA256
  • SHA384
  • SHA512
  • SHA3224
  • SHA3256
  • SHA3384
  • SHA3512
Variables that are passed as the first parameter to the rsaVerify function
7 Sell Order type
8 this Transaction sender address or information about the token
9 tx Transaction or order
10 unit Variable that contains 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 ""