Skip to main content

Try it Live

Run Bytecode examples in the interactive playground

    BasicBlock Type

    TerminatorType

    Options

    Basic Block Properties

    Entry Points

    Blocks start at:
    1. Program start (PC 0) - Entry block
    2. JUMPDEST - Valid jump destination
    3. After terminator - Instruction following STOP/RETURN/REVERT/etc.

    Exit Points

    Blocks end at:
    1. Terminator - STOP, RETURN, REVERT, INVALID, SELFDESTRUCT
    2. JUMP - Unconditional jump
    3. JUMPI - Conditional jump
    4. Before JUMPDEST - Next block entry

    Maximal Property

    Blocks are maximal sequences: cannot be extended without violating single entry/exit.

    Usage Patterns

    Basic Block Listing

    Control Flow Graph

    Reachability Analysis

    Gas Analysis by Block

    Stack Analysis by Block

    Extract Block Instructions

    Control Flow Patterns

    Linear Flow

    Conditional Branch

    Loop Detection

    Function Dispatch Pattern

    Integration with Other APIs

    Combined with prettyPrint

    Combined with analyzeGas

    Combined with analyzeStack

    Combined with scan

    Advanced Patterns

    Dominator Analysis

    Topological Sort

    Hot Path Identification

    Validation

    Blocks automatically validated when validate: true (default):
    Validation errors throw BytecodeError:

    Performance

    Memory

    • Small bytecode (<1KB): ~1KB metadata
    • Medium bytecode (10KB): ~10KB metadata
    • Large bytecode (24KB): ~25KB metadata
    Metadata size roughly equals bytecode size (O(n)).

    Computation

    • Small bytecode (<1KB): <1ms
    • Medium bytecode (10KB): ~5ms
    • Large bytecode (24KB): ~15ms
    CFG construction adds ~20% overhead.
    Reuse block analysis results. Blocks don’t change unless bytecode changes.

    Optimization

    Common Use Cases

    Compiler Optimization

    Security Analysis

    Debugging

    Limitations

    Block analysis is based on static control flow and cannot account for:
    • Dynamic jump targets - JUMP destination from stack unknown
    • External calls - Called contract code unknown
    • CREATE operations - Deployed code unknown
    • DELEGATECALL - Execution context changes
    Results represent possible control flow, not guaranteed runtime behavior.

    What’s Included

    ✅ Entry/exit points (JUMPDEST, terminators) ✅ Static jumps (PUSH+JUMP detected) ✅ Conditional branches (JUMPI) ✅ Fallthrough edges ✅ Reachability from entry

    What’s Not Included

    ❌ Dynamic jump target resolution ❌ External call effects ❌ Loop iteration counts ❌ Runtime path probabilities

    See Also