Numscript

Asset Colors

Restrict Numscript source funds by experimental color tags that track their origin or purpose.

Numscript

Requires flag: experimental-asset-colors

This is a feature of the experimental Numscript interpreter. To run it through the API, set runtime: experimental-interpreter in the transaction request body (the default is machine) and enable the relevant feature flag. See Selecting an Interpreter for per-feature availability.

Restrict which funds can be sourced from an account based on a color tag. Colors track the origin or purpose of funds — useful for compliance, earmarking, or regulatory constraints.

Syntax#

Use \ after a source account to restrict by color:

numscript
#![feature("experimental-asset-colors")]
send [COIN 100] (
  source = @treasury \ "GRANT"
  destination = @programs:education
)

Only funds tagged with the "GRANT" color in @treasury are used. If the account has 200 COIN total but only 80 are tagged "GRANT", this transaction fails with insufficient funds.

Ordered color fallback#

Combine with ordered sources to try different colors in priority:

numscript
#![feature("experimental-asset-colors")]
send [COIN 100] (
  source = {
    @treasury \ "GRANT"
    @treasury \ "DONATION"
    @treasury
  }
  destination = @programs:education
)

Try grant-colored funds first, then donation-colored, then uncolored funds. The final entry is not an "any color" fallback: a source with no color restriction reads the uncolored bucket only, so @treasury there is the same source as @treasury \ "". No single source draws across every color — to reach more buckets, list each one as its own ordered entry.

With overdraft#

Color restrictions can be combined with overdraft:

numscript
#![feature("experimental-asset-colors")]
send [COIN 100] (
  source = @treasury \ "GRANT" allowing unbounded overdraft
  destination = @programs:education
)

Use cases#

  • Earmark funds for specific purposes (grants, donations, operating)
  • Regulatory compliance — track fund origins through the ledger
  • Prevent mixing of restricted and unrestricted funds