_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. Selecting an Interpreter
Numscript

Selecting an Interpreter

Since Ledger v2.2, two versions of the Numscript interpreter are available: the original, built directly into our Ledger service, and a new portable and embeddable interpreter that can run independently or enhance other ledgering systems.

The original interpreter is enabled by default but is no longer evolving, while the new version will receive ongoing updates and must be manually enabled.

To enable the new interpreter:

ledger.experimental-features
example: truedefault: falsebool

Enables general experimental features in the ledger by setting the EXPERIMENTAL_FEATURES environment variable on the deployment.

This setting can be configured on Formance Cloud deployments by contacting your Formance Cloud support team.
ledger.experimental-numscript
example: truedefault: falsebool

Enables the experimental Numscript interpreter in the ledger by setting the EXPERIMENTAL_NUMSCRIPT_INTERPRETER environment variable.

This setting can be configured on Formance Cloud deployments by contacting your Formance Cloud support team.

The new interpreter supports additional language features not available in the original, including oneof, account interpolation, asset colors, and more. See the Numscript reference for the full list and how to enable each one.

Selecting the interpreter per transaction#

Each transaction picks its interpreter through the runtime field on the create-transaction request body:

  • machine (default) — the original interpreter built into the Ledger.
  • experimental-interpreter — the new interpreter. Required for any experimental feature.

Using runtime: experimental-interpreter also requires the Ledger to run with the new interpreter enabled (the ledger.experimental-features and ledger.experimental-numscript settings above), and each experimental feature must additionally be enabled via its own #![feature(...)] flag.

Experimental feature availability#

Which experimental features you can use depends on the Numscript interpreter version bundled in your Ledger release. The reference pages reflect this automatically — a feature only appears once your selected Stack/Ledger version bundles an interpreter recent enough to support it.

FeatureFlagInterpreterAvailable from
OneOfexperimental-oneof0.0.15Ledger 2.3 / Stack v3.1
Account interpolationexperimental-account-interpolation0.0.15Ledger 2.3 / Stack v3.1
Mid-script function callsexperimental-mid-script-function-call0.0.15Ledger 2.3 / Stack v3.1
Overdraft functionexperimental-overdraft-function0.0.15Ledger 2.3 / Stack v3.1
get_assetexperimental-get-asset-function0.0.16Ledger 2.3 / Stack v3.1
get_amountexperimental-get-amount-function0.0.16Ledger 2.3 / Stack v3.1
Asset colorsexperimental-asset-colors0.0.17Ledger 2.3 / Stack v3.1

For the callable functions specifically (with live per-function availability against your selection), see Functions.

The Numscript playground uses the new interpreter. Experimental features can be toggled individually in the playground's feature flags selector.

Program StructureUnambiguous Monetary Notation
On This Page
  • Selecting the interpreter per transaction
  • Experimental feature availability