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.
opcode: number- Byte value to check (0x00-0xFF)
boolean - True if valid EVM opcode
Use cases:
- Validate bytecode before execution
- Filter out undefined opcodes during disassembly
- Detect malformed or invalid bytecode
Opcode.isValidOpcode(opcode)
Alias for isValid().
opcode: number- Byte value
boolean - True if valid opcode
Jump Validation
Opcode.isValidJumpDest(bytecode, offset)
Check if offset is a valid JUMPDEST in bytecode.
bytecode: Uint8Array- Contract bytecodeoffset: number- Program counter offset to check
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
Opcode.isJumpDestination(opcode)
Check if opcode is JUMPDEST (0x5B).
opcode: BrandedOpcode- Opcode to check
boolean - True if JUMPDEST
Defined in: primitives/Opcode/BrandedOpcode/isJumpDestination.js
Category Checks
Opcode.isPush(opcode)
Check if opcode is PUSH0-PUSH32.
opcode: BrandedOpcode- Opcode to check
boolean - True if PUSH0-PUSH32 (0x5F-0x7F)
Defined in: primitives/Opcode/BrandedOpcode/isPush.js
Opcode.isDup(opcode)
Check if opcode is DUP1-DUP16.
opcode: BrandedOpcode- Opcode to check
boolean - True if DUP1-DUP16 (0x80-0x8F)
Defined in: primitives/Opcode/BrandedOpcode/isDup.js
Opcode.isSwap(opcode)
Check if opcode is SWAP1-SWAP16.
opcode: BrandedOpcode- Opcode to check
boolean - True if SWAP1-SWAP16 (0x90-0x9F)
Defined in: primitives/Opcode/BrandedOpcode/isSwap.js
Opcode.isLog(opcode)
Check if opcode is LOG0-LOG4.
opcode: BrandedOpcode- Opcode to check
boolean - True if LOG0-LOG4 (0xA0-0xA4)
Defined in: primitives/Opcode/BrandedOpcode/isLog.js
Opcode.isJump(opcode)
Check if opcode is JUMP or JUMPI.
opcode: BrandedOpcode- Opcode to check
boolean - True if JUMP (0x56) or JUMPI (0x57)
Defined in: primitives/Opcode/BrandedOpcode/isJump.js
Opcode.isTerminating(opcode)
Check if opcode terminates execution.
opcode: BrandedOpcode- Opcode to check
boolean - True if STOP, RETURN, REVERT, INVALID, or SELFDESTRUCT
Terminating opcodes:
STOP(0x00) - Halts executionRETURN(0xF3) - Returns from callREVERT(0xFD) - Reverts state changesINVALID(0xFE) - Invalid opcode trapSELFDESTRUCT(0xFF) - Destroys contract
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
- Constructors - Parsing bytecode
- Utilities - Opcode metadata
- Usage Patterns - Bytecode analysis

