evm_disassemble

Decodes bytecode with evmone advanced static analysis fixed to the Osaka revision. It exposes 27 instruction, PUSH, block, stack, gas, storage, and call-hint columns without executing the code.

Example

Local

1
SELECT
2
pc,
3
mnemonic,
4
opcode,
5
CASE WHEN push_value IS NULL THEN NULL ELSE concat('0x', lower(hex(push_value))) END AS push_value,
6
push_length,
7
push_truncated,
8
instruction_size,
9
gas_cost
10
FROM evm_disassemble('0x5f1e63aabb'::BYTES)
11
ORDER BY pc;
12
-- => [{"pc":0,"mnemonic":"PUSH0","opcode":95,"push_value":"0x0000000000000000000000000000000000000000000000000000000000000000","push_length":0,"push_truncated":"false","instruction_size":1,"gas_cost":2},{"pc":1,"mnemonic":"CLZ","opcode":30,"push_value":null,"push_length":null,"push_truncated":null,"instruction_size":1,"gas_cost":5},{"pc":2,"mnemonic":"PUSH4","opcode":99,"push_value":"0x000000000000000000000000000000000000000000000000000000000000aabb","push_length":4,"push_truncated":"true","instruction_size":3,"gas_cost":3}]
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

evm_disassemble(BYTES) #

Disassembles BYTES using Osaka meanings and gas tables; no EVM-revision argument is available.

Inputs

Name Type Use
bytecode BYTES

Bytecode to decode as BYTES. Use deployed runtime bytecode, such as `compile(...).bin_runtime` or `code_at(...)`, when inspecting contract behavior; deployment init code is valid but represents the constructor path.

required positional

Result columns

NameType
pcINTEGER

Zero-based byte offset of the decoded opcode

labelVARCHAR

Static jump-destination label, otherwise NULL

mnemonicVARCHAR

Osaka instruction name, or UNKNOWN for an undefined opcode

opcodeUTINYINT

Raw opcode byte value (0x00-0xFF)

push_valueBYTES32

Right-aligned, zero-padded PUSH value; PUSH0 is zero; NULL for non-PUSH

Showing fewer

Instruction-level bytecode table. Returns one row per decoded instruction at a zero-based byte-offset PC. NULL bytecode errors and empty bytecode returns zero rows. Analysis is fixed to Osaka with no revision argument; earlier-fork bytecode can therefore receive Osaka opcode meanings and gas tables.

Guidance

PUSH decoding

PUSH0 has declared width zero and value zero. PUSH1 through PUSH32 report their declared width even when fewer immediate bytes remain; `instruction_size` reports bytes actually present.

  • `push_value` right-aligns available immediate bytes and zero-pads to BYTES32.
  • `push_truncated` marks a missing immediate suffix.
  • PUSH-only fields are NULL on other instructions.

Static-analysis interpretation

Block IDs and boundaries, entry/max stack, instruction stack depth, and `analysis_instr_index` come from evmone advanced analysis. Reachability is static CFG analysis and can be conservative or incomplete around dynamic jumps.

  • `gas_cost` is static base opcode gas and `block_gas_cost` is evmone block metadata; neither includes memory expansion, warm/cold access, refunds, or execution-path gas.
  • Storage classifications are heuristics: constant, array, mapping, or computed.
  • Constant call targets appear only when statically recovered.
  • `call_type_metadata` is VARCHAR containing JSON. `has_value = false` can mean zero, unknown, or a call type without a value operand.

Boundary

This table is not a decompiler, formal verifier, symbolic executor, or security finding engine.

  • Full function, dominance, loop, memory, and data-flow analysis remains internal.

Related functions

Category and tags

Tag
EVM