Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

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:
Stack Output:
Gas Cost: 2 (GasQuickStep) Operation:

Behavior

GASLIMIT pushes the block gas limit onto the stack as a 256-bit unsigned integer:
The gas limit can adjust by ±1/1024 per block, allowing gradual increases or decreases based on validator votes.

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 gas
  • NUMBER, TIMESTAMP, COINBASE: 2 gas
  • GAS (0x5A): 2 gas
  • GASPRICE (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

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
Gas efficiency:
  • 2 gas per query
  • ~500,000 queries per million gas

References