FuelVM Instruction Set

Reading Guide

This page provides a description of all instructions for the FuelVM. Encoding is read as a sequence of one 8-bit value (the opcode identifier) followed by four 6-bit values (the register identifiers or immediate value). A single i indicates a 6-bit immediate value, i i indicates a 12-bit immediate value, i i i indicates an 18-bit immediate value, and i i i i indicates a 24-bit immediate value. All immediate values are interpreted as big-endian unsigned integers.

  • The syntax MEM[x, y] used in this page means the memory range starting at byte x, of length y bytes.
  • The syntax STATE[x, y] used in this page means the sequence of storage slots starting at key x and spanning y bytes.

Some instructions may panic, i.e. enter an unrecoverable state. Additionally, attempting to execute an instruction not in this list causes a panic and consumes no gas. How a panic is handled depends on context:

  • In a predicate context, cease VM execution and return false.
  • In other contexts, revert (described below).

On a non-predicate panic, append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Panic
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
pcuint64Value of register $pc.
isuint64Value of register $is.

then append an additional receipt to the list of receipts, again modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.ScriptResult
resultuint641
gas_useduint64Gas consumed by the script.

A few instructions are annotated with the effects they produce, the table below explains each effect:

effect namedescription
Storage readInstruction reads from storage slots
Storage writeInstruction writes to storage slots
External callExternal contract call instruction
Balance tree readInstruction reads from the balance tree
Balance tree writeInstruction writes to the balance tree
Output messageInstruction sends a message to a recipient address

If an instruction is not annotated with an effect, it means it does not produce any of the aforementioned affects.

Arithmetic/Logic (ALU) Instructions

All these instructions advance the program counter $pc by 4 after performing their operation.

If the F_UNSAFEMATH flag is set, an ALU operation that would have panicked will instead set $err to true.

If the F_WRAPPING flag is set, an ALU operation that would have panicked will instead set $of to the overflow of the operation.

ADD: Add

DescriptionAdds two registers.
Operation$rA = $rB + $rC;
Syntaxadd $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of is assigned the overflow of the operation.

$err is cleared.

ADDI: Add immediate

DescriptionAdds a register and an immediate value.
Operation$rA = $rB + imm;
Syntaxaddi $rA, $rB, immediate
Encoding0x00 rA rB i i
Notes

Panic if:

$of is assigned the overflow of the operation.

$err is cleared.

AND: AND

DescriptionBitwise ANDs two registers.
Operation$rA = $rB & $rC;
Syntaxand $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

ANDI: AND immediate

DescriptionBitwise ANDs a register and an immediate value.
Operation$rA = $rB & imm;
Syntaxandi $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

imm is extended to 64 bits, with the high 52 bits set to 0.

$of and $err are cleared.

DIV: Divide

DescriptionDivides two registers.
Operation$rA = $rB // $rC;
Syntaxdiv $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

If $rC == 0, $rA is cleared and $err is set to true.

Otherwise, $err is cleared.

$of is cleared.

DIVI: Divide immediate

DescriptionDivides a register and an immediate value.
Operation$rA = $rB // imm;
Syntaxdivi $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

If imm == 0, $rA is cleared and $err is set to true.

Otherwise, $err is cleared.

$of is cleared.

EQ: Equals

DescriptionCompares two registers for equality.
Operation$rA = $rB == $rC;
Syntaxeq $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

EXP: Exponentiate

DescriptionRaises one register to the power of another.
Operation$rA = $rB ** $rC;
Syntaxexp $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

If the result cannot fit in 8 bytes, $of is set to 1 and $rA is instead set to 0, otherwise $of is cleared.

$err is cleared.

EXPI: Exponentiate immediate

DescriptionRaises one register to the power of an immediate value.
Operation$rA = $rB ** imm;
Syntaxexpi $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

If the result cannot fit in 8 bytes, $of is set to 1 and $rA is instead set to 0, otherwise $of is cleared.

$err is cleared.

GT: Greater than

DescriptionCompares two registers for greater-than.
Operation$rA = $rB > $rC;
Syntaxgt $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

LT: Less than

DescriptionCompares two registers for less-than.
Operation$rA = $rB < $rC;
Syntaxlt $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

MLOG: Math logarithm

DescriptionThe (integer) logarithm base $rC of $rB.
Operation$rA = math.floor(math.log($rB, $rC));
Syntaxmlog $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

If $rB == 0, both $rA and $of are cleared and $err is set to true.

If $rC <= 1, both $rA and $of are cleared and $err is set to true.

Otherwise, $of and $err are cleared.

MOD: Modulus

DescriptionModulo remainder of two registers.
Operation$rA = $rB % $rC;
Syntaxmod $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

If $rC == 0, both $rA and $of are cleared and $err is set to true.

Otherwise, $of and $err are cleared.

MODI: Modulus immediate

DescriptionModulo remainder of a register and an immediate value.
Operation$rA = $rB % imm;
Syntaxmodi $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

If imm == 0, both $rA and $of are cleared and $err is set to true.

Otherwise, $of and $err are cleared.

MOVE: Move

DescriptionCopy from one register to another.
Operation$rA = $rB;
Syntaxmove $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

$of and $err are cleared.

MOVI: Move immediate

DescriptionCopy an immediate value into a register.
Operation$rA = imm;
Syntaxmovi $rA, imm
Encoding0x00 rA i i i
Notes

Panic if:

$of and $err are cleared.

MROO: Math root

DescriptionThe (integer) $rCth root of $rB.
Operation$rA = math.floor(math.root($rB, $rC));
Syntaxmroo $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

If $rC == 0, both $rA and $of are cleared and $err is set to true.

Otherwise, $of and $err are cleared.

MUL: Multiply

DescriptionMultiplies two registers.
Operation$rA = $rB * $rC;
Syntaxmul $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of is assigned the overflow of the operation.

$err is cleared.

MULI: Multiply immediate

DescriptionMultiplies a register and an immediate value.
Operation$rA = $rB * imm;
Syntaxmul $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

$of is assigned the overflow of the operation.

$err is cleared.

NOOP: No operation

DescriptionPerforms no operation.
Operation
Syntaxnoop
Encoding0x00 - - - -
Notes

$of and $err are cleared.

NOT: Invert

DescriptionBitwise NOT a register.
Operation$rA = ~$rB;
Syntaxnot $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

$of and $err are cleared.

OR: OR

DescriptionBitwise ORs two registers.
Operation$rA = $rB \| $rC;
Syntaxor $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

ORI: OR immediate

DescriptionBitwise ORs a register and an immediate value.
Operation$rA = $rB \| imm;
Syntaxori $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

imm is extended to 64 bits, with the high 52 bits set to 0.

$of and $err are cleared.

SLL: Shift left logical

DescriptionLeft shifts a register by a register.
Operation$rA = $rB << $rC;
Syntaxsll $rA, $rB, $rC
Encoding0x00 rA rB rC -
NotesZeroes are shifted in.

Panic if:

$of and $err are cleared.

SLLI: Shift left logical immediate

DescriptionLeft shifts a register by an immediate value.
Operation$rA = $rB << imm;
Syntaxslli $rA, $rB, imm
Encoding0x00 rA rB i i
NotesZeroes are shifted in.

Panic if:

$of and $err are cleared.

SRL: Shift right logical

DescriptionRight shifts a register by a register.
Operation$rA = $rB >> $rC;
Syntaxsrl $rA, $rB, $rC
Encoding0x00 rA rB rC -
NotesZeroes are shifted in.

Panic if:

$of is assigned the underflow of the operation, as though $of is the high byte of a 128-bit register.

$err is cleared.

SRLI: Shift right logical immediate

DescriptionRight shifts a register by an immediate value.
Operation$rA = $rB >> imm;
Syntaxsrli $rA, $rB, imm
Encoding0x00 rA rB i i
NotesZeroes are shifted in.

Panic if:

$of is assigned the underflow of the operation, as though $of is the high byte of a 128-bit register.

$err is cleared.

SUB: Subtract

DescriptionSubtracts two registers.
Operation$rA = $rB - $rC;
Syntaxsub $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes$of is assigned the overflow of the operation.

Panic if:

$of is assigned the underflow of the operation, as though $of is the high byte of a 128-bit register.

$err is cleared.

SUBI: Subtract immediate

DescriptionSubtracts a register and an immediate value.
Operation$rA = $rB - imm;
Syntaxsubi $rA, $rB, imm
Encoding0x00 rA rB i i
Notes$of is assigned the overflow of the operation.

Panic if:

$of is assigned the underflow of the operation, as though $of is the high byte of a 128-bit register.

$err is cleared.

XOR: XOR

DescriptionBitwise XORs two registers.
Operation$rA = $rB ^ $rC;
Syntaxxor $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

$of and $err are cleared.

XORI: XOR immediate

DescriptionBitwise XORs a register and an immediate value.
Operation$rA = $rB ^ imm;
Syntaxxori $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

$of and $err are cleared.

Control Flow Instructions

JMP: Jump

DescriptionJumps to the code instruction offset by a register.
Operation$pc = $is + $rA * 4;
Syntaxjmp $rA
Encoding0x00 rA - - -
Notes

Panic if:

  • $is + $rA * 4 > VM_MAX_RAM - 1

JI: Jump immediate

DescriptionJumps to the code instruction offset by imm.
Operation$pc = $is + imm * 4;
Syntaxji imm
Encoding0x00 i i i i
Notes

Panic if:

  • $is + imm * 4 > VM_MAX_RAM - 1

JNE: Jump if not equal

DescriptionJump to the code instruction offset by a register if $rA is not equal to $rB.
Operationif $rA != $rB:
$pc = $is + $rC * 4;
else:
$pc += 4;
Syntaxjne $rA $rB $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $is + $rC * 4 > VM_MAX_RAM - 1

JNEI: Jump if not equal immediate

DescriptionJump to the code instruction offset by imm if $rA is not equal to $rB.
Operationif $rA != $rB:
$pc = $is + imm * 4;
else:
$pc += 4;
Syntaxjnei $rA $rB imm
Encoding0x00 rA rB i i
Notes

Panic if:

  • $is + imm * 4 > VM_MAX_RAM - 1

JNZI: Jump if not zero immediate

DescriptionJump to the code instruction offset by imm if $rA is not equal to $zero.
Operationif $rA != $zero:
$pc = $is + imm * 4;
else:
$pc += 4;
Syntaxjnzi $rA imm
Encoding0x00 rA i i i
Notes

Panic if:

  • $is + imm * 4 > VM_MAX_RAM - 1

RET: Return from context

DescriptionReturns from context with value $rA.
Operationreturn($rA);
Syntaxret $rA
Encoding0x00 rA - - -
Notes

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Return
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
valuint64Value of register $rA.
pcuint64Value of register $pc.
isuint64Value of register $is.

If current context is external, append an additional receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.ScriptResult
resultuint640
gas_useduint64Gas consumed by the script.

If current context is external, cease VM execution and return $rA.

Returns from contract call, popping the call frame. Before popping perform the following operations.

Return the unused forwarded gas to the caller:

  1. $cgas = $cgas + $fp->$cgas (add remaining context gas from previous context to current remaining context gas)

Set the return value:

  1. $ret = $rA
  2. $retl = 0

Then pop the call frame and restoring registers except $ggas, $cgas, $ret, and $retl. Afterwards, set the following registers:

  1. $pc = $pc + 4 (advance program counter from where we called)

Memory Instructions

All these instructions advance the program counter $pc by 4 after performing their operation.

ALOC: Allocate memory

DescriptionAllocate a number of bytes from the heap.
Operation$hp = $hp - $rA;
Syntaxaloc $rA
Encoding0x00 rA - - -
NotesDoes not initialize memory.

Panic if:

  • $hp - $rA underflows
  • $hp - $rA < $sp

CFEI: Extend call frame immediate

DescriptionExtend the current call frame's stack by an immediate value.
Operation$sp = $sp + imm
Syntaxcfei imm
Encoding0x00 i i i i
NotesDoes not initialize memory.

Panic if:

  • $sp + imm overflows
  • $sp + imm > $hp

CFSI: Shrink call frame immediate

DescriptionShrink the current call frame's stack by an immediate value.
Operation$sp = $sp - imm
Syntaxcfsi imm
Encoding0x00 i i i i
NotesDoes not clear memory.

Panic if:

  • $sp - imm underflows
  • $sp - imm < $ssp

LB: Load byte

DescriptionA byte is loaded from the specified address offset by imm.
Operation$rA = MEM[$rB + imm, 1];
Syntaxlb $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

LW: Load word

DescriptionA word is loaded from the specified address offset by imm.
Operation$rA = MEM[$rB + (imm * 8), 8];
Syntaxlw $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

  • $rA is a reserved register
  • $rB + (imm * 8) + 8 overflows
  • $rB + (imm * 8) + 8 > VM_MAX_RAM

MCL: Memory clear

DescriptionClear bytes in memory.
OperationMEM[$rA, $rB] = 0;
Syntaxmcl $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

  • $rA + $rB overflows
  • $rA + $rB > VM_MAX_RAM
  • $rB > MEM_MAX_ACCESS_SIZE
  • The memory range MEM[$rA, $rB] does not pass ownership check

MCLI: Memory clear immediate

DescriptionClear bytes in memory.
OperationMEM[$rA, imm] = 0;
Syntaxmcli $rA, imm
Encoding0x00 rA i i i
Notes

Panic if:

  • $rA + imm overflows
  • $rA + imm > VM_MAX_RAM
  • imm > MEM_MAX_ACCESS_SIZE
  • The memory range MEM[$rA, imm] does not pass ownership check

MCP: Memory copy

DescriptionCopy bytes in memory.
OperationMEM[$rA, $rC] = MEM[$rB, $rC];
Syntaxmcp $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $rA + $rC overflows
  • $rB + $rC overflows
  • $rA + $rC > VM_MAX_RAM
  • $rB + $rC > VM_MAX_RAM
  • $rC > MEM_MAX_ACCESS_SIZE
  • The memory ranges MEM[$rA, $rC] and MEM[$rB, $rC] overlap
  • The memory range MEM[$rA, $rC] does not pass ownership check

MCPI: Memory copy immediate

DescriptionCopy bytes in memory.
OperationMEM[$rA, imm] = MEM[$rB, imm];
Syntaxmcpi $rA, $rB, imm
Encoding0x00 rA rB imm imm
Notes

Panic if:

  • $rA + imm overflows
  • $rB + imm overflows
  • $rA + imm > VM_MAX_RAM
  • $rB + imm > VM_MAX_RAM
  • imm > MEM_MAX_ACCESS_SIZE
  • The memory ranges MEM[$rA, imm] and MEM[$rB, imm] overlap
  • The memory range MEM[$rA, imm] does not pass ownership check

MEQ: Memory equality

DescriptionCompare bytes in memory.
Operation$rA = MEM[$rB, $rD] == MEM[$rC, $rD];
Syntaxmeq $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
Notes

Panic if:

  • $rA is a reserved register
  • $rB + $rD overflows
  • $rC + $rD overflows
  • $rB + $rD > VM_MAX_RAM
  • $rC + $rD > VM_MAX_RAM
  • $rD > MEM_MAX_ACCESS_SIZE

SB: Store byte

DescriptionThe least significant byte of $rB is stored at the address $rA offset by imm.
OperationMEM[$rA + imm, 1] = $rB[7, 1];
Syntaxsb $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

  • $rA + imm + 1 overflows
  • $rA + imm + 1 > VM_MAX_RAM
  • The memory range MEM[$rA + imm, 1] does not pass ownership check

SW: Store word

DescriptionThe value of $rB is stored at the address $rA offset by imm.
OperationMEM[$rA + (imm * 8), 8] = $rB;
Syntaxsw $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Panic if:

  • $rA + (imm * 8) + 8 overflows
  • $rA + (imm * 8) + 8 > VM_MAX_RAM
  • The memory range MEM[$rA + (imm * 8), 8] does not pass ownership check

Contract Instructions

All these instructions advance the program counter $pc by 4 after performing their operation, except for CALL, RETD and RVRT.

BAL: Balance of contract ID

DescriptionSet $rA to the balance of asset ID at $rB for contract with ID at $rC.
Operation$rA = balance(MEM[$rB, 32], MEM[$rC, 32]);
Syntaxbal $rA, $rB, $rC
Encoding0x00 rA rB rC -
EffectsBalance tree read
Notes

Where helper balance(asset_id: byte[32], contract_id: byte[32]) -> uint64 returns the current balance of asset_id of contract with ID contract_id.

Panic if:

  • $rA is a reserved register
  • $rB + 32 overflows
  • $rB + 32 > VM_MAX_RAM
  • $rC + 32 overflows
  • $rC + 32 > VM_MAX_RAM
  • Contract with ID MEM[$rC, 32] is not in tx.inputs

BHEI: Block height

DescriptionGet Fuel block height.
Operation$rA = blockheight();
Syntaxbhei $rA
Encoding0x00 rA - - -
Notes

Panic if:

BHSH: Block hash

DescriptionGet block header hash.
OperationMEM[$rA, 32] = blockhash($rB);
Syntaxbhsh $rA $rB
Encoding0x00 rA rB - -
Notes

Panic if:

  • $rA + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • The memory range MEM[$rA, 32] does not pass ownership check

Block header hashes for blocks with height greater than or equal to current block height are zero (0x00**32).

BURN: Burn existing coins

DescriptionBurn $rA coins of the current contract's asset ID.
Operationburn($rA);
Syntaxburn $rA
Encoding0x00 rA - - -
Notes

Panic if:

  • Balance of asset ID MEM[$fp, 32] of output with contract ID MEM[$fp, 32] minus $rA underflows
  • $fp == 0 (in the script context)

For output with contract ID MEM[$fp, 32], decrease balance of asset ID MEM[$fp, 32] by $rA.

This modifies the balanceRoot field of the appropriate output.

CALL: Call contract

DescriptionCall contract.
Operation
Syntaxcall $rA $rB $rC $rD
Encoding0x00 rA rB rC rD
EffectsExternal call
Notes

Given helper balanceOfStart(asset_id: byte[32]) -> uint32 which returns the memory address of the remaining free balance of asset_id, or panics if asset_id has no free balance remaining.

Panic if:

  • $rA + 32 overflows
  • $rC + 32 overflows
  • Contract with ID MEM[$rA, 32] is not in tx.inputs
  • Reading past MEM[VM_MAX_RAM - 1]
  • In an external context, if $rB > MEM[balanceOfStart(MEM[$rC, 32]), 8]
  • In an internal context, if $rB is greater than the balance of asset ID MEM[$rC, 32] of output with contract ID MEM[$fp, 32]

Register $rA is a memory address from which the following fields are set (word-aligned):

bytestypevaluedescription
32byte[32]toContract ID to call.
8byte[8]param1First parameter.
8byte[8]param2Second parameter.

$rB is the amount of coins to forward. $rC points to the 32-byte asset ID of the coins to forward. $rD is the amount of gas to forward. If it is set to an amount greater than the available gas, all available gas is forwarded.

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Call
frombyte[32]Contract ID of current context if in an internal context, zero otherwise.
tobyte[32]Contract ID of called contract.
amountuint64Amount of coins to forward, i.e. $rB.
asset_idbyte[32]Asset ID of coins to forward, i.e. MEM[$rC, 32].
gasuint64Gas to forward, i.e. $rD.
param1uint64First parameter.
param2uint64Second parameter.
pcuint64Value of register $pc.
isuint64Value of register $is.

For output with contract ID MEM[$rA, 32], increase balance of asset ID MEM[$rC, 32] by $rB. In an external context, decrease MEM[balanceOfStart(MEM[$rC, 32]), 8] by $rB. In an internal context, decrease asset ID MEM[$rC, 32] balance of output with contract ID MEM[$fp, 32] by $rB.

A call frame is pushed at $sp. In addition to filling in the values of the call frame, the following registers are set:

  1. $fp = $sp (on top of the previous call frame is the beginning of this call frame)
  2. Set $ssp and $sp to the start of the writable stack area of the call frame.
  3. Set $pc and $is to the starting address of the code.
  4. $bal = $rB (forward coins)
  5. $cgas = $rD or all available gas (forward gas)

This modifies the balanceRoot field of the appropriate output(s).

CB: Block proposer address

DescriptionGet block proposer address.
OperationMEM[$rA, 32] = coinbase();
Syntaxcb $rA
Encoding0x00 rA - - -
Notes

Panic if:

  • $rA + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • The memory range MEM[$rA, 32] does not pass ownership check

CCP: Code copy

DescriptionCopy $rD bytes of code starting at $rC for contract with ID equal to the 32 bytes in memory starting at $rB into memory starting at $rA.
OperationMEM[$rA, $rD] = code($rB, $rC, $rD);
Syntaxccp $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
NotesIf $rD is greater than the code size, zero bytes are filled in.

This is used only for reading and inspecting code of other contracts. Use LDC to load code for executing.

Panic if:

  • $rA + $rD overflows
  • $rB + 32 overflows
  • $rA + $rD > VM_MAX_RAM
  • $rB + 32 > VM_MAX_RAM
  • The memory range MEM[$rA, $rD] does not pass ownership check
  • $rD > MEM_MAX_ACCESS_SIZE
  • Contract with ID MEM[$rB, 32] is not in tx.inputs

CROO: Code Merkle root

DescriptionSet the 32 bytes in memory starting at $rA to the code root for contract with ID equal to the 32 bytes in memory starting at $rB.
OperationMEM[$rA, 32] = coderoot(MEM[$rB, 32]);
Syntaxcroo $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

  • $rA + 32 overflows
  • $rB + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • $rB + 32 > VM_MAX_RAM
  • The memory range MEM[$rA, 32] does not pass ownership check
  • Contract with ID MEM[$rB, 32] is not in tx.inputs

Code root computation is defined here.

CSIZ: Code size

DescriptionSet $rA to the size of the code for contract with ID equal to the 32 bytes in memory starting at $rB.
Operation$rA = codesize(MEM[$rB, 32]);
Syntaxcsiz $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

  • $rA is a reserved register
  • $rB + 32 overflows
  • $rB + 32 > VM_MAX_RAM
  • Contract with ID MEM[$rB, 32] is not in tx.inputs

LDC: Load code from an external contract

DescriptionCopy $rC bytes of code starting at $rB for contract with ID equal to the 32 bytes in memory starting at $rA into memory starting at $ssp.
OperationMEM[$ssp, $rC] = code($rA, $rB, $rC);
Syntaxldc $rA, $rB, $rC
Encoding0x00 rA rB rC -
NotesIf $rC is greater than the code size, zero bytes are filled in.

Panic if:

  • $ssp + $rC overflows
  • $rA + 32 overflows
  • $ssp + $rC > VM_MAX_RAM
  • $rA + 32 > VM_MAX_RAM
  • $ssp != $sp
  • $ssp + $rC > $hp
  • $rC > CONTRACT_MAX_SIZE
  • $rC > MEM_MAX_ACCESS_SIZE
  • Contract with ID MEM[$rA, 32] is not in tx.inputs

Increment $fp->codesize, $ssp, and $sp by $rC padded to word alignment.

This instruction can be used to concatenate the code of multiple contracts together. It can only be used when the stack area of the call frame is unused (i.e. prior to being used).

LOG: Log event

DescriptionLog an event. This is a no-op.
Operationlog($rA, $rB, $rC, $rD);
Syntaxlog $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
Notes

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Log
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
val0uint64Value of register $rA.
val1uint64Value of register $rB.
val2uint64Value of register $rC.
val3uint64Value of register $rD.
pcuint64Value of register $pc.
isuint64Value of register $is.

LOGD: Log data event

DescriptionLog an event. This is a no-op.
Operationlogd($rA, $rB, $rC, $rD);
Syntaxlogd $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
Notes

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.LogData
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
val0uint64Value of register $rA.
val1uint64Value of register $rB.
ptruint64Value of register $rC.
lenuint64Value of register $rD.
digestbyte[32]Hash of MEM[$rC, $rD].
pcuint64Value of register $pc.
isuint64Value of register $is.

Logs the memory range MEM[$rC, $rD].

MINT: Mint new coins

DescriptionMint $rA coins of the current contract's asset ID.
Operationmint($rA);
Syntaxmint $rA
Encoding0x00 rA - - -
Notes

Panic if:

  • Balance of asset ID MEM[$fp, 32] of output with contract ID MEM[$fp, 32] plus $rA overflows
  • $fp == 0 (in the script context)

For output with contract ID MEM[$fp, 32], increase balance of asset ID MEM[$fp, 32] by $rA.

This modifies the balanceRoot field of the appropriate output.

RETD: Return from context with data

DescriptionReturns from context with value MEM[$rA, $rB].
Operationreturndata($rA, $rB);
Syntaxretd $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

  • $rA + $rB overflows
  • $rA + $rB > VM_MAX_RAM
  • $rB > MEM_MAX_ACCESS_SIZE

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.ReturnData
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
ptruint64Value of register $rA.
lenuint64Value of register $rB.
digestbyte[32]Hash of MEM[$rA, $rB].
pcuint64Value of register $pc.
isuint64Value of register $is.

If current context is a script, append an additional receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.ScriptResult
resultuint640
gas_useduint64Gas consumed by the script.

If current context is external, cease VM execution and return MEM[$rA, $rB].

Returns from contract call, popping the call frame. Before popping, perform the following operations.

Return the unused forwarded gas to the caller:

  1. $cgas = $cgas + $fp->$cgas (add remaining context gas from previous context to current remaining context gas)

Set the return value:

  1. $ret = $rA
  2. $retl = $rB

Then pop the call frame and restoring registers except $ggas, $cgas, $ret, and $retl. Afterwards, set the following registers:

  1. $pc = $pc + 4 (advance program counter from where we called)

RVRT: Revert

DescriptionHalt execution, reverting state changes and returning value in $rA.
Operationrevert($rA);
Syntaxrvrt $rA
Encoding0x00 rA - - -
Notes

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Revert
idbyte[32]Contract ID of current context if in an internal context, zero otherwise.
valuint64Value of register $rA.
pcuint64Value of register $pc.
isuint64Value of register $is.

Then append an additional receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.ScriptResult
resultuint641
gas_useduint64Gas consumed by the script.

Cease VM execution and revert script effects. After a revert:

  1. All OutputContract outputs will have the same balanceRoot and stateRoot as on initialization.
  2. All OutputVariable outputs will have to, amount, and asset_id of zero.

SMO: Send message to output

DescriptionSend a message to recipient address MEM[$rA, 32] with call abi MEM[$rA + 32, $rB] and $rD coins, with output $rC.
Operationoutputmessage(MEM[$fp, 32], MEM[$rA, 32], MEM[$rA + 32, $rB], $rD, $rC);
Syntaxsmo $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
EffectsOutput message
Notes

Given helper balanceOfStart(asset_id: byte[32]) -> uint32 which returns the memory address of the remaining free balance of asset_id, or panics if asset_id has no free balance remaining.

Panic if:

  • $rA + $rB + 32 overflows
  • $rA + $rB + 32 > VM_MAX_RAM
  • $rB > MEM_MAX_ACCESS_SIZE
  • $rB > MESSAGE_MAX_DATA_SIZE
  • $rC > tx.outputsCount
  • In an external context, if $rD > MEM[balanceOfStart(0), 8]
  • In an internal context, if $rD is greater than the balance of asset ID 0 of output with contract ID MEM[$fp, 32]
  • tx.outputs[$rC].type != OutputType.Message
  • tx.outputs[$rC].recipient != 0
  • MEM[$rA, 32] == 0

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.MessageOut
messageIDbyte[32]The messageID as described here.
senderbyte[32]The address of the message sender: MEM[$fp, 32].
recipientbyte[32]The address of the message recipient: MEM[$rA, 32].
amountuint64Amount of base asset coins sent with message: $rD.
noncebyte[32]The message nonce as described here.
lenuint16Length of message data, in bytes: $rB.
digestbyte[32]Hash of MEM[$rA + 32, $rB].

In an external context, decrease MEM[balanceOfStart(0), 8] by $rD. In an internal context, decrease asset ID 0 balance of output with contract ID MEM[$fp, 32] by $rD. Then set:

  • tx.outputs[$rC].recipient = MEM[$rA, 32]
  • tx.outputs[$rC].amount = $rD

This modifies the balanceRoot field of the appropriate output. messageID is added to the OutputMessage Merkle tree as part of block header. TODO: document output messages Merkle tree construction and maintenance and link here

SCWQ: State clear sequential 32 byte slots

DescriptionA sequential series of 32 bytes is cleared from the current contract's state.
OperationSTATE[MEM[$rA, 32], 32 * $rC] = None;
Syntaxscwq $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $rA + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • $rB is a reserved register
  • $fp == 0 (in the script context)

Register $rB will be set to false if any storage slot in the requested range was already unset (default) and true if all the slots were set.

SRW: State read word

DescriptionA word is read from the current contract's state.
Operation$rA = STATE[MEM[$rC, 32]][0, 8];
Syntaxsrw $rA, $rB, $rC
Encoding0x00 rA rB rC -
EffectsStorage read
NotesReturns zero if the state element does not exist.

Panic if:

Register $rB will be set to false if any storage slot in the requested range is unset (default) and true if all the slots were set.

SRWQ: State read sequential 32 byte slots

DescriptionA sequential series of 32 bytes is read from the current contract's state.
OperationMEM[$rA, 32 * rD] = STATE[MEM[$rC, 32], 32 * rD];
Syntaxsrwq $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
EffectsStorage read
NotesReturns zero if the state element does not exist.

Panic if:

  • $rA + 32 * rD overflows
  • $rA + 32 * rD > VM_MAX_RAM
  • $rB is a reserved register
  • $rC + 32 * rD overflows
  • $rC + 32 * rD > VM_MAX_RAM
  • The memory range MEM[$rA, 32 * rD] does not pass ownership check
  • $fp == 0 (in the script context)

Register $rB will be set to false if any storage slot in the requested range is unset (default) and true if all the slots were set.

SWW: State write word

DescriptionA word is written to the current contract's state.
OperationSTATE[MEM[$rA, 32]][0, 8] = $rC;
STATE[MEM[$rA, 32]][8, 24] = 0;
Syntaxsww $rA $rB $rC
Encoding0x00 rA rB rC -
EffectsStorage write
Notes

Panic if:

  • $rA + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • $rB is a reserved register
  • $fp == 0 (in the script context)

The last 24 bytes of STATE[MEM[$rA, 32]] are set to 0. Register $rB will be set to false if the storage slot was previously unset (default) and true if the slot was set.

SWWQ: State write sequential 32 byte slots

DescriptionA sequential series of 32 bytes is written to the current contract's state.
OperationSTATE[MEM[$rA, 32], 32 * $rD] = MEM[$rC, 32 * $rD];
Syntaxswwq $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
EffectsStorage write
Notes

Panic if:

  • $rA + 32 overflows
  • $rB is a reserved register
  • $rC + 32 * $rD overflows
  • $rA + 32 > VM_MAX_RAM
  • $rC + 32 * $rD > VM_MAX_RAM
  • $fp == 0 (in the script context)

Register $rB will be set to false if the first storage slot was previously unset (default) and true if the slot was set.

TIME: Timestamp at height

DescriptionGet timestamp of block at given height.
Operation$rA = time($rB);
Syntaxtime $rA, $rB
Encoding0x00 rA rB - -
Notes

Panic if:

Gets the timestamp of the block at height $rB. Time is in TAI64 format.

TR: Transfer coins to contract

DescriptionTransfer $rB coins with asset ID at $rC to contract with ID at $rA.
Operationtransfer(MEM[$rA, 32], $rB, MEM[$rC, 32]);
Syntaxtr $rA, $rB, $rC
Encoding0x00 rA rB rC -
EffectsBalance tree read, balance tree write
Notes

Given helper balanceOfStart(asset_id: byte[32]) -> uint32 which returns the memory address of the remaining free balance of asset_id, or panics if asset_id has no free balance remaining.

Panic if:

  • $rA + 32 overflows
  • $rC + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • $rC + 32 > VM_MAX_RAM
  • Contract with ID MEM[$rA, 32] is not in tx.inputs
  • In an external context, if $rB > MEM[balanceOfStart(MEM[$rC, 32]), 8]
  • In an internal context, if $rB is greater than the balance of asset ID MEM[$rC, 32] of output with contract ID MEM[$fp, 32]
  • $rB == 0

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.Transfer
frombyte[32]Contract ID of current context if in an internal context, zero otherwise.
tobyte[32]Contract ID of contract to transfer coins to.
amountuint64Amount of coins transferred.
asset_idbyte[32]asset ID of coins transferred.
pcuint64Value of register $pc.
isuint64Value of register $is.

For output with contract ID MEM[$rA, 32], increase balance of asset ID MEM[$rC, 32] by $rB. In an external context, decrease MEM[balanceOfStart(MEM[$rC, 32]), 8] by $rB. In an internal context, decrease asset ID MEM[$rC, 32] balance of output with contract ID MEM[$fp, 32] by $rB.

This modifies the balanceRoot field of the appropriate output(s).

TRO: Transfer coins to output

DescriptionTransfer $rC coins with asset ID at $rD to address at $rA, with output $rB.
Operationtransferout(MEM[$rA, 32], $rB, $rC, MEM[$rD, 32]);
Syntaxtro $rA, $rB, $rC, $rD
Encoding0x00 rA rB rC rD
EffectsBalance tree read, balance tree write
Notes

Given helper balanceOfStart(asset_id: byte[32]) -> uint32 which returns the memory address of the remaining free balance of asset_id, or panics if asset_id has no free balance remaining.

Panic if:

  • $rA + 32 overflows
  • $rD + 32 overflows
  • $rA + 32 > VM_MAX_RAM
  • $rD + 32 > VM_MAX_RAM
  • $rB > tx.outputsCount
  • In an external context, if $rC > MEM[balanceOfStart(MEM[$rD, 32]), 8]
  • In an internal context, if $rC is greater than the balance of asset ID MEM[$rD, 32] of output with contract ID MEM[$fp, 32]
  • $rC == 0
  • tx.outputs[$rB].type != OutputType.Variable
  • tx.outputs[$rB].amount != 0

Append a receipt to the list of receipts, modifying tx.receiptsRoot:

nametypedescription
typeReceiptTypeReceiptType.TransferOut
frombyte[32]Contract ID of current context if in an internal context, zero otherwise.
tobyte[32]Address to transfer coins to.
amountuint64Amount of coins transferred.
asset_idbyte[32]asset ID of coins transferred.
pcuint64Value of register $pc.
isuint64Value of register $is.

In an external context, decrease MEM[balanceOfStart(MEM[$rD, 32]), 8] by $rC. In an internal context, decrease asset ID MEM[$rD, 32] balance of output with contract ID MEM[$fp, 32] by $rC. Then set:

  • tx.outputs[$rB].to = MEM[$rA, 32]
  • tx.outputs[$rB].amount = $rC
  • tx.outputs[$rB].asset_id = MEM[$rD, 32]

This modifies the balanceRoot field of the appropriate output(s).

Cryptographic Instructions

All these instructions advance the program counter $pc by 4 after performing their operation.

ECR: Signature recovery

DescriptionThe 64-byte public key (x, y) recovered from 64-byte signature starting at $rB on 32-byte message hash starting at $rC.
OperationMEM[$rA, 64] = ecrecover(MEM[$rB, 64], MEM[$rC, 32]);
Syntaxecr $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $rA + 64 overflows
  • $rB + 64 overflows
  • $rC + 32 overflows
  • $rA + 64 > VM_MAX_RAM
  • $rB + 64 > VM_MAX_RAM
  • $rC + 32 > VM_MAX_RAM
  • The memory range MEM[$rA, 64] does not pass ownership check

Signatures and signature verification are specified here.

If the signature cannot be verified, MEM[$rA, 64] is set to 0 and $err is set to 1, otherwise $err is cleared.

To get the address from the public key, hash the public key with SHA-2-256.

K256: keccak-256

DescriptionThe keccak-256 hash of $rC bytes starting at $rB.
OperationMEM[$rA, 32] = keccak256(MEM[$rB, $rC]);
Syntaxk256 $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $rA + 32 overflows
  • $rB + $rC overflows
  • $rA + 32 > VM_MAX_RAM
  • $rB + $rC > VM_MAX_RAM
  • The memory range MEM[$rA, 32] does not pass ownership check
  • $rC > MEM_MAX_ACCESS_SIZE

S256: SHA-2-256

DescriptionThe SHA-2-256 hash of $rC bytes starting at $rB.
OperationMEM[$rA, 32] = sha256(MEM[$rB, $rC]);
Syntaxs256 $rA, $rB, $rC
Encoding0x00 rA rB rC -
Notes

Panic if:

  • $rA + 32 overflows
  • $rB + $rC overflows
  • $rA + 32 > VM_MAX_RAM
  • $rB + $rC > VM_MAX_RAM
  • The memory range MEM[$rA, 32] does not pass ownership check
  • $rC > MEM_MAX_ACCESS_SIZE

Other Instructions

All these instructions advance the program counter $pc by 4 after performing their operation.

FLAG: Set flags

DescriptionSet $flag to $rA.
Operation$flag = $rA;
Syntaxflag $rA
Encoding0x00 rA - - -
Notes

GM: Get metadata

DescriptionGet metadata from memory.
OperationVaries (see below).
Syntaxgm $rA, imm
Encoding0x00 rA imm imm imm
Notes

Read metadata from memory. A convenience instruction to avoid manually extracting metadata.

namevaluedescription
GM_IS_CALLER_EXTERNAL0x00001Get if caller is external.
GM_GET_CALLER0x00002Get caller's contract ID.
GM_GET_VERIFYING_PREDICATE0x00003Get index of current predicate.

If imm == GM_IS_CALLER_EXTERNAL:

Panic if:

  • $fp == 0 (in an external context)

Set $rA to true if parent is an external context, false otherwise.

If imm == GM_GET_CALLER:

Panic if:

  • $fp == 0 (in an external context)
  • $fp->$fp == 0 (if parent context is external)

Set $rA to $fp->$fp (i.e. $rA will point to the previous call frame's contract ID).

If imm == GM_GET_VERIFYING_PREDICATE:

Panic if:

  • not in a predicate context

Set $rA to the index of the currently-verifying predicate.

GTF: Get transaction fields

DescriptionGet transaction fields.
OperationVaries (see below).
Syntaxgtf $rA, $rB, imm
Encoding0x00 rA rB i i
Notes

Get fields from the transaction.

nameimmset $rA to
GTF_TYPE0x001tx.type
GTF_SCRIPT_GAS_PRICE0x002tx.gasPrice
GTF_SCRIPT_GAS_LIMIT0x003tx.gasLimit
GTF_SCRIPT_MATURITY0x004tx.maturity
GTF_SCRIPT_SCRIPT_LENGTH0x005tx.scriptLength
GTF_SCRIPT_SCRIPT_DATA_LENGTH0x006tx.scriptDataLength
GTF_SCRIPT_INPUTS_COUNT0x007tx.inputsCount
GTF_SCRIPT_OUTPUTS_COUNT0x008tx.outputsCount
GTF_SCRIPT_WITNESSES_COUNT0x009tx.witnessesCount
GTF_SCRIPT_RECEIPTS_ROOT0x00AMemory address of tx.receiptsRoot
GTF_SCRIPT_SCRIPT0x00BMemory address of tx.script
GTF_SCRIPT_SCRIPT_DATA0x00CMemory address of tx.scriptData
GTF_SCRIPT_INPUT_AT_INDEX0x00DMemory address of tx.inputs[$rB]
GTF_SCRIPT_OUTPUT_AT_INDEX0x00EMemory address of t.outputs[$rB]
GTF_SCRIPT_WITNESS_AT_INDEX0x00FMemory address of tx.witnesses[$rB]
GTF_CREATE_GAS_PRICE0x010tx.gasPrice
GTF_CREATE_GAS_LIMIT0x011tx.gasLimit
GTF_CREATE_MATURITY0x012tx.maturity
GTF_CREATE_BYTECODE_LENGTH0x013tx.bytecodeLength
GTF_CREATE_BYTECODE_WITNESS_INDEX0x014tx.bytecodeWitnessIndex
GTF_CREATE_STORAGE_SLOTS_COUNT0x015tx.storageSlotsCount
GTF_CREATE_INPUTS_COUNT0x016tx.inputsCount
GTF_CREATE_OUTPUTS_COUNT0x017tx.outputsCount
GTF_CREATE_WITNESSES_COUNT0x018tx.witnessesCount
GTF_CREATE_SALT0x019Memory address of tx.salt
GTF_CREATE_STORAGE_SLOT_AT_INDEX0x01AMemory address of tx.storageSlots[$rB]
GTF_CREATE_INPUT_AT_INDEX0x01BMemory address of tx.inputs[$rB]
GTF_CREATE_OUTPUT_AT_INDEX0x01CMemory address of t.outputs[$rB]
GTF_CREATE_WITNESS_AT_INDEX0x01DMemory address of tx.witnesses[$rB]
GTF_INPUT_TYPE0x101tx.inputs[$rB].type
GTF_INPUT_COIN_TX_ID0x102Memory address of tx.inputs[$rB].txID
GTF_INPUT_COIN_OUTPUT_INDEX0x103tx.inputs[$rB].outputIndex
GTF_INPUT_COIN_OWNER0x104Memory address of tx.inputs[$rB].owner
GTF_INPUT_COIN_AMOUNT0x105tx.inputs[$rB].amount
GTF_INPUT_COIN_ASSET_ID0x106Memory address of tx.inputs[$rB].asset_id
GTF_INPUT_COIN_TX_POINTER0x107Memory address of tx.inputs[$rB].txPointer
GTF_INPUT_COIN_WITNESS_INDEX0x108tx.inputs[$rB].witnessIndex
GTF_INPUT_COIN_MATURITY0x109tx.inputs[$rB].maturity
GTF_INPUT_COIN_PREDICATE_LENGTH0x10Atx.inputs[$rB].predicateLength
GTF_INPUT_COIN_PREDICATE_DATA_LENGTH0x10Btx.inputs[$rB].predicateDataLength
GTF_INPUT_COIN_PREDICATE0x10CMemory address of tx.inputs[$rB].predicate
GTF_INPUT_COIN_PREDICATE_DATA0x10DMemory address of tx.inputs[$rB].predicateData
GTF_INPUT_CONTRACT_TX_ID0x10EMemory address of tx.inputs[$rB].txID
GTF_INPUT_CONTRACT_OUTPUT_INDEX0x10Ftx.inputs[$rB].outputIndex
GTF_INPUT_CONTRACT_BALANCE_ROOT0x110Memory address of tx.inputs[$rB].balanceRoot
GTF_INPUT_CONTRACT_STATE_ROOT0x111Memory address of tx.inputs[$rB].stateRoot
GTF_INPUT_CONTRACT_TX_POINTER0x112Memory address of tx.inputs[$rB].txPointer
GTF_INPUT_CONTRACT_CONTRACT_ID0x113Memory address of tx.inputs[$rB].contractID
GTF_INPUT_MESSAGE_MESSAGE_ID0x114Memory address of tx.inputs[$rB].messageID
GTF_INPUT_MESSAGE_SENDER0x115Memory address of tx.inputs[$rB].sender
GTF_INPUT_MESSAGE_RECIPIENT0x116Memory address of tx.inputs[$rB].recipient
GTF_INPUT_MESSAGE_AMOUNT0x117tx.inputs[$rB].amount
GTF_INPUT_MESSAGE_NONCE0x118tx.inputs[$rB].nonce
GTF_INPUT_MESSAGE_WITNESS_INDEX0x119tx.inputs[$rB].witnessIndex
GTF_INPUT_MESSAGE_DATA_LENGTH0x11Atx.inputs[$rB].dataLength
GTF_INPUT_MESSAGE_PREDICATE_LENGTH0x11Btx.inputs[$rB].predicateLength
GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH0x11Ctx.inputs[$rB].predicateDataLength
GTF_INPUT_MESSAGE_DATA0x11DMemory address of tx.inputs[$rB].data
GTF_INPUT_MESSAGE_PREDICATE0x11EMemory address of tx.inputs[$rB].predicate
GTF_INPUT_MESSAGE_PREDICATE_DATA0x11FMemory address of tx.inputs[$rB].predicateData
GTF_OUTPUT_TYPE0x201tx.outputs[$rB].type
GTF_OUTPUT_COIN_TO0x202Memory address of tx.outputs[$rB].to
GTF_OUTPUT_COIN_AMOUNT0x203tx.outputs[$rB].amount
GTF_OUTPUT_COIN_ASSET_ID0x204Memory address of tx.outputs[$rB].asset_id
GTF_OUTPUT_CONTRACT_INPUT_INDEX0x205tx.outputs[$rB].inputIndex
GTF_OUTPUT_CONTRACT_BALANCE_ROOT0x206Memory address of tx.outputs[$rB].balanceRoot
GTF_OUTPUT_CONTRACT_STATE_ROOT0x207Memory address of tx.outputs[$rB].stateRoot
GTF_OUTPUT_MESSAGE_RECIPIENT0x208Memory address of tx.outputs[$rB].recipient
GTF_OUTPUT_MESSAGE_AMOUNT0x209tx.outputs[$rB].amount
GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID0x20AMemory address of tx.outputs[$rB].contractID
GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT0x20BMemory address of tx.outputs[$rB].stateRoot
GTF_WITNESS_DATA_LENGTH0x301tx.witnesses[$rB].dataLength
GTF_WITNESS_DATA0x302Memory address of tx.witnesses[$rB].data

Panic if:

  • $rA is a reserved register
  • imm is not one of the values listed above
  • The value of $rB results in an out of bounds access for variable-length fields
  • The input or output type does not match (OutputChange and OutputVariable count as OutputCoin)

For fixed-length fields, the value of $rB is ignored.