GasCosts
Constants for gas costs of EVM operations, based on Yellow Paper Appendix G and various EIPs.Constants
Transaction Costs
Storage Operations
Account Access (EIP-2929)
Logging
Calldata
Memory & Copying
Cryptographic Operations
Other Operations
Opcode Cost Tiers
Block Limits
Transaction Type Costs
Usage Examples
Calculate Calldata Cost
Calculate LOG Cost
Estimate Transaction Base Cost
Compare Storage Operations
EIP Changes
EIP-2929 (Berlin)
Cold vs warm access distinction:EIP-3529 (London)
Refund reduction:EIP-1559 (London)
Changed fee structure but not gas costs:Cost Categories
Cheap Operations (≤ 10 gas)
- Stack operations: PUSH, POP, DUP, SWAP
- Arithmetic: ADD, SUB, MUL, DIV
- Logic: AND, OR, XOR, NOT
- Comparison: LT, GT, EQ
Medium Operations (10-100 gas)
- SHA3/KECCAK256: 30 + 6 per word
- BLOCKHASH: 20
- Message calls (base): 100
Expensive Operations (100-2600 gas)
- SLOAD (warm): 100
- SLOAD (cold): 2100
- Account access (cold): 2600
Very Expensive Operations (5000-20000 gas)
- SSTORE (reset): 5000
- SELFDESTRUCT: 5000
- SSTORE (set): 20000
Transaction Base Costs (≥ 21000 gas)
- Simple transfer: 21000
- Contract creation: 32000+
- Complex interactions: 50000-1000000+
Memory Costs
Memory expansion is quadratic:See Also
- GasUsed - Actual gas consumed
- GasEstimate - Estimate gas before execution
- GasRefund - Gas refunds after execution
- Yellow Paper Appendix G - Fee schedule
- EIP-2929 - Gas cost increases
- EIP-3529 - Refund reduction

