{"eip":1767,"title":"GraphQL interface to Ethereum node data","description":"This EIP specifies a GraphQL schema for accessing data stored on an Ethereum node. It aims to provide a complete replacement to the read-only information exposed via the present JSON-RPC interface, while improving on usability, consistency, efficiency, and future-proofing.","authors":["Nick Johnson (@arachnid)","Raúl Kripalani (@raulk)","Kris Shinn (@kshinn)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2019-02-14","discussionsTo":"https://ethereum-magicians.org/t/graphql-interface-to-ethereum-node-data/2710","repo":"EIPs","label":"EIP-1767","officialUrl":"https://eips.ethereum.org/EIPS/eip-1767","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1767.md","url":"https://eips.huatuo.xyz/eip-1767/","tldr":{"en":"Specifies a GraphQL schema and endpoint for Ethereum nodes, letting clients fetch exactly the block, transaction, account and log data they need in one query.","ja":"Ethereum ノード向けの GraphQL スキーマとエンドポイントを定める。クライアントは、必要なブロック、トランザクション、アカウント、ログのデータだけを、1 回のクエリで正確に取得できる。","ko":"이더리움 노드를 위한 GraphQL 스키마와 엔드포인트를 규정한다. 클라이언트는 필요한 블록, 트랜잭션, 계정, 로그 데이터만 쿼리 한 번으로 정확히 가져올 수 있다.","zh":"为以太坊节点规定 GraphQL schema 和端点，让客户端用一次查询就能精确获取所需的区块、交易、账户和日志数据。"},"tags":["graphql","api","node","json-rpc","interface"],"explainers":{"en":{"lang":"en","tldr":"Specifies a GraphQL schema and endpoint for Ethereum nodes, letting clients fetch exactly the block, transaction, account and log data they need in one query.","tags":["graphql","api","node","json-rpc","interface"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1767/","markdown":"## What problem does it solve?\n\nThe JSON-RPC interface has two kinds of weakness. It was loosely specified, so clients disagreed on details such as how to encode an empty byte string (`\"\"`, `\"0x\"` or `\"0x0\"`). And it returns fixed bundles of fields, so the node often does work the caller does not need: `eth_getBlock` always fetches `totalDifficulty`, and fetching every receipt in a block via `eth_getTransactionReceipt` can mean deserializing the same data again and again.\n\nEIP-1767 proposes GraphQL as a cleaner read API. The caller describes exactly which fields it wants, related data (block → transactions → receipts → logs) comes back in one round trip, and the schema itself is the formal specification.\n\n## How it works\n\n- Nodes **must** expose a GraphQL endpoint over HTTP, **should** serve it at `/graphql`, and **should** use port 8547 by default. They **may** serve the GraphiQL explorer at `/`.\n- The schema defines scalars (`Bytes32`, `Address`, `Bytes`, `BigInt`, `Long`) with strict hex encodings, and types such as `Block`, `Transaction`, `Account`, `Log`, `CallResult`, `SyncState` and `Pending`.\n- Top-level queries: `block`, `blocks`, `transaction`, `logs`, `pending`, `gasPrice`, `protocolVersion`, `syncing`.\n- One mutation: `sendRawTransaction`.\n- Calls and gas estimation are fields on a block (`block { call(...) }`), so they run against that block's state.\n\nMost read-only JSON-RPC methods map directly onto queries:\n\n| JSON-RPC | GraphQL |\n| --- | --- |\n| `eth_blockNumber` | `{ block { number } }` |\n| `eth_getBalance` | `{ block { account(address: \"0x...\") { balance } } }` |\n| `eth_getTransactionReceipt` | `{ transaction(hash: \"0x...\") { status gasUsed logs { ... } } }` |\n| `eth_sendRawTransaction` | `mutation { sendRawTransaction(data: \"0x...\") }` |\n\nNode-side signing (`eth_sign`, `eth_sendTransaction`), compilers, filters and mining calls are intentionally left out. Client-specific extensions must be prefixed, for example `_geth_`.\n\n## Sample code\n\nAll transactions in the latest block with their status and logs, in one request:\n\n```graphql\n{\n  block {\n    number\n    hash\n    transactions {\n      hash\n      from { address }\n      to { address }\n      status\n      gasUsed\n      logs { topics data }\n    }\n  }\n}\n```\n\nSending it from TypeScript:\n\n```ts\nconst query = `{ block { number transactions { hash status } } }`;\n\nconst res = await fetch(\"http://localhost:8547/graphql\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ query }),\n});\nconst { data } = await res.json();\nconsole.log(data.block.number, data.block.transactions.length);\n```\n\n## Things to know\n\n- **Status: Stagnant.** The EIP itself was not finalized, though the spec lists implementations in go-ethereum (from 1.9.0) and Pantheon (now Hyperledger Besu).\n- Endpoints are usually disabled by default and must be turned on with a client flag. Check your client's documentation for the exact option and port.\n- Fields described in the spec reflect proof-of-work era blocks (`difficulty`, `ommers`, `mixHash`). Client schemas have evolved since; inspect the live schema with GraphQL introspection rather than relying on this EIP.\n- JSON-RPC ([EIP-1474](/eip-1474/) and the current execution API spec) remains the primary interface; GraphQL is an optional extra.\n"},"ja":{"lang":"ja","tldr":"Ethereum ノード向けの GraphQL スキーマとエンドポイントを定める。クライアントは、必要なブロック、トランザクション、アカウント、ログのデータだけを、1 回のクエリで正確に取得できる。","tags":["graphql","api","node","json-rpc","interface"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1767/","markdown":"## 何を解決するのか\n\nJSON-RPC インターフェースには 2 種類の弱点があります。仕様が緩かったため、空のバイト列をどうエンコードするか（`\"\"`、`\"0x\"`、`\"0x0\"`）といった細部でクライアント間の見解が分かれました。また、決まったフィールドのまとまりを返すため、呼び出し側に不要な処理をノードがしてしまうことがよくあります。`eth_getBlock` は常に `totalDifficulty` を取得しますし、ブロック内のすべてのレシートを `eth_getTransactionReceipt` で取得すると、同じデータを何度もデシリアライズすることになりかねません。\n\nEIP-1767 は、よりすっきりした読み取り API として GraphQL を提案します。呼び出し側は欲しいフィールドを正確に記述し、関連データ（ブロック → トランザクション → レシート → ログ）は 1 回のラウンドトリップで返り、スキーマ自体が正式な仕様になります。\n\n## 仕組み\n\n- ノードは、HTTP 上で GraphQL エンドポイントを公開**しなければならず**、`/graphql` で提供する**べきで**、デフォルトでポート 8547 を使う**べきです**。GraphiQL エクスプローラーを `/` で提供してもかまい**ません**。\n- スキーマは、厳格な 16 進エンコーディングを持つスカラー（`Bytes32`、`Address`、`Bytes`、`BigInt`、`Long`）と、`Block`、`Transaction`、`Account`、`Log`、`CallResult`、`SyncState`、`Pending` などの型を定義します。\n- トップレベルのクエリ: `block`、`blocks`、`transaction`、`logs`、`pending`、`gasPrice`、`protocolVersion`、`syncing`。\n- ミューテーションは 1 つ: `sendRawTransaction`。\n- 呼び出しとガス見積もりはブロックのフィールドになっており（`block { call(...) }`）、そのブロックの状態に対して実行されます。\n\n読み取り専用の JSON-RPC メソッドの多くは、クエリに直接対応します。\n\n| JSON-RPC | GraphQL |\n| --- | --- |\n| `eth_blockNumber` | `{ block { number } }` |\n| `eth_getBalance` | `{ block { account(address: \"0x...\") { balance } } }` |\n| `eth_getTransactionReceipt` | `{ transaction(hash: \"0x...\") { status gasUsed logs { ... } } }` |\n| `eth_sendRawTransaction` | `mutation { sendRawTransaction(data: \"0x...\") }` |\n\nノード側での署名（`eth_sign`、`eth_sendTransaction`）、コンパイラ、フィルター、マイニングの呼び出しは、意図的に除外されています。クライアント固有の拡張には、たとえば `_geth_` のようにプレフィックスを付けなければなりません。\n\n## サンプルコード\n\n最新ブロックのすべてのトランザクションを、ステータスとログとともに 1 回のリクエストで取得する:\n\n```graphql\n{\n  block {\n    number\n    hash\n    transactions {\n      hash\n      from { address }\n      to { address }\n      status\n      gasUsed\n      logs { topics data }\n    }\n  }\n}\n```\n\nTypeScript から送信する:\n\n```ts\nconst query = `{ block { number transactions { hash status } } }`;\n\nconst res = await fetch(\"http://localhost:8547/graphql\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ query }),\n});\nconst { data } = await res.json();\nconsole.log(data.block.number, data.block.transactions.length);\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** EIP 自体は確定しませんでしたが、仕様書には go-ethereum（1.9.0 以降）と Pantheon（現在の Hyperledger Besu）の実装が挙げられています。\n- エンドポイントは通常、デフォルトでは無効で、クライアントのフラグで有効にする必要があります。正確なオプションとポートは、お使いのクライアントのドキュメントを確認してください。\n- 仕様書に記載されたフィールドは、プルーフ・オブ・ワーク時代のブロック（`difficulty`、`ommers`、`mixHash`）を反映しています。クライアントのスキーマはその後進化しています。この EIP に頼らず、GraphQL のイントロスペクションで稼働中のスキーマを確認してください。\n- JSON-RPC（[EIP-1474](/eip-1474/) と現行の実行 API 仕様）が引き続き主要なインターフェースであり、GraphQL は任意の追加機能です。\n"},"ko":{"lang":"ko","tldr":"이더리움 노드를 위한 GraphQL 스키마와 엔드포인트를 규정한다. 클라이언트는 필요한 블록, 트랜잭션, 계정, 로그 데이터만 쿼리 한 번으로 정확히 가져올 수 있다.","tags":["graphql","api","node","json-rpc","interface"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1767/","markdown":"## 어떤 문제를 해결하나요?\n\nJSON-RPC 인터페이스에는 두 가지 약점이 있습니다. 명세가 느슨해서, 빈 바이트 문자열을 어떻게 인코딩할지(`\"\"`, `\"0x\"`, `\"0x0\"`) 같은 세부 사항에서 클라이언트마다 의견이 갈렸습니다. 그리고 정해진 필드 묶음을 반환하기 때문에 호출자에게 필요하지 않은 작업을 노드가 하게 되는 경우가 많습니다. `eth_getBlock`은 항상 `totalDifficulty`를 가져오고, 블록의 모든 영수증을 `eth_getTransactionReceipt`로 가져오면 같은 데이터를 계속 반복해서 역직렬화하게 될 수 있습니다.\n\nEIP-1767은 더 깔끔한 읽기 API로 GraphQL을 제안합니다. 호출자는 원하는 필드를 정확히 기술하고, 관련 데이터(블록 → 트랜잭션 → 영수증 → 로그)는 한 번의 왕복으로 돌아오며, 스키마 자체가 공식 명세가 됩니다.\n\n## 어떻게 동작하나요?\n\n- 노드는 HTTP로 GraphQL 엔드포인트를 노출**해야 하고**, `/graphql`에서 제공**해야 하며**, 기본적으로 8547 포트를 사용**해야 합니다**. GraphiQL 탐색기를 `/`에서 제공**해도 됩니다**.\n- 스키마는 엄격한 16진수 인코딩을 갖는 스칼라(`Bytes32`, `Address`, `Bytes`, `BigInt`, `Long`)와 `Block`, `Transaction`, `Account`, `Log`, `CallResult`, `SyncState`, `Pending` 같은 타입을 정의합니다.\n- 최상위 쿼리: `block`, `blocks`, `transaction`, `logs`, `pending`, `gasPrice`, `protocolVersion`, `syncing`.\n- 뮤테이션은 하나: `sendRawTransaction`.\n- 호출과 가스 추정은 블록의 필드(`block { call(...) }`)이므로 해당 블록의 상태를 기준으로 실행됩니다.\n\n대부분의 읽기 전용 JSON-RPC 메서드는 쿼리에 그대로 대응합니다.\n\n| JSON-RPC | GraphQL |\n| --- | --- |\n| `eth_blockNumber` | `{ block { number } }` |\n| `eth_getBalance` | `{ block { account(address: \"0x...\") { balance } } }` |\n| `eth_getTransactionReceipt` | `{ transaction(hash: \"0x...\") { status gasUsed logs { ... } } }` |\n| `eth_sendRawTransaction` | `mutation { sendRawTransaction(data: \"0x...\") }` |\n\n노드 측 서명(`eth_sign`, `eth_sendTransaction`), 컴파일러, 필터, 채굴 호출은 의도적으로 제외되었습니다. 클라이언트 고유 확장에는 `_geth_`처럼 접두사를 붙여야 합니다.\n\n## 샘플 코드\n\n최신 블록의 모든 트랜잭션을 상태와 로그와 함께 한 번의 요청으로 가져옵니다.\n\n```graphql\n{\n  block {\n    number\n    hash\n    transactions {\n      hash\n      from { address }\n      to { address }\n      status\n      gasUsed\n      logs { topics data }\n    }\n  }\n}\n```\n\nTypeScript에서 보내기:\n\n```ts\nconst query = `{ block { number transactions { hash status } } }`;\n\nconst res = await fetch(\"http://localhost:8547/graphql\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ query }),\n});\nconst { data } = await res.json();\nconsole.log(data.block.number, data.block.transactions.length);\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** EIP 자체는 확정되지 않았지만, 명세에는 go-ethereum(1.9.0부터)과 Pantheon(현재의 Hyperledger Besu)의 구현이 나열되어 있습니다.\n- 엔드포인트는 보통 기본적으로 비활성화되어 있어 클라이언트 플래그로 켜야 합니다. 정확한 옵션과 포트는 사용 중인 클라이언트의 문서를 확인하세요.\n- 명세에 기술된 필드는 작업 증명 시대의 블록(`difficulty`, `ommers`, `mixHash`)을 반영합니다. 클라이언트 스키마는 그 뒤로 발전했으니, 이 EIP에 의존하지 말고 GraphQL 인트로스펙션으로 실제 동작 중인 스키마를 확인하세요.\n- JSON-RPC([EIP-1474](/eip-1474/)와 현재의 실행 API 명세)가 여전히 주된 인터페이스이며, GraphQL은 선택적인 부가 기능입니다.\n"},"zh":{"lang":"zh","tldr":"为以太坊节点规定 GraphQL schema 和端点，让客户端用一次查询就能精确获取所需的区块、交易、账户和日志数据。","tags":["graphql","api","node","json-rpc","interface"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1767/","markdown":"## 它解决什么问题？\n\nJSON-RPC 接口有两类弱点。其一，它的规范比较松散，客户端在一些细节上存在分歧，例如如何编码空字节串（`\"\"`、`\"0x\"` 还是 `\"0x0\"`）。其二，它返回的是固定的字段组合，因此节点常常要做调用者并不需要的工作：`eth_getBlock` 总是会获取 `totalDifficulty`，而通过 `eth_getTransactionReceipt` 获取区块中的每一张收据，可能意味着一遍又一遍地反序列化相同的数据。\n\nEIP-1767 提议用 GraphQL 作为更干净的读取 API。调用者准确描述自己想要哪些字段，相关数据（区块 → 交易 → 收据 → 日志）在一次往返中返回，而 schema 本身就是正式的规范。\n\n## 它如何运作\n\n- 节点**必须**通过 HTTP 暴露一个 GraphQL 端点，**应当**在 `/graphql` 提供服务，并且**应当**默认使用 8547 端口。它们**可以**在 `/` 提供 GraphiQL 浏览器。\n- schema 定义了带有严格十六进制编码的标量（`Bytes32`、`Address`、`Bytes`、`BigInt`、`Long`），以及 `Block`、`Transaction`、`Account`、`Log`、`CallResult`、`SyncState` 和 `Pending` 等类型。\n- 顶层查询：`block`、`blocks`、`transaction`、`logs`、`pending`、`gasPrice`、`protocolVersion`、`syncing`。\n- 一个 mutation：`sendRawTransaction`。\n- 调用和 gas 估算是区块上的字段（`block { call(...) }`），因此它们针对该区块的状态运行。\n\n大多数只读的 JSON-RPC 方法都能直接映射为查询：\n\n| JSON-RPC | GraphQL |\n| --- | --- |\n| `eth_blockNumber` | `{ block { number } }` |\n| `eth_getBalance` | `{ block { account(address: \"0x...\") { balance } } }` |\n| `eth_getTransactionReceipt` | `{ transaction(hash: \"0x...\") { status gasUsed logs { ... } } }` |\n| `eth_sendRawTransaction` | `mutation { sendRawTransaction(data: \"0x...\") }` |\n\n节点侧签名（`eth_sign`、`eth_sendTransaction`）、编译器、过滤器和挖矿相关调用被有意排除在外。特定于客户端的扩展必须加前缀，例如 `_geth_`。\n\n## 示例代码\n\n用一次请求获取最新区块中的所有交易及其状态和日志：\n\n```graphql\n{\n  block {\n    number\n    hash\n    transactions {\n      hash\n      from { address }\n      to { address }\n      status\n      gasUsed\n      logs { topics data }\n    }\n  }\n}\n```\n\n用 TypeScript 发送：\n\n```ts\nconst query = `{ block { number transactions { hash status } } }`;\n\nconst res = await fetch(\"http://localhost:8547/graphql\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ query }),\n});\nconst { data } = await res.json();\nconsole.log(data.block.number, data.block.transactions.length);\n```\n\n## 需要注意\n\n- **状态：Stagnant。** EIP 本身没有最终确定，不过规范列出了 go-ethereum（自 1.9.0 起）和 Pantheon（现为 Hyperledger Besu）中的实现。\n- 端点通常默认处于关闭状态，需要通过客户端的参数开启。确切的选项和端口请查阅你所用客户端的文档。\n- 规范中描述的字段反映的是工作量证明时代的区块（`difficulty`、`ommers`、`mixHash`）。客户端的 schema 此后已经演进；请通过 GraphQL 内省查看实际运行的 schema，而不要依赖这份 EIP。\n- JSON-RPC（[EIP-1474](/eip-1474/) 以及当前的执行层 API 规范）仍是主要接口；GraphQL 是可选的补充。\n"}}}
