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

oneof

Numscript

Requires flag: experimental-oneof

Select the first source or destination that can satisfy the transaction. Unlike ordered sources (which split funds across accounts), oneof picks exactly one branch.

Source#

Try each account in order. The first one with sufficient balance handles the entire amount:

Numscript
send [USD/2 10000] (
  source = oneof {
    @users:1234:main
    @users:1234:savings
    @world
  }
  destination = @merchants:5678
)

If @users:1234:main has 10000 or more, it's used entirely. If not, @users:1234:savings is tried. Falls through to @world only if neither user account can cover the full amount.

This differs from ordered sources ({ @a @b @c }) which would drain @a first, then take the remainder from @b, then @c. With oneof, it's all-or-nothing per branch.

Destination#

Numscript
send [USD/2 10000] (
  source = @revenue
  destination = oneof {
    max [USD/2 5000] to @payouts:priority
    remaining to @payouts:standard
  }
)

The first matching constraint is used. max caps the amount for that branch; remaining catches everything else.

MetadataAccount Interpolation
On This Page
  • Source
  • Destination