{"eip":4788,"title":"Beacon block root in the EVM","description":"Expose beacon chain roots in the EVM","authors":["Alex Stokes (@ralexstokes)","Ansgar Dietrichs (@adietrichs)","Danny Ryan (@djrtwo)","Martin Holst Swende (@holiman)","lightclient (@lightclient)"],"status":"Final","type":"Standards Track","category":"Core","created":"2022-02-10","requires":[1559],"discussionsTo":"https://ethereum-magicians.org/t/eip-4788-beacon-root-in-evm/8281","repo":"EIPs","label":"EIP-4788","officialUrl":"https://eips.ethereum.org/EIPS/eip-4788","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4788.md","url":"https://eips.huatuo.xyz/eip-4788/","tldr":{"en":"Puts the parent beacon block root into every execution block and stores recent roots in a system contract, so smart contracts can verify consensus-layer facts like validator balances with Merkle proofs.","ja":"親ビーコンブロックルートをすべての実行ブロックに含め、直近のルートをシステムコントラクトに保存することで、スマートコントラクトがバリデーター残高などのコンセンサスレイヤーの事実を Merkle 証明で検証できるようにする。","ko":"부모 비콘 블록 루트를 모든 실행 블록에 넣고 최근 루트를 시스템 컨트랙트에 저장해, 스마트 컨트랙트가 검증자 잔액 같은 합의 계층의 사실을 Merkle 증명으로 검증할 수 있게 한다.","zh":"把父信标区块根放入每个执行区块，并将近期的根存入系统合约，让智能合约可以用 Merkle 证明验证验证者余额等共识层信息。"},"tags":["beacon-chain","consensus","oracle","staking","core","dencun"],"explainers":{"en":{"lang":"en","tldr":"Puts the parent beacon block root into every execution block and stores recent roots in a system contract, so smart contracts can verify consensus-layer facts like validator balances with Merkle proofs.","tags":["beacon-chain","consensus","oracle","staking","core","dencun"],"related":[2935,1559,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4788/","markdown":"## What problem does it solve?\n\nSince the Merge, Ethereum has two layers: the execution layer (where contracts run) and the consensus layer (the beacon chain, holding validators, balances, withdrawals). Contracts could not see the consensus layer at all. Staking pools, restaking protocols and bridges that needed facts about validators had to rely on trusted oracles to relay them.\n\nA beacon block root is a cryptographic commitment to the entire consensus state. If a contract can read a trusted root, anyone can submit a Merkle proof against it and the contract can verify that proof on-chain, with no oracle.\n\n## How it works\n\n- **Header field.** Each execution block header gains `parent_beacon_block_root`, the hash tree root of the parent beacon block. The consensus client supplies it; execution clients check it.\n- **System contract.** At `BEACON_ROOTS_ADDRESS` (`0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02`) lives a tiny contract. At the start of every block, before any transaction, the client calls it from `SYSTEM_ADDRESS` (`0xfff…fffe`) with the root. That call does not count against the block gas limit.\n- **Ring buffers.** The contract keeps `HISTORY_BUFFER_LENGTH = 8191` entries in two ring buffers: one stores the block timestamp, the other the root, both at index `timestamp % 8191`. The spec notes this covers about a day of blocks at current slot times.\n- **Reading.** Anyone else calls the contract with a 32-byte big-endian timestamp. It returns the root stored for that timestamp, or reverts if the input is not 32 bytes, is zero, or the stored timestamp does not match (so stale or missing entries are never returned).\n\nThe contract was deployed with a keyless \"Nick's method\" transaction, so its address is the same on any chain that deploys it the same way. It activated on mainnet with the Dencun upgrade in March 2024.\n\n## Sample code\n\nReading the beacon root for a given block timestamp from Solidity:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract BeaconRootReader {\n    address constant BEACON_ROOTS = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;\n\n    /// Returns the parent beacon block root committed in the block with `ts`.\n    function rootAt(uint256 ts) public view returns (bytes32 root) {\n        (bool ok, bytes memory out) = BEACON_ROOTS.staticcall(abi.encode(ts));\n        require(ok, \"no root for timestamp\");\n        root = abi.decode(out, (bytes32));\n    }\n\n    function latestRoot() external view returns (bytes32) {\n        return rootAt(block.timestamp); // root of this block's parent beacon block\n    }\n}\n```\n\nA proof verifier would then check an SSZ Merkle branch (for example to a validator's balance) against the returned root.\n\n## Things to know\n\n- The returned root is that of the **parent** beacon block of the execution block with that timestamp, not of a beacon block at that time.\n- Only roughly the last day of roots is available. Proofs must be submitted before their root is overwritten.\n- Querying a timestamp with no execution block (a missed slot) reverts; callers should handle that.\n- Merkle proofs are against SSZ hash tree roots, so you need consensus-layer tooling to build them.\n- The companion [EIP-2935](/eip-2935/) uses a similar system-contract pattern to serve historical execution block hashes.\n"},"ja":{"lang":"ja","tldr":"親ビーコンブロックルートをすべての実行ブロックに含め、直近のルートをシステムコントラクトに保存することで、スマートコントラクトがバリデーター残高などのコンセンサスレイヤーの事実を Merkle 証明で検証できるようにする。","tags":["beacon-chain","consensus","oracle","staking","core","dencun"],"related":[2935,1559,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4788/","markdown":"## 何を解決するのか\n\nThe Merge 以降、Ethereum には 2 つのレイヤーがあります。コントラクトが動く実行レイヤーと、バリデーター、残高、引き出しを保持するコンセンサスレイヤー（ビーコンチェーン）です。コントラクトはコンセンサスレイヤーをまったく見ることができませんでした。バリデーターに関する事実を必要とするステーキングプール、リステーキングプロトコル、ブリッジは、それを中継する信頼されたオラクルに頼らざるを得ませんでした。\n\nビーコンブロックルートは、コンセンサス状態全体への暗号学的なコミットメントです。コントラクトが信頼できるルートを読み取れるなら、誰でもそのルートに対する Merkle 証明を提出でき、コントラクトはオラクルなしでその証明をオンチェーンで検証できます。\n\n## 仕組み\n\n- **ヘッダーフィールド。** 各実行ブロックヘッダーに `parent_beacon_block_root` が追加されます。これは親ビーコンブロックの hash tree root です。コンセンサスクライアントが値を渡し、実行クライアントが検証します。\n- **システムコントラクト。** `BEACON_ROOTS_ADDRESS`（`0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02`）に小さなコントラクトが置かれます。各ブロックの開始時、どのトランザクションよりも前に、クライアントが `SYSTEM_ADDRESS`（`0xfff…fffe`）からルートを渡してこれを呼び出します。この呼び出しはブロックのガスリミットに含まれません。\n- **リングバッファ。** コントラクトは `HISTORY_BUFFER_LENGTH = 8191` 個のエントリを 2 つのリングバッファに保持します。一方にブロックのタイムスタンプ、もう一方にルートを、どちらもインデックス `timestamp % 8191` に格納します。仕様によれば、現在のスロット時間ではおよそ 1 日分のブロックをカバーします。\n- **読み取り。** それ以外の呼び出し元は、32 バイトのビッグエンディアンのタイムスタンプを渡してコントラクトを呼びます。コントラクトはそのタイムスタンプに保存されたルートを返します。入力が 32 バイトでない場合、ゼロの場合、または保存されたタイムスタンプが一致しない場合は revert します（古いエントリや存在しないエントリが返されることはありません）。\n\nこのコントラクトはキーなしの「Nick's method」トランザクションでデプロイされたため、同じ方法でデプロイすればどのチェーンでも同じアドレスになります。2024 年 3 月の Dencun アップグレードでメインネットで有効になりました。\n\n## サンプルコード\n\nSolidity から、指定したブロックのタイムスタンプに対応するビーコンルートを読み取ります。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract BeaconRootReader {\n    address constant BEACON_ROOTS = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;\n\n    /// Returns the parent beacon block root committed in the block with `ts`.\n    function rootAt(uint256 ts) public view returns (bytes32 root) {\n        (bool ok, bytes memory out) = BEACON_ROOTS.staticcall(abi.encode(ts));\n        require(ok, \"no root for timestamp\");\n        root = abi.decode(out, (bytes32));\n    }\n\n    function latestRoot() external view returns (bytes32) {\n        return rootAt(block.timestamp); // root of this block's parent beacon block\n    }\n}\n```\n\n証明の検証コントラクトは、返されたルートに対して SSZ の Merkle ブランチ（たとえばバリデーターの残高までのもの）を検証することになります。\n\n## 知っておくべきこと\n\n- 返されるルートは、そのタイムスタンプを持つ実行ブロックの**親**ビーコンブロックのものであり、その時刻のビーコンブロックのものではありません。\n- 利用できるのはおよそ直近 1 日分のルートだけです。証明は、ルートが上書きされる前に提出する必要があります。\n- 実行ブロックが存在しないタイムスタンプ（スロットの欠落）を問い合わせると revert するため、呼び出し側で処理する必要があります。\n- Merkle 証明は SSZ の hash tree root に対するものなので、証明の生成にはコンセンサスレイヤーのツールが必要です。\n- 関連する [EIP-2935](/eip-2935/) も、同様のシステムコントラクトの方式で過去の実行ブロックハッシュを提供します。\n"},"ko":{"lang":"ko","tldr":"부모 비콘 블록 루트를 모든 실행 블록에 넣고 최근 루트를 시스템 컨트랙트에 저장해, 스마트 컨트랙트가 검증자 잔액 같은 합의 계층의 사실을 Merkle 증명으로 검증할 수 있게 한다.","tags":["beacon-chain","consensus","oracle","staking","core","dencun"],"related":[2935,1559,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4788/","markdown":"## 어떤 문제를 해결하나요?\n\n머지 이후 이더리움은 두 계층으로 나뉩니다. 컨트랙트가 실행되는 실행 계층과, 검증자·잔액·출금을 보관하는 합의 계층(비콘 체인)입니다. 컨트랙트는 합의 계층을 전혀 볼 수 없었습니다. 검증자에 관한 사실이 필요한 스테이킹 풀, 리스테이킹 프로토콜, 브리지는 이를 전달해 주는 신뢰할 수 있는 오라클에 의존해야 했습니다.\n\n비콘 블록 루트는 전체 합의 상태에 대한 암호학적 커밋먼트입니다. 컨트랙트가 신뢰할 수 있는 루트를 읽을 수 있다면, 누구든 그 루트에 대한 Merkle 증명을 제출할 수 있고 컨트랙트는 오라클 없이 그 증명을 온체인에서 검증할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n- **헤더 필드.** 각 실행 블록 헤더에 `parent_beacon_block_root`가 추가됩니다. 부모 비콘 블록의 hash tree root입니다. 합의 클라이언트가 값을 제공하고 실행 클라이언트가 검사합니다.\n- **시스템 컨트랙트.** `BEACON_ROOTS_ADDRESS`(`0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02`)에 작은 컨트랙트가 있습니다. 모든 블록의 시작 시점, 어떤 트랜잭션보다도 먼저, 클라이언트가 `SYSTEM_ADDRESS`(`0xfff…fffe`)에서 루트를 담아 이 컨트랙트를 호출합니다. 이 호출은 블록 가스 한도에 포함되지 않습니다.\n- **링 버퍼.** 컨트랙트는 `HISTORY_BUFFER_LENGTH = 8191`개의 항목을 두 개의 링 버퍼에 보관합니다. 하나는 블록 타임스탬프를, 다른 하나는 루트를 저장하며, 둘 다 인덱스 `timestamp % 8191`에 저장됩니다. 사양에 따르면 현재 슬롯 시간 기준으로 약 하루치 블록을 포괄합니다.\n- **읽기.** 그 외의 호출자는 32바이트 빅엔디언 타임스탬프로 컨트랙트를 호출합니다. 컨트랙트는 그 타임스탬프에 저장된 루트를 반환하며, 입력이 32바이트가 아니거나 0이거나 저장된 타임스탬프가 일치하지 않으면 revert합니다(오래되었거나 없는 항목이 반환되는 일은 없습니다).\n\n이 컨트랙트는 키 없는 \"Nick's method\" 트랜잭션으로 배포되었으므로, 같은 방식으로 배포하는 어떤 체인에서든 주소가 같습니다. 2024년 3월 Dencun 업그레이드와 함께 메인넷에서 활성화되었습니다.\n\n## 샘플 코드\n\nSolidity에서 특정 블록 타임스탬프의 비콘 루트를 읽는 코드입니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract BeaconRootReader {\n    address constant BEACON_ROOTS = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;\n\n    /// Returns the parent beacon block root committed in the block with `ts`.\n    function rootAt(uint256 ts) public view returns (bytes32 root) {\n        (bool ok, bytes memory out) = BEACON_ROOTS.staticcall(abi.encode(ts));\n        require(ok, \"no root for timestamp\");\n        root = abi.decode(out, (bytes32));\n    }\n\n    function latestRoot() external view returns (bytes32) {\n        return rootAt(block.timestamp); // root of this block's parent beacon block\n    }\n}\n```\n\n증명 검증기는 반환된 루트에 대해 SSZ Merkle 브랜치(예: 특정 검증자의 잔액까지의 브랜치)를 검증하게 됩니다.\n\n## 알아둘 점\n\n- 반환되는 루트는 해당 타임스탬프를 가진 실행 블록의 **부모** 비콘 블록의 루트이며, 그 시각의 비콘 블록의 루트가 아닙니다.\n- 대략 최근 하루치 루트만 사용할 수 있습니다. 증명은 해당 루트가 덮어써지기 전에 제출해야 합니다.\n- 실행 블록이 없는 타임스탬프(놓친 슬롯)를 조회하면 revert되므로 호출자가 이를 처리해야 합니다.\n- Merkle 증명은 SSZ hash tree root에 대한 것이므로, 증명을 만들려면 합의 계층 도구가 필요합니다.\n- 함께 소개되는 [EIP-2935](/eip-2935/)는 비슷한 시스템 컨트랙트 방식으로 과거 실행 블록 해시를 제공합니다.\n"},"zh":{"lang":"zh","tldr":"把父信标区块根放入每个执行区块，并将近期的根存入系统合约，让智能合约可以用 Merkle 证明验证验证者余额等共识层信息。","tags":["beacon-chain","consensus","oracle","staking","core","dencun"],"related":[2935,1559,4844],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4788/","markdown":"## 它解决什么问题？\n\n自合并（Merge）以来，以太坊分为两层：合约运行的执行层，以及保存验证者、余额和提款信息的共识层（信标链）。合约完全看不到共识层。需要验证者相关信息的质押池、再质押协议和跨链桥，只能依赖受信任的预言机来转发这些信息。\n\n信标区块根是对整个共识状态的密码学承诺。如果合约能读取一个可信的根，任何人都可以针对它提交 Merkle 证明，合约就能在链上验证该证明，无需预言机。\n\n## 它如何运作\n\n- **区块头字段。** 每个执行区块头新增 `parent_beacon_block_root`，即父信标区块的 hash tree root。共识客户端提供它，执行客户端负责检查。\n- **系统合约。** 在 `BEACON_ROOTS_ADDRESS`（`0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02`）上有一个很小的合约。每个区块开始时，在任何交易之前，客户端会从 `SYSTEM_ADDRESS`（`0xfff…fffe`）携带该根调用它。这次调用不计入区块 gas 上限。\n- **环形缓冲区。** 合约用两个环形缓冲区保存 `HISTORY_BUFFER_LENGTH = 8191` 个条目：一个存区块时间戳，另一个存根，两者都存放在索引 `timestamp % 8191` 处。规范指出，按当前的 slot 时间，这大约覆盖一天的区块。\n- **读取。** 其他任何人用 32 字节大端序的时间戳调用该合约。它返回为该时间戳存储的根；如果输入不是 32 字节、为零，或存储的时间戳不匹配，则 revert（因此不会返回过期或缺失的条目）。\n\n该合约通过无密钥的\"Nick 方法\"交易部署，所以在任何以相同方式部署它的链上，地址都是一样的。它随 2024 年 3 月的 Dencun 升级在主网上线。\n\n## 示例代码\n\n在 Solidity 中读取给定区块时间戳对应的信标根：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract BeaconRootReader {\n    address constant BEACON_ROOTS = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;\n\n    /// Returns the parent beacon block root committed in the block with `ts`.\n    function rootAt(uint256 ts) public view returns (bytes32 root) {\n        (bool ok, bytes memory out) = BEACON_ROOTS.staticcall(abi.encode(ts));\n        require(ok, \"no root for timestamp\");\n        root = abi.decode(out, (bytes32));\n    }\n\n    function latestRoot() external view returns (bytes32) {\n        return rootAt(block.timestamp); // root of this block's parent beacon block\n    }\n}\n```\n\n证明验证器随后会针对返回的根检查 SSZ Merkle 分支（例如指向某个验证者余额的分支）。\n\n## 需要注意\n\n- 返回的根是具有该时间戳的执行区块的**父**信标区块的根，而不是该时间点的信标区块的根。\n- 只有大约最近一天的根可用。证明必须在其对应的根被覆盖之前提交。\n- 查询一个没有执行区块的时间戳（错过的 slot）会 revert，调用方应当处理这种情况。\n- Merkle 证明针对的是 SSZ hash tree root，因此需要共识层工具来构造证明。\n- 配套的 [EIP-2935](/eip-2935/) 使用类似的系统合约模式来提供历史执行区块哈希。\n"}},"requiredBy":[7569,7708,8256,8304]}
