Skip to content

Opcode Support ​

Back to Runtime Specification

The embedded runtime implements the opcode subset documented below. Opcodes not handled by the runtime are rejected with an Unsupported opcode execution error.

Constants ​

OpcodeHexGasDescription
PUSHINT80x001Push 1-byte signed integer
PUSHINT160x011Push 2-byte signed integer
PUSHINT320x021Push 4-byte signed integer
PUSHINT640x031Push 8-byte signed integer
PUSHINT1280x041Push 16-byte signed integer
PUSHINT2560x051Push 32-byte signed integer
PUSHT0x081Push true
PUSHF0x091Push false
PUSHA0x0A1Push address (pointer)
PUSHNULL0x0B1Push null
PUSHDATA10x0C2Push data (1-byte length prefix)
PUSHDATA20x0D2Push data (2-byte length prefix)
PUSHDATA40x0E2Push data (4-byte length prefix)
PUSHM10x0F1Push -1
PUSH0-PUSH160x10-0x201Push small integers 0 through 16

Flow Control ​

OpcodeHexGasDescription
NOP0x211No operation
JMP / JMP_L0x22 / 0x232Unconditional jump (short/long offset)
JMPIF / JMPIF_L0x24 / 0x252Jump if top is true
JMPIFNOT / JMPIFNOT_L0x26 / 0x272Jump if top is false
JMPEQ / JMPEQ_L0x28 / 0x292Jump if top two are equal
JMPNE / JMPNE_L0x2A / 0x2B2Jump if top two are not equal
JMPGT / JMPGT_L0x2C / 0x2D2Jump if greater than
JMPGE / JMPGE_L0x2E / 0x2F2Jump if greater or equal
JMPLT / JMPLT_L0x30 / 0x312Jump if less than
JMPLE / JMPLE_L0x32 / 0x332Jump if less or equal
CALL / CALL_L0x34 / 0x35512Call function (short/long offset)
CALLA0x36512Call address on stack
CALLT0x37512Call method token (native contract optimization)
ABORT0x381Abort execution unconditionally
ASSERT0x391Abort if top is false
THROW0x3A1Throw exception
TRY / TRY_L0x3B / 0x3C1Begin try block (catch/finally offsets)
ENDTRY / ENDTRY_L0x3D / 0x3E1End try block
ENDFINALLY0x3F1End finally block (rethrows pending exception)
RET0x400Return from current context
SYSCALL0x4110Invoke system interop (4-byte hash follows)

Stack Operations ​

OpcodeHexGasDescription
DEPTH0x432Push stack depth
DROP0x452Remove top item
NIP0x462Remove second item
XDROP0x482Remove item at index N
CLEAR0x492Clear the stack
DUP0x4A2Duplicate top item
OVER0x4B2Copy second item to top
PICK0x4D2Copy item at index N to top
TUCK0x4E2Insert top item below second
SWAP0x502Swap top two items
ROT0x512Rotate top three items
ROLL0x522Move item at index N to top
REVERSE30x532Reverse top 3 items
REVERSE40x542Reverse top 4 items
REVERSEN0x552Reverse top N items

Splice and Buffer ​

OpcodeHexGasDescription
NEWBUFFER0x884Create new buffer of given size
MEMCPY0x894Copy bytes between buffers
CAT0x8B4Concatenate two byte arrays
SUBSTR0x8C4Extract substring
LEFT0x8D4Take left N bytes
RIGHT0x8E4Take right N bytes

Bitwise and Logic ​

OpcodeHexGasDescription
INVERT0x903Bitwise NOT
AND0x913Bitwise AND
OR0x923Bitwise OR
XOR0x933Bitwise XOR
EQUAL0x973Equality comparison
NOTEQUAL0x983Inequality comparison

Numeric ​

OpcodeHexGasDescription
SIGN0x993Push sign (-1, 0, 1)
ABS0x9A3Absolute value
NEGATE0x9B3Negate
INC / DEC0x9C / 0x9D3Increment / decrement
ADD / SUB0x9E / 0x9F3Addition / subtraction
MUL / DIV / MOD0xA0 / 0xA1 / 0xA25Multiplication / division / modulo
POW0xA38Exponentiation
SQRT0xA46Integer square root
MODMUL / MODPOW0xA5 / 0xA68Modular multiply / modular power
SHL / SHR0xA8 / 0xA93Shift left / shift right
NOT0xAA2Logical NOT
BOOLAND / BOOLOR0xAB / 0xAC2Logical AND / OR
NZ0xB12Non-zero test
NUMEQUAL / NUMNOTEQUAL0xB3 / 0xB43Numeric equality
LT / LE / GT / GE0xB5-0xB83Comparison operators
MIN / MAX0xB9 / 0xBA3Minimum / maximum
WITHIN0xBB3Range check (a <= x < b)

Compound and Collections ​

OpcodeHexGasDescription
PACKMAP0xBE4Pack key-value pairs into map
PACKSTRUCT0xBF4Pack items into struct
PACK / UNPACK0xC0 / 0xC14Pack/unpack array
NEWARRAY0 / NEWARRAY / NEWARRAY_T0xC2 / 0xC3 / 0xC44Create arrays
NEWSTRUCT0 / NEWSTRUCT0xC5 / 0xC64Create structs
NEWMAP0xC84Create empty map
SIZE0xCA4Get collection/string size
HASKEY0xCB4Check if key exists
KEYS / VALUES0xCC / 0xCD4Get map keys / values
PICKITEM0xCE4Get item by index/key
APPEND0xCF4Append to array
SETITEM0xD04Set item by index/key
REVERSEITEMS0xD14Reverse collection in place
REMOVE0xD24Remove item by index/key
CLEARITEMS0xD34Clear all items
POPITEM0xD44Pop last item from array

Type Operations ​

OpcodeHexGasDescription
ISNULL0xD82Check if top is null
ISTYPE0xD92Check if top matches type code
CONVERT0xDB2Convert top to specified type

Supported type codes:

CodeType
0x20Boolean
0x21Integer
0x28ByteString
0x30Buffer
0x40Array
0x41Struct
0x48Map
0x60InteropInterface

Extensions ​

OpcodeHexGasDescription
ABORTMSG0xE01Abort with message
ASSERTMSG0xE11Assert with message

MIT Licensed