Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Formula language reference

Formulas are string expressions evaluated at transaction build time. They appear in output/input amount_sat, validation expr, hook set values, and witness expr.

Operators

OperatorDescription
+ - * /Integer arithmetic (division truncates)
== != < <= > >=Comparison (returns boolean)
&& || !Boolean logic
( )Grouping

References

SyntaxDescription
compile_params.NAMECompile parameter by name
params.NAMEAction parameter by name
args.NAMEAction argument by name
input_id.amount_satSatoshi amount of a resolved input
input_id.assetAsset ID of a resolved input (hex string)
input_id.presentBoolean — whether an optional input was found
output_id.amount_satSatoshi amount of a constructed output (post-construction)
feesEstimated transaction fee (used in change formulas)

Functions

FunctionSignatureDescription
pow(base, exp)(u64, u64) → u64Integer exponentiation
index_of(id)(input or output id) → u32Transaction index of a named input/output
concat(a, b, …)(bytes…) → bytesByte concatenation (OP_RETURN data only)

See Spec.md §9 for the authoritative grammar.