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:Behavior
NUMBER pushes the current block number onto the stack as a 256-bit unsigned integer: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 gasTIMESTAMP,COINBASE,GASLIMIT: 2 gasBLOCKHASH: 20 gasSLOAD(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
- TypeScript
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
- 2 gas per query
- ~500,000 queries per million gas
Related Instructions
- BLOCKHASH (0x40) - Get hash of recent block
- TIMESTAMP (0x42) - Get block timestamp
- DIFFICULTY (0x44) - Get difficulty/PREVRANDAO
References
- Yellow Paper - Section 9.3 (Block Information)
- EVM Codes - NUMBER
- Solidity Docs - block.number
- Ethereum Block Explorer

