Overview
Opcode:0x45
Introduced: Frontier (EVM genesis)
GASLIMIT retrieves the maximum amount of gas that can be consumed by all transactions in the current block. This limit is dynamically adjusted by validators/miners based on network demand and consensus rules.
Specification
Stack Input:Behavior
GASLIMIT pushes the block gas limit onto the stack as a 256-bit unsigned integer:Examples
Basic Usage
Gas Capacity Checks
Gas Usage Estimation
Gas Cost
Cost: 2 gas (GasQuickStep) GASLIMIT is one of the cheapest EVM operations. Comparison:GASLIMIT: 2 gasNUMBER,TIMESTAMP,COINBASE: 2 gasGAS(0x5A): 2 gasGASPRICE(0x3A): 2 gas
Common Usage
Gas-Aware Operations
Dynamic Batch Sizing
Gas Target Validation
Network Congestion Detection
Transaction Splitting Logic
Security Considerations
Gas Limit Manipulation
Validators can gradually adjust gas limit (±1/1024 per block):DoS via Gas Limit Assumptions
Don’t assume gas limit won’t change:Block Gas Limit vs Transaction Gas Limit
EIP-1559 Considerations
Post-London (EIP-1559), gas limit still applies:Implementation
- TypeScript
Edge Cases
Minimum Gas Limit
Maximum Gas Limit
Historical Gas Limits
Stack Overflow
Historical Evolution
Gas Limit Increases
Adjustment Rules
Practical Patterns
Safe Batch Processing
Gas Limit Monitoring
Benchmarks
Performance:- Stack push: O(1)
- No computation required
- 2 gas per query
- ~500,000 queries per million gas
Related Instructions
- GAS (0x5A) - Get remaining transaction gas
- GASPRICE (0x3A) - Get gas price
- BASEFEE (0x48) - Get base fee (EIP-1559)
References
- Yellow Paper - Section 9.3 (Block Information)
- EVM Codes - GASLIMIT
- EIP-1559 - Fee market change
- Solidity Docs - block.gaslimit

