Try it Live
Run Bytecode examples in the interactive playground
Type Definition
BrandedUint8Array with utils for analyzing, validating, and iterating over EVM bytecode.
Native Uint8Array Methods
JavaScript builtins available on allUint8Array instances:
setFromBase64()- Populate from base64 stringsetFromHex()- Populate from hex stringtoBase64()- Encode to base64 stringtoHex()- Encode to hex string
toHex() and setFromHex() are available as of 2025 (Node.js 22+, Chrome 131+). Use Tevm’s Hex.toHex() for broader compatibility.Quick Reference
Effect Schema
API Methods
Constructors
from(value)- Universal constructor from any inputfromHex(hex)- Parse hex string (with or without 0x prefix)fromUint8Array(bytes)- Create from Uint8Array
Iteration
scan(bytecode, options?)- Iterator for lazy bytecode traversal with fusion detection
Analysis
analyze(bytecode)- Complete analysis (validation + jump destinations + instructions)analyzeBlocks(bytecode, options?)- Split into basic blocks with control flow metadataanalyzeGas(bytecode, options?)- Estimate gas costs with instruction/block breakdownanalyzeStack(bytecode, options?)- Validate stack depth constraints and track effectsanalyzeJumpDestinations(bytecode)- Find all JUMPDEST positionsparseInstructions(bytecode)- Parse all instructions with PUSH dataisValidJumpDest(bytecode, offset)- Check if position is valid jump targetdetectFusions(bytecode)- Identify multi-instruction optimization patterns
Validation
validate(bytecode)- Validate bytecode structure
Metadata
hasMetadata(bytecode)- Check for compiler metadatastripMetadata(bytecode)- Remove metadata from bytecode
Formatting
formatInstructions(bytecode)- Disassemble to string arrayprettyPrint(bytecode, options?)- Annotated disassembly with colors and metadata
Conversions
toHex(bytecode)- Convert to hex string with 0x prefixtoAbi(bytecode)- Extract ABI from bytecode using reverse engineering
Utilities
size(bytecode)- Get byte lengthequals(a, b)- Compare bytecode equalityhash(bytecode)- Compute keccak256 hashextractRuntime(bytecode)- Extract runtime code from deployment bytecodegetBlock(bytecode, pc)- Get basic block containing a program countergetNextPc(bytecode, currentPc)- Get next program counter after instruction
Reference
- Instruction Types - Complete OpcodeData union reference (40+ types)
- Synthetic Opcodes - Extended opcode set for fusion patterns
Types
- BrandedBytecode
- BytecodeLike
- Analysis Types
Uint8Array, TypeScript enforces type safety with symbol branding.Usage Patterns
Analyzing Contract Bytecode
Comparing Bytecode
Extracting Runtime Code
Tree-Shaking
Import only what you need for optimal bundle size:Related
Core Documentation
- Fundamentals - Learn bytecode structure and parsing
- Instruction Types - Complete OpcodeData union reference
Advanced Features
- Pretty Print - Annotated disassembly with visualization
- Analyze Blocks - Basic block analysis and CFG
- Detect Fusions - Multi-instruction pattern detection
- Synthetic Opcodes - Extended opcode set
Related Primitives
- Opcode - EVM instruction definitions and gas costs
- Keccak256 - Keccak256 hashing for bytecode verification
- Hex - Hex string encoding and decoding
Specification
- Ethereum Yellow Paper - Formal EVM specification
- EVM Opcodes - Interactive opcode reference
- wolflo/evm-opcodes - Gas costs and opcode details
- Solidity Metadata - Contract metadata format

