Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Blockhash

Library for accessing historical block hashes beyond the standard 256 block limit. Uses EIP-2935's history storage contract which maintains a ring buffer of the last 8191 block hashes in state. For blocks within the last 256 blocks, it uses the native BLOCKHASH opcode. For blocks between 257 and 8191 blocks ago, it queries the EIP-2935 history storage. For blocks older than 8191 or future blocks, it returns zero, matching the BLOCKHASH behavior. NOTE: After EIP-2935 activation, it takes 8191 blocks to completely fill the history. Before that, only block hashes since the fork block will be available.

State Variables

HISTORY_STORAGE_ADDRESS

Address of the EIP-2935 history storage contract.

address internal constant HISTORY_STORAGE_ADDRESS = 0x0000F90827F1C53a10cb7A02335B175320002935;

Functions

blockHash

Retrieves the block hash for any historical block within the supported range. NOTE: The function gracefully handles future blocks and blocks beyond the history window by returning zero, consistent with the EVM's native BLOCKHASH behavior.

function blockHash(uint256 blockNumber) internal view returns (bytes32);

_historyStorageCall

Internal function to query the EIP-2935 history storage contract.

function _historyStorageCall(uint256 blockNumber) private view returns (bytes32 hash);