Skip to main content

Try it Live

Run Opcode examples in the interactive playground

Validation

Methods for validating opcodes and checking opcode categories.

Opcode Validity

Opcode.isValid(opcode)

Check if byte value is a valid EVM opcode.
Parameters:
  • opcode: number - Byte value to check (0x00-0xFF)
Returns: boolean - True if valid EVM opcode Use cases:
  • Validate bytecode before execution
  • Filter out undefined opcodes during disassembly
  • Detect malformed or invalid bytecode
Defined in: primitives/Opcode/BrandedOpcode/isValid.js

Opcode.isValidOpcode(opcode)

Alias for isValid().
Parameters:
  • opcode: number - Byte value
Returns: boolean - True if valid opcode

Jump Validation

Opcode.isValidJumpDest(bytecode, offset)

Check if offset is a valid JUMPDEST in bytecode.
Parameters:
  • bytecode: Uint8Array - Contract bytecode
  • offset: number - Program counter offset to check
Returns: boolean - True if offset is valid JUMPDEST Validation rules:
  • Offset must be within bytecode bounds
  • Byte at offset must be JUMPDEST (0x5B)
  • Offset must not be inside PUSH immediate data
Defined in: primitives/Opcode/BrandedOpcode/isValidJumpDest.js

Opcode.isJumpDestination(opcode)

Check if opcode is JUMPDEST (0x5B).
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if JUMPDEST Defined in: primitives/Opcode/BrandedOpcode/isJumpDestination.js

Category Checks

Opcode.isPush(opcode)

Check if opcode is PUSH0-PUSH32.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if PUSH0-PUSH32 (0x5F-0x7F) Defined in: primitives/Opcode/BrandedOpcode/isPush.js

Opcode.isDup(opcode)

Check if opcode is DUP1-DUP16.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if DUP1-DUP16 (0x80-0x8F) Defined in: primitives/Opcode/BrandedOpcode/isDup.js

Opcode.isSwap(opcode)

Check if opcode is SWAP1-SWAP16.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if SWAP1-SWAP16 (0x90-0x9F) Defined in: primitives/Opcode/BrandedOpcode/isSwap.js

Opcode.isLog(opcode)

Check if opcode is LOG0-LOG4.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if LOG0-LOG4 (0xA0-0xA4) Defined in: primitives/Opcode/BrandedOpcode/isLog.js

Opcode.isJump(opcode)

Check if opcode is JUMP or JUMPI.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if JUMP (0x56) or JUMPI (0x57) Defined in: primitives/Opcode/BrandedOpcode/isJump.js

Opcode.isTerminating(opcode)

Check if opcode terminates execution.
Parameters:
  • opcode: BrandedOpcode - Opcode to check
Returns: boolean - True if STOP, RETURN, REVERT, INVALID, or SELFDESTRUCT Terminating opcodes:
  • STOP (0x00) - Halts execution
  • RETURN (0xF3) - Returns from call
  • REVERT (0xFD) - Reverts state changes
  • INVALID (0xFE) - Invalid opcode trap
  • SELFDESTRUCT (0xFF) - Destroys contract
Defined in: primitives/Opcode/BrandedOpcode/isTerminating.js

Opcode.isTerminator(opcode)

Alias for isTerminating().

Validation Patterns

Validate Bytecode

Check Jump Safety

Categorize Instructions

Find Invalid Opcodes

Validate PUSH Consistency

Check for Unreachable Code

See Also