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: 0x43
Introduced: Frontier (EVM genesis)
NUMBER retrieves the current block number - the sequential index of the block in the blockchain. Block numbers start at 0 (genesis) and increment by 1 for each new block.
Specification
Stack Input:
Stack Output:
Gas Cost: 2 (GasQuickStep)
Operation:
Behavior
NUMBER pushes the current block number onto the stack as a 256-bit unsigned integer:
The block number is deterministic and strictly increasing, making it reliable for sequencing and versioning.
Examples
Basic Usage
Block Range Checks
Block Calculations
Gas Cost
Cost: 2 gas (GasQuickStep)
NUMBER is one of the cheapest EVM operations.
Comparison:
NUMBER: 2 gas
TIMESTAMP, COINBASE, GASLIMIT: 2 gas
BLOCKHASH: 20 gas
SLOAD (cold): 2100 gas
Common Usage
Block-Based Scheduling
Phased Rollout
Block-Based Rewards
Version Control
Block Number Checkpoint
Security Considerations
Not Suitable for Randomness
Block numbers are predictable and should never be used for randomness:
Block Reorganizations
Block numbers can temporarily decrease during chain reorgs:
Future Block Conditions
Never check for exact future blocks:
Block Time Variability
Block production time varies by network and consensus:
Block Number Overflow
Theoretical but not practical concern (would take millions of years):
Implementation
Edge Cases
Genesis Block
Large Block Number
Maximum u256 Block
Stack Overflow
Out of Gas
Practical Patterns
Safe Block Range Checks
Block-Based Epochs
Hardfork Detection
Historical Milestones
Benchmarks
Performance:
- Stack push: O(1)
- No computation required
Gas efficiency:
- 2 gas per query
- ~500,000 queries per million gas
References