OP Code Reference

OP Code Reference

This reference outlines the integer representations of each virtual machine OP code and the methods available through the public APIs (for both Typescript and Solidity).

OP_DEBUG

Used for debugging. Outputs the machine state to the console. Available only in JavaScript.

IntJSSolidity
255debug(label: string)N/A

OP_TARGET

  • Pops the top item off the stack and uses it as the target for the following operations.
  • Resets the slot position to 0.
IntJSSolidity
1target()target()

OP_SET_OUTPUT

  • Pops the top value from the stack and sets it as an output at the specified index.
IntJSSolidity
2setOutput(i: number)setOutput(uint8 i)

OP_EVAL_LOOP

Evaluates an expression or operation.

IntJSSolidity
3evalLoop(opts: {success?: boolean; failure?: boolean; acquire?: boolean; back?: number; } = {})evalLoop(uint8 flags) / eval(uint8 flags, uint8 back)

OP_EVAL_INLINE

IntJSSolidity
4eval()eval()

OP_REQ_NONZERO

  • Ensures the value at a specific offset (back from the top of the stack) is non-zero.
  • Defaults to the value at the stack's top. If zero, it sets an exit code and returns.
IntJSSolidity
10requireNonzero(back = 0)requireNonzero(uint8 back)

OP_REQ_CONTRACT

  • Checks if the current target is a contract address. If zero, sets an exit code and returns.
IntJSSolidity
11requireContract()requireContract()

OP_READ_SLOTS

  • Reads n slots from the current target starting from the current slot defined in the machine.
IntJSSolidity
20read(n = 1)read() / read(uint8 n)

OP_READ_BYTES

  • Reads a bytes value from the storage of the current target.
IntJSSolidity
21readBytes()readBytes()

OP_READ_ARRAY

  • Reads array values from the storage of the current target.
IntJSSolidity
22readArray(step: number)readArray(uint8 step)

OP_SLOT_ZERO

  • Resets the machine slot to 0.
IntJSSolidity
30zeroSlot()zeroSlot()

OP_SLOT_ADD

  • Increments the slot in the virtual machine by the value at the top of the stack.
IntJSSolidity
31addSlot()addSlot()

OP_SLOT_FOLLOW

  • Generates and updates the machine slot ID for a mapping or array using the value at the stack's top as the key/index.
IntJSSolidity
32follow()follow()

OP_PUSH_INPUT

  • Pushes a value from the input register onto the stack. Various helper methods exist for different types.
IntJSSolidity
40pushInput(i: number) / pushStr(s: string) / pushBytes(v: BytesLike) / push(x: BigNumberish)push(uint256 x) / push(address x) / push(bytes32 x) / push(string memory s) / push(bytes memory v) / push(GatewayRequest memory x)

OP_PUSH_OUTPUT

  • Pushes an output at index i onto the stack.
IntJSSolidity
41pushOutput(i: number)pushOutput(uint8 i)

OP_PUSH_SLOT

  • Pushes the current virtual machine slot onto the stack.
IntJSSolidity
42pushSlot()readSlot()

OP_PUSH_TARGET

  • Pushes the current virtual machine target address onto the stack.
IntJSSolidity
43pushTarget()readTarget()

OP_DUP

  • Pushes the stack item offset from the head by back to the top of the stack.
IntJSSolidity
50dup(back = 0)dup(uint8 back)

OP_POP

  • Removes the top stack item.
IntJSSolidity
51pop()pop()

OP_SWAP

  • Swaps the item at the top of the stack with the item at the specified offset from the head.
IntJSSolidity
52swap(back = 1)``

OP_KECCAK

  • Computes the Keccak-256 hash of the item at the head of the stack and replaces it on the stack.
IntJSSolidity
60keccak()keccak()

OP_CONCAT

  • Pops and concatenates the last back items on the stack.
IntJSSolidity
61concat(back: number)concat(uint8 n)

OP_SLICE

  • Slices n bytes from the value at the head of the stack starting from offset x.
IntJSSolidity
62slice(x: number, n: number)slice(uint16 pos, uint16 len)