_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
      • oneofexp
      • Account Interpolationexp
      • get_assetexp
      • get_amountexp
      • Mid-script Function Callsexp
      • Asset Colorsexp
  • Connectivity
  • WalletsEE
  • FlowsEE
  • ReconciliationEE
  1. Modules
  2. Numscript
  3. Reference
  4. Destinations
Numscript

Destinations

As with sources, there are several options when it comes to deciding where should funds in a financial transaction come from. The send statement provides the following ways of defining destinations:

Single destination#

Numscript
send [COIN 100] (
  source = @world
  destination = @users:001
)

Allocation destinations#

Similar to portioned sources, destination can be defined as a sequence of fractions to split the monetary onto multiple accounts.

In any case, the summed total of fractions in a block needs to be equal to 1 and the remaining keyword can be used to reach that total:

Numscript
send [COIN 100] (
  source = @world
  destination = {
    90/100 to @users:001
    remaining to @fees
  }
)

Out of convenience, percentage notation is also available:

Numscript
send [COIN 100] (
  source = @world
  destination = {
    90% to @users:001
    remaining to @fees
  }
)

Kept destinations#

Instead of transferring all funds to new accounts, you can keep part of the amount in the source account with the kept keyword. It stands in for a destination account inside a block, and pairs naturally with remaining to keep whatever is left after the explicit allocations:

Numscript
send [COIN 100] (
  source = @world
  destination = {
    50% to @users:001
    remaining kept
  }
)

Here 50% of the amount goes to users:001 and the remaining 50% stays in world. This is useful when you only want to transfer a portion of the funds.

Ordered destinations with maximum caps#

Ordered destinations route funds to multiple accounts in sequence, sending up to a maximum cap to each one before moving on. Any leftover goes to the final remaining destination:

Numscript
send [COIN 100] (
  source = @world
  destination = {
    max [COIN 20] to @users:001
    max [COIN 50] to @users:002
    remaining to @users:003
  }
)

This sends COIN 20 to users:001, COIN 50 to users:002, and the remaining COIN 30 to users:003.

Nested destinations#

Finally, as with sources, destination blocks can be nested:

Numscript
send [COIN 100] (
  source = @world
  destination = {
    80% to @users:001
    20% to {
      70% to @platform
      15% to @taxes
      remaining to @charity
    }
  }
)
SourcesRounding
On This Page
  • Single destination
  • Allocation destinations
  • Kept destinations
  • Ordered destinations with maximum caps
  • Nested destinations