Try it Live
Run Bytecode examples in the interactive playground
GasAnalysis Type
InstructionGas
BlockGas
ExpensiveInstruction
ExecutionPath
Options
Usage Patterns
Basic Gas Estimation
Instruction-Level Breakdown
Block-Level Analysis
Identify Expensive Operations
Path Analysis
Dynamic Gas Estimation
EIP-3860 Initcode Gas
Calculate initcode gas (2 gas per 32-byte word):Gas Cost Categories
Instructions grouped by gas cost category:Base Cost (3 gas)
- Stack: PUSH, DUP, SWAP, POP
- Arithmetic: ADD, SUB, MUL
- Comparison: LT, GT, EQ
- Bitwise: AND, OR, XOR, NOT
Memory Expansion (3+ gas)
- MLOAD, MSTORE, MSTORE8: 3 gas + expansion cost
- Expansion:
3 * new_words + (new_words)² ÷ 512
Storage (2100/20000 gas)
- SLOAD: 100 gas (warm) / 2100 gas (cold)
- SSTORE: 100/2900/20000 gas (depends on change)
Calls (700+ gas)
- CALL, DELEGATECALL, STATICCALL: 700 base + value transfer + memory expansion
- CREATE, CREATE2: 32000 gas + deployment gas
Hashing
- KECCAK256: 30 gas + 6 gas per word
- SHA256, RIPEMD160: 60 gas + 12 gas per word (precompiles)
Expensive Operations
- EXP: 10 gas + 50 gas per byte of exponent
- SELFDESTRUCT: 5000 gas + refund
Limitations
What’s Included
✅ Base opcode costs (ADD, MUL, PUSH, etc.) ✅ JUMPDEST costs (1 gas each) ✅ Block-level aggregation ✅ Sequential execution path ✅ Multiple path exploration (withanalyzePaths)
What’s Estimated
⚠️ Memory expansion (requires runtime sizes) ⚠️ Storage access (warm/cold requires context) ⚠️ Call stipend and value transfer ⚠️ CREATE deployment gasWhat’s Not Included
❌ Actual loop iteration counts ❌ External contract execution costs ❌ Precompile gas (except fixed-cost ones) ❌ Gas refunds (SELFDESTRUCT, SSTORE)Optimization Hints
Identify gas optimization opportunities:Integration with Opcode Module
Gas costs come from Opcode.getGasCost():See Also
- analyzeStack - Stack depth validation
- analyzeBlocks - Basic block analysis
- Opcode.getGasCost - Individual opcode costs
- prettyPrint - Disassembly with gas annotations

