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
Block context instructions provide access to blockchain environment data within smart contract execution. These opcodes allow contracts to query information about the current block, historical blocks, and chain configuration.
Opcode Range: 0x40 - 0x4A (11 opcodes)
Instructions
Chain and Account Context
EIP-4844 Blob Context
Historical Evolution
Frontier (Genesis)
BLOCKHASH, COINBASE, TIMESTAMP, NUMBER, DIFFICULTY, GASLIMIT
- Original block context operations for basic blockchain awareness
Istanbul (EIP-1344, EIP-1884)
CHAINID - Enable replay protection across different chains
SELFBALANCE - More efficient balance queries for current contract
Paris (The Merge)
DIFFICULTY repurposed as PREVRANDAO for post-merge randomness
Cancun (EIP-4844)
BLOBHASH, BLOBBASEFEE - Support for proto-danksharding blob transactions
Common Patterns
Timestamp-Based Logic
Block-Based Randomness (Legacy)
Chain-Specific Behavior
Historical Block Queries
Gas Costs Summary
Security Considerations
Timestamp Manipulation
Block timestamps can be manipulated by miners within bounds (±15 seconds typically):
Blockhash Limitations
BLOCKHASH only returns hashes for the most recent 256 blocks:
PREVRANDAO Considerations
Post-merge, DIFFICULTY returns PREVRANDAO - beacon chain randomness:
- More unpredictable than PoW difficulty
- Still not suitable for high-stakes randomness
- Use Chainlink VRF for critical applications
Chain ID Replay Protection
Always include block.chainid in transaction hashing for cross-chain protection:
Implementation Notes
TypeScript Usage
References