Assembly

Constraint

All operations available to the constraint checker. Note that this is a subset of the operations available to state read execution.

Stack

Operations related to stack manipulation.

NameStack InStack OutPanicsDescription
Push: 0x1 arg bytes: 8valuePush one word onto the stack.
Pop: 0x2aPop one word from the stack.
Dup: 0x3valuevalue, valueDuplicate the top word on the stack.
DupFrom: 0x4indexvalue_iDuplicate the word at the given stack depth index. 0 is the index of the element at the top of the stack.
Swap: 0x5a, bb, aSwap top two words on stack.
SwapIndex: 0x6a, b, c, d, indexa, d, c, bIndex is out of range.Swap the top word on the stack with the word at the given stack depth index. 0 is the index of the element at the top of the stack.
Select: 0x7a, b, condbConditionally keep one of the top two elements on the stack. If condition is true, the top element is kept.
SelectRange: 0x8arr_a_0, ..arr_a_N, arr_b_0, ..arr_b_N, len, condarr_b_0, ..arr_b_NConditionally keep one of the top two ranges on the stack. If condition is true, the top range is kept. The ranges must be of equal length. The ranges must be stacked sequentially. Here N is len -1.
Repeat: 0x9num_repeats, count_up_boolRepeat a section of code the number of times. Takes a boolean to either count from 0 up or from the number of repeats down to 0.
RepeatEnd: 0xAIf there is no counter on the repeat stack., If there is no repeat registered to return to.Increment or decrements the top counter on the repeat stack. If the counter is counting up and counter == limit - 1 then this pops the counter and continues with the program. If the counter is counting down and the counter is 0 then this pops the counter and continues with the program. If it is < limit - 1 or > 0 respectively then the program jumps to the last Repeat

Pred

Operations for computing predicates.

NameStack InStack OutPanicsDescription
Eq: 0x10lhs, rhslhs == rhsCheck equality of two words.
EqRange: 0x11arr_a_0, ..arr_a_N, arr_b_0, ..arr_b_N, len(top-(2*len))..(top - len) == (top - len)..topCheck equality of two ranges on the stack. The ranges must be of equal length. The ranges must be stacked sequentially. Here N is len -1.
Gt: 0x12lhs, rhslhs > rhsCheck if left-hand side is greater than right-hand side.
Lt: 0x13lhs, rhslhs < rhsCheck if left-hand side is less than right-hand side.
Gte: 0x14lhs, rhslhs >= rhsCheck if left-hand side is greater than or equal to right-hand side.
Lte: 0x15lhs, rhslhs <= rhsCheck if left-hand side is less than or equal to right-hand side.
And: 0x16lhs, rhslhs && rhsLogical AND of two words.
Or: 0x17lhs, rhslhsrhs
Not: 0x18a!aLogical NOT of a word.

Alu

Operations for computing arithmetic and logic.

NameStack InStack OutPanicsDescription
Add: 0x20lhs, rhslhs + rhsAdd two words.
Sub: 0x21lhs, rhslhs - rhsSubtract two words.
Mul: 0x22lhs, rhslhs * rhsMultiply two words.
Div: 0x23lhs, rhslhs / rhsInteger division.
Mod: 0x24lhs, rhslhs % rhsModulus of lhs by rhs.

Access

Operations for accessing input data.

NameStack InStack OutPanicsDescription
DecisionVar: 0x30slotdecision_wordThe slot is out of range., If the slot is empty.Access the first word in a decision variable slot by slot. The slot must be in range. Returns a decision word.
DecisionVarAt: 0x31slot, indexdecision_wordThe slot is out of range., The index is out of range.Access a word in a decision variable slot by slot and index. The slot and index must be in range. Returns a decision word.
DecisionVarRange: 0x32slot, index, lenelem: decision_word len: rangeThe slot is out of range., The range index..(index + len) is out of range.Access a range of decision variables slot words starting from a specified slot and index. Returns a list of decision words with length equal to the specified len.
DecisionVarLen: 0x33slotlenThe slot is out of range.Get the length of a specified slot.
State: 0x34slot, deltastate_slot_w0, ...state_slot_wNThe slot is out of range.Access a state variable by slot. If the slot is empty, this is a noop. The delta parameter determines if changes are considered. Use StateLen to get the length of the state variable.
StateRange: 0x35slot, range, deltastate_word_0, ...state_word_M, state_word_0, ...state_word_N, ...The range slot..(slot + range) is out of range.Access a range of state variables starting from a specified slot. Empty slots will not write anything to the stack. The delta parameter determines if changes are considered. Returns a list of state words with length equal to the specified range. Use StateLenRange to get the lengths of the state variables.
StateLen: 0x36slot, deltalenThe slot is out of range.Get the length of a state variable at a specified slot. Returns a the length of the state variable.
StateLenRange: 0x37slot, range, deltaelem: length len: rangeThe range slot..(slot + range) is out of range.Get the lengths of a range of state variables starting from a specified slot. Returns a list of lengths, each being the length of a state variable in the range.
MutKeysLen: 0x38wordGet the number of mutable keys being proposed for mutation. This operation returns a single word representing the length.
MutKeysContains: 0x39key, key_lenboolCheck if the mutable keys being proposed contain the given key. This operation returns a true if the key is found, false otherwise.
ThisAddress: 0x3AkeyGet the content hash of this predicate. This operation returns a list of words with a length of 4, representing the hash.
ThisContractAddress: 0x3BkeyGet the content hash of the contract this predicate belongs to. This operation returns a list of words with a length of 4, representing the contract's hash.
ThisPathway: 0x3CinGet the pathway of this predicate. This operation returns the index of the solution data currently being used to check this predicate.
RepeatCounter: 0x3Dcounter_valueAccess the top repeat counters current value.
Transient: 0x3Ekey_0, ...key_N, key_len, pathwayelem: slot_word len: value_lenGet the solution data indexed by pathway and key.
TransientLen: 0x3Fkey_0, ...key_N, key_len, pathwaylenGet the length of solution data indexed by pathway and key.
PredicateAt: 0x40pathwaycontract_key_0, contract_key_1, contract_key_2, contract_key_3, predicate_key_0, predicate_key_1, predicate_key_2, predicate_key_3Get the predicate at solution data pathway.
ThisTransientLen: 0x41lenGet the length of the transient data at this predicate.
ThisTransientContains: 0x42key_0, ...key_N, key_lenboolCheck if the transient data at this predicate contains the given key.

Crypto

Operations providing cryptographic functionality.

NameStack InStack OutPanicsDescription
Sha256: 0x50data, data_lenhash_w0, hash_w1, hash_w2, hash_w3Produce a SHA 256 hash from the specified data.
VerifyEd25519: 0x51data, data_len, sig_w0, sig_w1, sig_w2, sig_w3, sig_w4, sig_w5, sig_w6, sig_w7, key_w0, key_w1, key_w2, key_w3boolValidate an Ed25519 signature against a public key.
RecoverSecp256k1: 0x52hash_0, hash_1, hash_2, hash_3, sig_w0, sig_w1, sig_w2, sig_w3, sig_w4, sig_w5, sig_w6, sig_w7, sig_8pub_key_w0, pub_key_w1, pub_key_w2, pub_key_w3, pub_key_4Recover the public key from a secp256k1 signature. If the signature is invalid, the operation will return all zeros.

TotalControlFlow

Control flow operations that keep the program total.

NameStack InStack OutPanicsDescription
Halt: 0x60End the execution of the program.
HaltIf: 0x61valueHalt the program if the value is true.
JumpForwardIf: 0x63n_instruction, conditionThe jump is out of bounds., The jump is negative., The jump distance is zero.Jump forward the given number of instructions if the value is true.

Temporary

Operations for temporary memory.

NameStack InStack OutPanicsDescription
Alloc: 0x70sizeindexMax memory size reached.Allocate new memory to the end of the temporary memory. Sets new memory to 0. Returns the index to the start of the new block of memory.
Load: 0x71indexvalueIndex is out of bounds.Load the value at the index of temporary memory onto the stack.
Store: 0x72index, valueIndex is out of bounds.Store the value at the index of temporary memory.

StateSlots

Operations for controlling mutable state slots.

NameStack InStack OutPanicsDescription
AllocSlots: 0x80sizeAllocate new slots to the end of the memory.
Load: 0x81indexelem: value_word len: value_lenIndex is out of bounds.Load the value at the index of a slot onto the stack. Noop if the slot is empty.
Store: 0x82value_word_0, ...value_word_len, len, indexIndex is out of bounds.Store the value at the index of state slots.
LoadWord: 0x83slot, indexValue_wordSlot or Index is out of bounds.Load the word at the index of the value at the slot onto the stack.
StoreWord: 0x84slot, index, wordSlot or Index is out of bounds.Store the word at the index of the value at the slot.
Clear: 0x85indexIndex is out of bounds.Clear the value at the index.
ClearRange: 0x86index, amountThe range is out of bounds.Clear a range of values.
Length: 0x87lengthGet the current length of the memory.
ValueLen: 0x88indexlengthGet the current length of a given value at the index.

KeyRange

NameStack InStack OutPanicsDescription
KeyRange: 0x90key_w0, ...key_wN, key_len, num_keys_to_read, slot_indexRead a range of values at each key from state starting at the key into state slots starting at the slot index. The key is lexographically incremented for each value read. All keys are assumed to be the same length. Returns the values onto the stack, followed by their indices.

KeyRangeExtern

NameStack InStack OutPanicsDescription
KeyRangeExtern: 0x91ext_w0, ext_w1, ext_w2, ext_w3, key_w0, ...key_wN, key_len, num_keys_to_read, slot_indexRead a range of values at each key from external state starting at the key into state slots starting at the slot index. The key is lexographically incremented for each value read. The external state is at the ext address. Returns the values onto the stack, followed by their indices.