Skip to main content

Try it Live

Run Opcode examples in the interactive playground

Opcode.disassemble()

Disassemble bytecode into array of formatted assembly strings.

Parameters

  • bytecode: Uint8Array - Raw bytecode to disassemble

Returns

string[] - Array of formatted instruction strings Each line format: "<offset>: <mnemonic> [immediate]"

Output Format

  • Offset: 4-digit hex with leading zeros (e.g., 0000, 002A)
  • Mnemonic: Opcode name (e.g., PUSH1, ADD, SSTORE)
  • Immediate: Hex value for PUSH operations (e.g., 0x80, 0x0102)

Use Cases

Annotated Disassembly with Gas

Side-by-Side Comparison

Find Pattern Locations

Export to File

Highlight Instructions

Performance

  • O(n) time where n is number of instructions
  • String allocation for each instruction line
  • Single pass through parsed instructions
  • Uses parse() internally, so includes parsing overhead