---
eip: 7709
label: EIP-7709
title: Read BLOCKHASH from Storage and Update Cost
status: Draft
type: Standards Track
category: Core
created: 2024-05-18
requires: 2935
official: https://eips.ethereum.org/EIPS/eip-7709
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7709.md
canonical: https://eips.huatuo.xyz/eip-7709/
lang: en
tldr: "Makes the BLOCKHASH opcode read recent block hashes from the EIP-2935 history contract's storage and charge normal SLOAD gas for it, so it stops being a special case for stateless clients."
tags: [evm, opcode, blockhash, gas, statelessness, core]
---

# EIP-7709: Read BLOCKHASH from Storage and Update Cost

> Read the `BLOCKHASH (0x40)` opcode from the EIP-2935 system contract storage and adjust its gas cost to reflect storage access.

**TL;DR:** Makes the BLOCKHASH opcode read recent block hashes from the EIP-2935 history contract's storage and charge normal SLOAD gas for it, so it stops being a special case for stateless clients.

## What problem does it solve?

`BLOCKHASH` returns the hash of one of the last 256 blocks. To answer it, a client must keep recent block history outside of the state. That makes it a special case: it reads chain history, yet it is not priced or recorded like other state reads. For stateless clients, which need a witness of every piece of data a block touches, that is awkward.

[EIP-2935](/eip-2935/) already stores recent block hashes in a system contract's storage. EIP-7709 makes `BLOCKHASH` treat those hashes as ordinary storage reads.

## How it works

- **The return value does not change.** Requests for the current block, a future block, or one more than 256 blocks back (`BLOCKHASH_SERVE_WINDOW`) still return `0`.
- For an in-window block number `arg`, the result is defined as storage slot `arg % 8191` (`HISTORY_SERVE_WINDOW`) of the EIP-2935 contract at `0x0000F90827F1C53a10cb7A02335B175320002935`.
- **Gas:** on top of the usual `BLOCKHASH` base cost, the opcode now charges the full `SLOAD` effects of that slot under the active fork: cold or warm cost (as in [EIP-2929](/eip-2929/)), slot warming, and any state-access recording the fork needs.
- Clients may get the value however they like (a direct storage read, an internal call to the EIP-2935 `get` path, or their own in-memory history). Whatever method they use, they charge only the `SLOAD` effects, not the cost of running the system contract.
- EIP-2935 should have been live for at least 256 blocks before this activates (or both at genesis on a testnet), so the ring buffer is already full.

## Sample code

Resolution logic, from the spec:

```python
BLOCKHASH_SERVE_WINDOW = 256
HISTORY_SERVE_WINDOW   = 8191
HISTORY_STORAGE_ADDRESS = 0x0000F90827F1C53a10cb7A02335B175320002935

def resolve_blockhash(block, state, arg):
    if arg >= block.number or arg + BLOCKHASH_SERVE_WINDOW < block.number:
        return 0                      # no extra storage cost
    # charges cold/warm SLOAD, warms the slot, records the access
    return state.load_slot(HISTORY_STORAGE_ADDRESS, arg % HISTORY_SERVE_WINDOW)
```

Solidity code is unchanged; only its gas cost goes up:

```solidity
bytes32 h = blockhash(block.number - 1); // now also pays SLOAD (cold first time)
```

## Things to know

- Status is **Draft**; the fork timestamp is TBD.
- In-window `BLOCKHASH` calls become noticeably more expensive. The first lookup of a slot in a transaction pays the cold `SLOAD` price, later lookups the warm price. Contracts tuned to the old cost may break.
- `BLOCKHASH` still serves only 256 blocks, even though the EIP-2935 contract holds 8191. For older hashes, call the EIP-2935 contract directly and pay normal call costs.
- This fits the wider statelessness work (see [EIP-4762](/eip-4762/)), where every state access must show up in the block witness.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7709
