Overview
GasConstants provides comprehensive EVM gas cost constants and calculation functions according to the Ethereum Yellow Paper and various EIPs. Use this module to accurately compute gas costs for opcodes, storage operations, transactions, precompiles, and memory expansion.
Basic Opcode Costs
Step-based gas costs for EVM opcodes:| Constant | Gas | Opcodes |
|---|---|---|
QuickStep | 2 | ADDRESS, ORIGIN, CALLER, CALLVALUE, CALLDATASIZE, CODESIZE, GASPRICE, RETURNDATASIZE, PC, MSIZE, GAS, CHAINID, SELFBALANCE |
FastestStep | 3 | ADD, SUB, NOT, LT, GT, SLT, SGT, EQ, ISZERO, AND, OR, XOR, CALLDATALOAD, MLOAD, MSTORE, MSTORE8, PUSH, DUP, SWAP |
FastStep | 5 | MUL, DIV, SDIV, MOD, SMOD |
MidStep | 8 | ADDMOD, MULMOD, SIGNEXTEND |
SlowStep | 10 | JUMPI |
ExtStep | 20 | BALANCE, EXTCODESIZE, BLOCKHASH |
Hashing Operations
Storage Operations (EIP-2929, EIP-2200, EIP-3529)
Storage operations have different costs based on access patterns:| Constant | Gas | Description |
|---|---|---|
Sload | 100 | Warm SLOAD |
ColdSload | 2100 | Cold SLOAD (EIP-2929) |
ColdAccountAccess | 2600 | Cold account access (BALANCE, EXTCODESIZE, CALL family) |
WarmStorageRead | 100 | Warm storage read |
SstoreSentry | 2300 | Minimum gas for SSTORE |
SstoreSet | 20000 | SSTORE zero to non-zero |
SstoreReset | 5000 | SSTORE modify existing non-zero |
SstoreClear | 5000 | SSTORE clear to zero |
SstoreRefund | 4800 | Gas refund for clearing storage (EIP-3529) |
Memory Expansion
Memory costs grow quadratically with size:Transaction Costs
Contract Creation and Calls
Logging Operations
Copy Operations
EIP-4844: Blob Transactions
EIP-1153: Transient Storage
Refund Calculation
Hardfork Utilities
Check EIP activation status:Precompile Gas Costs
ThePrecompile namespace contains all precompile gas constants and calculation functions:
ECRECOVER, SHA256, RIPEMD160, IDENTITY
MODEXP (EIP-2565)
BN254 (alt_bn128) - Hardfork-dependent
BLAKE2F
Point Evaluation (EIP-4844)
BLS12-381 (EIP-2537 - Prague)
Complete Gas Constants Reference
All Constants
All Constants
Basic Operations
| Constant | Value | Description |
|---|---|---|
QuickStep | 2 | Very cheap operations |
FastestStep | 3 | Simple arithmetic |
FastStep | 5 | Multiplication/division |
MidStep | 8 | Advanced arithmetic |
SlowStep | 10 | Conditional jumps |
ExtStep | 20 | External account access |
Jumpdest | 1 | JUMPDEST marker |
Hashing
| Constant | Value | Description |
|---|---|---|
Keccak256Base | 30 | Base KECCAK256 cost |
Keccak256Word | 6 | Per 32-byte word |
Storage
| Constant | Value | Description |
|---|---|---|
Sload | 100 | Warm SLOAD |
ColdSload | 2100 | Cold SLOAD (EIP-2929) |
ColdAccountAccess | 2600 | Cold account access |
WarmStorageRead | 100 | Warm storage read |
SstoreSentry | 2300 | Minimum SSTORE gas |
SstoreSet | 20000 | Zero to non-zero |
SstoreReset | 5000 | Modify non-zero |
SstoreClear | 5000 | Clear to zero |
SstoreRefund | 4800 | Clear refund (EIP-3529) |
Logging
| Constant | Value | Description |
|---|---|---|
LogBase | 375 | Base LOG cost |
LogData | 8 | Per byte of data |
LogTopic | 375 | Per topic |
Calls and Creates
| Constant | Value | Description |
|---|---|---|
Create | 32000 | Base CREATE cost |
CreateData | 200 | Per byte deployed |
InitcodeWord | 2 | Per initcode word (EIP-3860) |
MaxInitcodeSize | 49152 | Max initcode (EIP-3860) |
Call | 40 | Base CALL cost |
CallStipend | 2300 | Value transfer stipend |
CallValueTransfer | 9000 | Value transfer cost |
CallNewAccount | 25000 | New account cost |
CallCode | 700 | CALLCODE (EIP-150) |
DelegateCall | 700 | DELEGATECALL (EIP-150) |
StaticCall | 700 | STATICCALL (EIP-214) |
Selfdestruct | 5000 | SELFDESTRUCT base |
SelfdestructRefund | 24000 | Removed in EIP-3529 |
CallGasRetentionDivisor | 64 | 63/64 rule |
Memory
| Constant | Value | Description |
|---|---|---|
Memory | 3 | Linear coefficient |
QuadCoeffDiv | 512 | Quadratic divisor |
Transactions
| Constant | Value | Description |
|---|---|---|
Tx | 21000 | Base transaction |
TxContractCreation | 53000 | Contract creation |
TxDataZero | 4 | Per zero byte |
TxDataNonZero | 16 | Per non-zero byte |
Copy | 3 | Per copy word |
MaxRefundQuotient | 5 | Max refund 1/5 |
EIP-4844 Blobs
| Constant | Value | Description |
|---|---|---|
BlobHash | 3 | BLOBHASH opcode |
BlobBaseFee | 2 | BLOBBASEFEE opcode |
EIP-1153 Transient Storage
| Constant | Value | Description |
|---|---|---|
TLoad | 100 | TLOAD cost |
TStore | 100 | TSTORE cost |
Related
- Hardfork - Ethereum hardfork identifiers
- Transaction - Transaction encoding/decoding
- Opcode - EVM opcode definitions

