{"eip":1898,"title":"Add `blockHash` to defaultBlock methods","description":"Add `blockHash` option to JSON-RPC methods that currently support defaultBlock parameter.","authors":["Charles Cooper (@charles-cooper)"],"status":"Final","type":"Standards Track","category":"Interface","created":"2019-04-01","requires":[234],"discussionsTo":"https://ethereum-magicians.org/t/eip-1898-add-blockhash-option-to-json-rpc-methods-that-currently-support-defaultblock-parameter/11757","repo":"EIPs","label":"EIP-1898","officialUrl":"https://eips.ethereum.org/EIPS/eip-1898","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1898.md","url":"https://eips.huatuo.xyz/eip-1898/","tldr":{"en":"Lets state-reading JSON-RPC calls such as eth_call and eth_getBalance target a block by its hash, so a series of queries is guaranteed to read the same state even across reorgs.","ja":"eth_call や eth_getBalance などのステートを読む JSON-RPC 呼び出しで、ブロックをハッシュで指定できるようにする。これにより、一連のクエリが reorg をまたいでも同じステートを読むことが保証される。","ko":"eth_call, eth_getBalance 같은 상태 조회 JSON-RPC 호출이 해시로 블록을 지정할 수 있게 해, 일련의 쿼리가 reorg가 일어나도 같은 상태를 읽도록 보장한다.","zh":"让 eth_call 和 eth_getBalance 等读取状态的 JSON-RPC 调用可以通过哈希指定区块，从而保证一系列查询即使跨越链重组也能读取相同的状态。"},"tags":["json-rpc","reorg","eth_call","node","interface"],"explainers":{"en":{"lang":"en","tldr":"Lets state-reading JSON-RPC calls such as eth_call and eth_getBalance target a block by its hash, so a series of queries is guaranteed to read the same state even across reorgs.","tags":["json-rpc","reorg","eth_call","node","interface"],"related":[234,1474,1186],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1898/","markdown":"## What problem does it solve?\n\nMany RPC methods take a \"default block\" parameter: a block number or a tag like `\"latest\"`. Neither pins down a single block. If a chain reorganisation happens between two calls, block number 100 may refer to a different block the second time, and `\"latest\"` moves anyway.\n\nThat breaks apps that need a consistent view across several calls: a wallet showing sender and recipient balances after a transfer, a DEX UI walking an on-chain order list with many `eth_call`s, or logic that depends on two pieces of state at once. Workarounds (re-checking block hashes after each call, relying on logs, vendor-specific subscriptions) are clumsy or incomplete.\n\nEIP-1898 generalises what [EIP-234](/eip-234/) did for log filters: let callers name the exact block by hash.\n\n## How it works\n\nFor these methods:\n\n`eth_getBalance`, `eth_getStorageAt`, `eth_getTransactionCount`, `eth_getCode`, `eth_call`, `eth_getProof`\n\nthe block parameter may now also be an **object**:\n\n- `{ \"blockNumber\": \"0x...\" }`, or\n- `{ \"blockHash\": \"0x...\", \"requireCanonical\": false }`\n\nRules:\n\n- If the block is not found, the node should return an error (recommended code `-32001`, Resource not found).\n- `requireCanonical` defaults to `false`, so a block that has been reorged out can still be queried if the node has it. If `true`, the node should also error when the block is not on the canonical chain (recommended `-32000`), with \"not found\" taking precedence.\n- The old forms (hex number, `\"latest\"`, `\"earliest\"`, `\"pending\"`, `\"safe\"`, `\"finalized\"`) keep working.\n\n## Sample code\n\nRaw JSON-RPC request:\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getBalance\",\n  \"params\": [\n    \"0x0000000000000000000000000000000000000000\",\n    { \"blockHash\": \"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3\", \"requireCanonical\": true }\n  ]\n}\n```\n\n(The hash above is mainnet's genesis block, the example the spec uses.)\n\nPinning several reads to one block with ethers v6:\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst head = await provider.getBlock(\"latest\");\nconst at = { blockHash: head!.hash, requireCanonical: false };\n\nconst [balA, balB] = await Promise.all([\n  provider.send(\"eth_getBalance\", [alice, at]),\n  provider.send(\"eth_getBalance\", [bob, at]),\n]);\nconsole.log(BigInt(balA), BigInt(balB)); // both read from exactly the same state\n```\n\n## Things to know\n\n- Status is **Final**. Support can still vary between node providers, so test against yours.\n- Querying an old or non-canonical block only works if the node still has that state; non-archive nodes prune old state, so very old block hashes may return errors.\n- The method list in the spec does not cover every RPC call; check client docs for others.\n- The full method catalogue lives in the execution-apis spec; [EIP-1474](/eip-1474/) is the older RPC spec this extends.\n"},"ja":{"lang":"ja","tldr":"eth_call や eth_getBalance などのステートを読む JSON-RPC 呼び出しで、ブロックをハッシュで指定できるようにする。これにより、一連のクエリが reorg をまたいでも同じステートを読むことが保証される。","tags":["json-rpc","reorg","eth_call","node","interface"],"related":[234,1474,1186],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1898/","markdown":"## 何を解決するのか\n\n多くの RPC メソッドは「デフォルトブロック」パラメータを取ります。ブロック番号か、`\"latest\"` のようなタグです。どちらも単一のブロックを特定しません。2 回の呼び出しの間にチェーンの再編成が起きると、ブロック番号 100 が 2 回目には別のブロックを指すことがあり、`\"latest\"` はそもそも動きます。\n\nこれは、複数の呼び出しにわたって一貫したビューを必要とするアプリを壊します。送金後に送信者と受信者の残高を表示するウォレット、多数の `eth_call` でオンチェーンの注文リストをたどる DEX の UI、2 つのステートを同時に必要とするロジックなどです。回避策（呼び出しのたびにブロックハッシュを再確認する、ログに頼る、ベンダー固有のサブスクリプションを使う）は、不格好か、不完全です。\n\nEIP-1898 は、[EIP-234](/eip-234/) がログフィルターに対して行ったことを一般化します。呼び出し側が、ハッシュで正確なブロックを指定できるようにするのです。\n\n## 仕組み\n\n次のメソッドについて、\n\n`eth_getBalance`、`eth_getStorageAt`、`eth_getTransactionCount`、`eth_getCode`、`eth_call`、`eth_getProof`\n\nブロックパラメータが**オブジェクト**でもよくなります。\n\n- `{ \"blockNumber\": \"0x...\" }`、または\n- `{ \"blockHash\": \"0x...\", \"requireCanonical\": false }`\n\nルール:\n\n- ブロックが見つからない場合、ノードはエラーを返すべきです（推奨コードは `-32001`、Resource not found）。\n- `requireCanonical` のデフォルトは `false` で、reorg で外れたブロックでも、ノードが持っていればクエリできます。`true` の場合、ブロックが正規チェーン上にないときもノードはエラーを返すべきです（推奨は `-32000`）。「見つからない」が優先されます。\n- 従来の形式（16 進の番号、`\"latest\"`、`\"earliest\"`、`\"pending\"`、`\"safe\"`、`\"finalized\"`）は引き続き動作します。\n\n## サンプルコード\n\n生の JSON-RPC リクエスト:\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getBalance\",\n  \"params\": [\n    \"0x0000000000000000000000000000000000000000\",\n    { \"blockHash\": \"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3\", \"requireCanonical\": true }\n  ]\n}\n```\n\n（上のハッシュは、仕様書が例に使っているメインネットのジェネシスブロックです。）\n\nethers v6 で複数の読み取りを 1 つのブロックに固定する例:\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst head = await provider.getBlock(\"latest\");\nconst at = { blockHash: head!.hash, requireCanonical: false };\n\nconst [balA, balB] = await Promise.all([\n  provider.send(\"eth_getBalance\", [alice, at]),\n  provider.send(\"eth_getBalance\", [bob, at]),\n]);\nconsole.log(BigInt(balA), BigInt(balB)); // both read from exactly the same state\n```\n\n## 知っておくべきこと\n\n- ステータスは **Final** です。サポートの状況はノードプロバイダーによって異なる可能性があるため、利用するプロバイダーでテストしてください。\n- 古いブロックや非正規のブロックをクエリできるのは、ノードがそのステートをまだ持っている場合だけです。アーカイブノードでないノードは古いステートを削除するため、非常に古いブロックハッシュではエラーが返ることがあります。\n- 仕様書のメソッド一覧は、すべての RPC 呼び出しを網羅しているわけではありません。ほかについては、クライアントのドキュメントを確認してください。\n- メソッドの完全な一覧は execution-apis 仕様にあります。[EIP-1474](/eip-1474/) は、これが拡張する古い RPC 仕様です。\n"},"ko":{"lang":"ko","tldr":"eth_call, eth_getBalance 같은 상태 조회 JSON-RPC 호출이 해시로 블록을 지정할 수 있게 해, 일련의 쿼리가 reorg가 일어나도 같은 상태를 읽도록 보장한다.","tags":["json-rpc","reorg","eth_call","node","interface"],"related":[234,1474,1186],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1898/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 RPC 메서드는 \"기본 블록\" 파라미터를 받습니다. 블록 번호이거나 `\"latest\"` 같은 태그입니다. 둘 다 단일 블록을 특정하지 못합니다. 두 호출 사이에 체인 재구성이 일어나면 블록 번호 100이 두 번째에는 다른 블록을 가리킬 수 있고, `\"latest\"`는 원래 움직입니다.\n\n이는 여러 호출에 걸쳐 일관된 뷰가 필요한 앱을 망가뜨립니다. 전송 후 보내는 쪽과 받는 쪽의 잔액을 보여 주는 지갑, 많은 `eth_call`로 온체인 주문 목록을 훑는 DEX UI, 두 가지 상태를 동시에 필요로 하는 로직 등이 그렇습니다. 우회책(호출할 때마다 블록 해시를 다시 확인하기, 로그에 의존하기, 벤더 전용 구독 사용하기)은 어설프거나 불완전합니다.\n\nEIP-1898은 [EIP-234](/eip-234/)가 로그 필터에 대해 한 일을 일반화합니다. 호출자가 해시로 정확한 블록을 지정하게 하는 것입니다.\n\n## 어떻게 동작하나요?\n\n다음 메서드들에 대해,\n\n`eth_getBalance`, `eth_getStorageAt`, `eth_getTransactionCount`, `eth_getCode`, `eth_call`, `eth_getProof`\n\n블록 파라미터가 이제 **객체**일 수도 있습니다.\n\n- `{ \"blockNumber\": \"0x...\" }`, 또는\n- `{ \"blockHash\": \"0x...\", \"requireCanonical\": false }`\n\n규칙:\n\n- 블록을 찾지 못하면 노드는 에러를 반환해야 합니다(권장 코드 `-32001`, Resource not found).\n- `requireCanonical`의 기본값은 `false`이므로, reorg로 밀려난 블록도 노드가 가지고 있다면 조회할 수 있습니다. `true`이면 블록이 정규 체인에 없을 때도 노드가 에러를 반환해야 하며(권장 `-32000`), \"찾을 수 없음\"이 우선합니다.\n- 기존 형식(16진수 번호, `\"latest\"`, `\"earliest\"`, `\"pending\"`, `\"safe\"`, `\"finalized\"`)은 계속 동작합니다.\n\n## 샘플 코드\n\n원시 JSON-RPC 요청:\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getBalance\",\n  \"params\": [\n    \"0x0000000000000000000000000000000000000000\",\n    { \"blockHash\": \"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3\", \"requireCanonical\": true }\n  ]\n}\n```\n\n(위 해시는 명세서가 예로 든 메인넷의 제네시스 블록입니다.)\n\nethers v6로 여러 읽기를 하나의 블록에 고정하기:\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst head = await provider.getBlock(\"latest\");\nconst at = { blockHash: head!.hash, requireCanonical: false };\n\nconst [balA, balB] = await Promise.all([\n  provider.send(\"eth_getBalance\", [alice, at]),\n  provider.send(\"eth_getBalance\", [bob, at]),\n]);\nconsole.log(BigInt(balA), BigInt(balB)); // both read from exactly the same state\n```\n\n## 알아둘 점\n\n- 상태는 **Final**입니다. 노드 제공업체마다 지원 여부가 다를 수 있으니 사용하는 곳에서 테스트하세요.\n- 오래된 블록이나 비정규 블록을 조회하는 것은 노드가 그 상태를 아직 가지고 있을 때만 동작합니다. 아카이브 노드가 아닌 노드는 오래된 상태를 정리하므로, 아주 오래된 블록 해시는 에러를 반환할 수 있습니다.\n- 명세서의 메서드 목록이 모든 RPC 호출을 다루지는 않습니다. 다른 호출은 클라이언트 문서를 확인하세요.\n- 전체 메서드 목록은 execution-apis 명세에 있습니다. [EIP-1474](/eip-1474/)는 이것이 확장하는 이전의 RPC 명세입니다.\n"},"zh":{"lang":"zh","tldr":"让 eth_call 和 eth_getBalance 等读取状态的 JSON-RPC 调用可以通过哈希指定区块，从而保证一系列查询即使跨越链重组也能读取相同的状态。","tags":["json-rpc","reorg","eth_call","node","interface"],"related":[234,1474,1186],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1898/","markdown":"## 它解决什么问题？\n\n许多 RPC 方法接受一个\"默认区块\"参数：区块号，或 `\"latest\"` 之类的标签。两者都不能锁定唯一的区块。如果两次调用之间发生链重组，区块号 100 在第二次可能指向另一个区块，而 `\"latest\"` 本来就会移动。\n\n这会破坏那些需要在多次调用之间保持一致视图的应用：转账后显示发送方和接收方余额的钱包，用许多次 `eth_call` 遍历链上订单列表的 DEX 界面，或同时依赖两份状态的逻辑。各种变通办法（每次调用后重新检查区块哈希、依赖日志、使用厂商特有的订阅）要么笨拙，要么不完整。\n\nEIP-1898 把 [EIP-234](/eip-234/) 为日志过滤器所做的事情推广开来：让调用者通过哈希指定确切的区块。\n\n## 它如何运作\n\n对于以下方法：\n\n`eth_getBalance`、`eth_getStorageAt`、`eth_getTransactionCount`、`eth_getCode`、`eth_call`、`eth_getProof`\n\n区块参数现在也可以是一个**对象**：\n\n- `{ \"blockNumber\": \"0x...\" }`，或\n- `{ \"blockHash\": \"0x...\", \"requireCanonical\": false }`\n\n规则：\n\n- 如果找不到该区块，节点应返回错误（推荐错误码 `-32001`，Resource not found）。\n- `requireCanonical` 默认为 `false`，因此已被重组出链的区块，只要节点还保存着它，仍然可以查询。如果为 `true`，当区块不在规范链上时，节点也应返回错误（推荐 `-32000`），其中\"未找到\"优先。\n- 旧的形式（十六进制编号、`\"latest\"`、`\"earliest\"`、`\"pending\"`、`\"safe\"`、`\"finalized\"`）仍然有效。\n\n## 示例代码\n\n原始 JSON-RPC 请求：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getBalance\",\n  \"params\": [\n    \"0x0000000000000000000000000000000000000000\",\n    { \"blockHash\": \"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3\", \"requireCanonical\": true }\n  ]\n}\n```\n\n（上面的哈希是主网的创世区块，也是规范所用的示例。）\n\n用 ethers v6 把多次读取固定到同一个区块：\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst head = await provider.getBlock(\"latest\");\nconst at = { blockHash: head!.hash, requireCanonical: false };\n\nconst [balA, balB] = await Promise.all([\n  provider.send(\"eth_getBalance\", [alice, at]),\n  provider.send(\"eth_getBalance\", [bob, at]),\n]);\nconsole.log(BigInt(balA), BigInt(balB)); // both read from exactly the same state\n```\n\n## 需要注意\n\n- 状态为 **Final**。各节点提供商的支持情况仍可能不同，请针对你使用的提供商进行测试。\n- 只有在节点仍保留该状态时，才能查询旧区块或非规范区块；非归档节点会裁剪旧状态，因此非常久远的区块哈希可能返回错误。\n- 规范中的方法列表并未涵盖所有 RPC 调用；其他调用请查阅客户端文档。\n- 完整的方法目录位于 execution-apis 规范中；[EIP-1474](/eip-1474/) 是它所扩展的较早的 RPC 规范。\n"}}}
