_Docs/
Get StartedModulesPlatformDeployCookbookChangelogReference
_Stack
_Modules
  • Ledger
  • Numscript
    • Program Structure
    • Selecting an Interpreter
    • Unambiguous Monetary Notation
    • CLI
    • Numscript specs format
    • Reference
      • Send
      • Sources
      • Destinations
      • Rounding
      • Save
      • Overdraft
      • Variables
      • Metadata
      • Functions
      • oneofexp
      • Account Interpolationexp
      • get_assetexp
      • get_amountexp
      • Mid-script Function Callsexp
      • Asset Colorsexp
  • Connectivity
  • WalletsEE
  • FlowsEE
  • ReconciliationEE
  1. Modules
  2. Numscript
  3. Reference
  4. Functions
Numscript

Functions

Built-in functions callable from Numscript. Which functions you can use depends on the interpreter version bundled in your Ledger release — see Selecting an Interpreter for the full availability matrix.

Numscript

The entries below reflect your current selection: each experimental function shows whether it is available for the interpreter version you have selected.

Statements#

These are available on both the original (machine) and experimental interpreters.

set_tx_meta("key", value)#

Writes metadata to the transaction. The key is a string; the value can be any type, as a literal or a variable. Details

Available from: all versions (machine and experimental-interpreter).

set_account_meta(account, "key", value)#

Writes metadata to an account during the transaction. Details

Available from: all versions (machine and experimental-interpreter).

Functions in vars#

These functions are called when initializing variables in the vars block. They require the experimental interpreter (runtime: experimental-interpreter) and the experimental-mid-script-function-call flag.

meta(account, "key")#

Reads structured account metadata into a typed variable. Details

Available from: interpreter 0.0.15 · Ledger 2.3 · Stack v3.1 · flag experimental-mid-script-function-call

Available in your selected version.

balance(account, asset)#

Returns the balance of an account for an asset. Fails on negative balances — use overdraft() for accounts that may go negative. Details

Available from: interpreter 0.0.15 · Ledger 2.3 · Stack v3.1 · flag experimental-mid-script-function-call

Available in your selected version.

overdraft(account, asset)#

Returns the positive overdraft amount of an account, or zero if the balance is non-negative. Details

Available from: interpreter 0.0.15 · Ledger 2.3 · Stack v3.1 · flags experimental-overdraft-function, experimental-mid-script-function-call

Available in your selected version.

get_asset(monetary)#

Returns the asset part of a monetary value. Details

Available from: interpreter 0.0.16 · Ledger 2.3 · Stack v3.1 · flag experimental-get-asset-function

Available in your selected version.

get_amount(monetary)#

Returns the numeric amount part of a monetary value. Details

Available from: interpreter 0.0.16 · Ledger 2.3 · Stack v3.1 · flag experimental-get-amount-function

Available in your selected version.
Metadataoneof
On This Page
  • Statements
  • set_tx_meta("key", value)
  • set_account_meta(account, "key", value)
  • Functions in vars
  • meta(account, "key")
  • balance(account, asset)
  • overdraft(account, asset)
  • get_asset(monetary)
  • get_amount(monetary)