_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. Sources
Numscript

Sources

There are several options when it comes to deciding where should the money come from. The send statement makes it handy by providing the following possibilities:

Single source#

The simplest way of sending a monetary value is from a single source. Here, we draw COIN 100 from the world account:

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

Ordered sources#

Using an ordered source block, you can defined several accounts to draw from sequentially until the desired monetary value is reached.

Numscript
send [COIN 100] (
  source = {
    @users:001:wallet
    @payments:001
  }
  destination = @orders:001
)

In example above, if the balance of COIN on the account users:001:wallet is 30, another 70 will be drawn from the payments:001 account.

Ordered sources can also be maxed to a monetary, preventing them from being drawn more than the amount specified:

Numscript
send [COIN 100] (
  source = {
    max [COIN 10] from @users:001:wallet
    @payments:001
  }
  destination = @orders:001
)

Portioned sources#

In addition to sequential accounts, source blocks can also use fractions to split the expense 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 = {
    10/100 from @platform:marketing
    remaining from @users:001:wallet
  }
  destination = @orders:001
)

Out of convenience, percentage notation is also available:

Numscript
send [COIN 100] (
  source = {
    10% from @platform:marketing
    remaining from @users:001:wallet
  }
  destination = @orders:001
)

Nested sources#

Source blocks can be nested with a combination of recursive ordered / portioned specifications:

Numscript
send [COIN 100] (
  source = {
    50% from {
      max [COIN 10] from @users:001:wallet
      @users:001:chest
    }
    remaining from @payments:001
  }
  destination = @orders:001
)
SendDestinations
On This Page
  • Single source
  • Ordered sources
  • Portioned sources
  • Nested sources