Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC1767, a proposal to make data retrieval from Ethereum nodes more flexible and efficient by introducing a standard GraphQL interface as an alternative to conventional JSON-RPC.

This article translates, summarizes, and expands on the proposal linked below.

Overview

ERC1767 aims to standardize a GraphQL schema as an alternative way to access data stored by Ethereum nodes. The conventional JSON-RPC interface has been widely used to retrieve information, but it has limitations in flexibility and efficiency. ERC1767 proposes GraphQL as a more usable, predictable, efficient, and extensible alternative for these read operations.

Motivation

At the time of the proposal, Ethereum's JSON-RPC interface had several shortcomings. Its informal and incomplete specification meant that behavior could vary slightly between nodes and that data formats were not always consistent. Even empty byte strings had multiple representations, such as "", 0x, and 0x0, creating compatibility problems.

JSON-RPC also tends to retrieve data based on what the interface assumes the caller needs, leading to unnecessary work. For example, when retrieving block information using eth_getBlock, the interface always loads the totalDifficulty field, even if the caller does not use it. Because this field is stored separately from the block header, it requires an additional disk access, reducing performance.

Similar inefficiencies arise when retrieving transaction receipts. In go-ethereum, all receipts in a block are stored together as a single binary object. Retrieving an individual transaction receipt requires loading the entire object and extracting the relevant receipt. Many clients want every receipt in a block, so retrieving them individually requires repeatedly loading the same binary object. The amount of work therefore grows quadratically.

These inefficiencies arise from the design constraints of JSON-RPC. Even if they could be addressed, doing so would introduce additional interface complexity. ERC1767 therefore proposes adopting GraphQL, an established query language. GraphQL lets callers specify exactly which data they need, reducing unnecessary processing and enabling more flexible and efficient API design.

Earlier work

Nick Johnson and the EthQL project independently developed the idea of using GraphQL to access Ethereum nodes. They subsequently collaborated to unify their respective schemas. The schema proposed in ERC1767 is based primarily on the one developed by EthQL.

By standardizing an established GraphQL-based schema, the proposal aims to improve how applications interact with Ethereum nodes.

Specification

Exposing a GraphQL endpoint

Ethereum nodes supporting the GraphQL API defined by ERC1767 must expose a GraphQL endpoint over HTTP. The endpoint should use the /graphql path, with 8547 as the recommended default port.

Nodes may also optionally provide GraphiQL at the / path, allowing developers to explore queries interactively.

Data types (scalars)

The GraphQL schema defines several custom scalar types to represent Ethereum data.

  • Bytes32
    • Fixed-length 32-byte binary data, represented as hexadecimal prefixed with 0x.
  • Address
    • A 20-byte Ethereum address.
  • Bytes
    • Variable-length binary data. An empty byte sequence is represented as 0x.
  • BigInt
    • An arbitrary-size integer. Input may be a number or a string in decimal or hexadecimal notation.
  • Long
    • A 64-bit unsigned integer.

These types provide explicit representations for Ethereum-specific data formats.

Schema structure

The schema is centered on schema { query: Query, mutation: Mutation }. Read-only operations belong to Query, while write operations such as transaction submission belong to Mutation.

Schema

graphql
# Bytes32 is a 32 byte binary string, represented as 0x-prefixed hexadecimal.
scalar Bytes32
# Address is a 20 byte Ethereum address, represented as 0x-prefixed hexadecimal.
scalar Address
# Bytes is an arbitrary length binary string, represented as 0x-prefixed hexadecimal.
# An empty byte string is represented as '0x'. Byte strings must have an even number of hexadecimal nybbles.
scalar Bytes
# BigInt is a large integer. Input is accepted as either a JSON number or as a string.
# Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
# 0x-prefixed hexadecimal.
scalar BigInt
# Long is a 64 bit unsigned integer.
scalar Long

schema {
    query: Query
    mutation: Mutation
}

# Account is an Ethereum account at a particular block.
type Account {
    # Address is the address owning the account.
    address: Address!
    # Balance is the balance of the account, in wei.
    balance: BigInt!
    # TransactionCount is the number of transactions sent from this account,
    # or in the case of a contract, the number of contracts created. Otherwise
    # known as the nonce.
    transactionCount: Long!
    # Code contains the smart contract code for this account, if the account
    # is a (non-self-destructed) contract.
    code: Bytes!
    # Storage provides access to the storage of a contract account, indexed
    # by its 32 byte slot identifier.
    storage(slot: Bytes32!): Bytes32!
}

# Log is an Ethereum event log.
type Log {
    # Index is the index of this log in the block.
    index: Int!
    # Account is the account which generated this log - this will always
    # be a contract account.
    account(block: Long): Account!
    # Topics is a list of 0-4 indexed topics for the log.
    topics: [Bytes32!]!
    # Data is unindexed data for this log.
    data: Bytes!
    # Transaction is the transaction that generated this log entry.
    transaction: Transaction!
}

# Transaction is an Ethereum transaction.
type Transaction {
    # Hash is the hash of this transaction.
    hash: Bytes32!
    # Nonce is the nonce of the account this transaction was generated with.
    nonce: Long!
    # Index is the index of this transaction in the parent block. This will
    # be null if the transaction has not yet been mined.
    index: Int
    # From is the account that sent this transaction - this will always be
    # an externally owned account.
    from(block: Long): Account!
    # To is the account the transaction was sent to. This is null for
    # contract-creating transactions.
    to(block: Long): Account
    # Value is the value, in wei, sent along with this transaction.
    value: BigInt!
    # GasPrice is the price offered to miners for gas, in wei per unit.
    gasPrice: BigInt!
    # Gas is the maximum amount of gas this transaction can consume.
    gas: Long!
    # InputData is the data supplied to the target of the transaction.
    inputData: Bytes!
    # Block is the block this transaction was mined in. This will be null if
    # the transaction has not yet been mined.
    block: Block

    # Status is the return status of the transaction. This will be 1 if the
    # transaction succeeded, or 0 if it failed (due to a revert, or due to
    # running out of gas). If the transaction has not yet been mined, this
    # field will be null.
    status: Long
    # GasUsed is the amount of gas that was used processing this transaction.
    # If the transaction has not yet been mined, this field will be null.
    gasUsed: Long
    # CumulativeGasUsed is the total gas used in the block up to and including
    # this transaction. If the transaction has not yet been mined, this field
    # will be null.
    cumulativeGasUsed: Long
    # CreatedContract is the account that was created by a contract creation
    # transaction. If the transaction was not a contract creation transaction,
    # or it has not yet been mined, this field will be null.
    createdContract(block: Long): Account
    # Logs is a list of log entries emitted by this transaction. If the
    # transaction has not yet been mined, this field will be null.
    logs: [Log!]
}

# BlockFilterCriteria encapsulates log filter criteria for a filter applied
# to a single block.
input BlockFilterCriteria {
    # Addresses is list of addresses that are of interest. If this list is
    # empty, results will not be filtered by address.
    addresses: [Address!]
    # Topics list restricts matches to particular event topics. Each event has a list
  # of topics. Topics matches a prefix of that list. An empty element array matches any
  # topic. Non-empty elements represent an alternative that matches any of the
  # contained topics.
  #
  # Examples:
  #  - [] or nil          matches any topic list
  #  - [[A]]              matches topic A in first position
  #  - [[], [B]]          matches any topic in first position, B in second position
  #  - [[A], [B]]         matches topic A in first position, B in second position
  #  - [[A, B]], [C, D]]  matches topic (A OR B) in first position, (C OR D) in second position
    topics: [[Bytes32!]!]
}

# Block is an Ethereum block.
type Block {
    # Number is the number of this block, starting at 0 for the genesis block.
    number: Long!
    # Hash is the block hash of this block.
    hash: Bytes32!
    # Parent is the parent block of this block.
    parent: Block
    # Nonce is the block nonce, an 8 byte sequence determined by the miner.
    nonce: Bytes!
    # TransactionsRoot is the keccak256 hash of the root of the trie of transactions in this block.
    transactionsRoot: Bytes32!
    # TransactionCount is the number of transactions in this block. if
    # transactions are not available for this block, this field will be null.
    transactionCount: Int
    # StateRoot is the keccak256 hash of the state trie after this block was processed.
    stateRoot: Bytes32!
    # ReceiptsRoot is the keccak256 hash of the trie of transaction receipts in this block.
    receiptsRoot: Bytes32!
    # Miner is the account that mined this block.
    miner(block: Long): Account!
    # ExtraData is an arbitrary data field supplied by the miner.
    extraData: Bytes!
    # GasLimit is the maximum amount of gas that was available to transactions in this block.
    gasLimit: Long!
    # GasUsed is the amount of gas that was used executing transactions in this block.
    gasUsed: Long!
    # Timestamp is the unix timestamp at which this block was mined.
    timestamp: BigInt!
    # LogsBloom is a bloom filter that can be used to check if a block may
    # contain log entries matching a filter.
    logsBloom: Bytes!
    # MixHash is the hash that was used as an input to the PoW process.
    mixHash: Bytes32!
    # Difficulty is a measure of the difficulty of mining this block.
    difficulty: BigInt!
    # TotalDifficulty is the sum of all difficulty values up to and including
    # this block.
    totalDifficulty: BigInt!
    # OmmerCount is the number of ommers (AKA uncles) associated with this
    # block. If ommers are unavailable, this field will be null.
    ommerCount: Int
    # Ommers is a list of ommer (AKA uncle) blocks associated with this block.
    # If ommers are unavailable, this field will be null. Depending on your
    # node, the transactions, transactionAt, transactionCount, ommers,
    # ommerCount and ommerAt fields may not be available on any ommer blocks.
    ommers: [Block]
    # OmmerAt returns the ommer (AKA uncle) at the specified index. If ommers
    # are unavailable, or the index is out of bounds, this field will be null.
    ommerAt(index: Int!): Block
    # OmmerHash is the keccak256 hash of all the ommers (AKA uncles)
    # associated with this block.
    ommerHash: Bytes32!
    # Transactions is a list of transactions associated with this block. If
    # transactions are unavailable for this block, this field will be null.
    transactions: [Transaction!]
    # TransactionAt returns the transaction at the specified index. If
    # transactions are unavailable for this block, or if the index is out of
    # bounds, this field will be null.
    transactionAt(index: Int!): Transaction
    # Logs returns a filtered set of logs from this block.
    logs(filter: BlockFilterCriteria!): [Log!]!
    # Account fetches an Ethereum account at the current block's state.
    account(address: Address!): Account
    # Call executes a local call operation at the current block's state.
    call(data: CallData!): CallResult
    # EstimateGas estimates the amount of gas that will be required for
    # successful execution of a transaction at the current block's state.
    estimateGas(data: CallData!): Long!
}

# CallData represents the data associated with a local contract call.
# All fields are optional.
input CallData {
    # From is the address making the call.
    from: Address
    # To is the address the call is sent to.
    to: Address
    # Gas is the amount of gas sent with the call.
    gas: Long
    # GasPrice is the price, in wei, offered for each unit of gas.
    gasPrice: BigInt
    # Value is the value, in wei, sent along with the call.
    value: BigInt
    # Data is the data sent to the callee.
    data: Bytes
}

# CallResult is the result of a local call operation.
type CallResult {
    # Data is the return data of the called contract.
    data: Bytes!
    # GasUsed is the amount of gas used by the call, after any refunds.
    gasUsed: Long!
    # Status is the result of the call - 1 for success or 0 for failure.
    status: Long!
}

# FilterCriteria encapsulates log filter criteria for searching log entries.
input FilterCriteria {
    # FromBlock is the block at which to start searching, inclusive. Defaults
    # to the latest block if not supplied.
    fromBlock: Long
    # ToBlock is the block at which to stop searching, inclusive. Defaults
    # to the latest block if not supplied.
    toBlock: Long
    # Addresses is a list of addresses that are of interest. If this list is
    # empty, results will not be filtered by address.
    addresses: [Address!]
    # Topics list restricts matches to particular event topics. Each event has a list
  # of topics. Topics matches a prefix of that list. An empty element array matches any
  # topic. Non-empty elements represent an alternative that matches any of the
  # contained topics.
  #
  # Examples:
  #  - [] or nil          matches any topic list
  #  - [[A]]              matches topic A in first position
  #  - [[], [B]]          matches any topic in first position, B in second position
  #  - [[A], [B]]         matches topic A in first position, B in second position
  #  - [[A, B]], [C, D]]  matches topic (A OR B) in first position, (C OR D) in second position
    topics: [[Bytes32!]!]
}

# SyncState contains the current synchronisation state of the client.
type SyncState{
    # StartingBlock is the block number at which synchronisation started.
    startingBlock: Long!
    # CurrentBlock is the point at which synchronisation has presently reached.
    currentBlock: Long!
    # HighestBlock is the latest known block number.
    highestBlock: Long!
    # PulledStates is the number of state entries fetched so far, or null
    # if this is not known or not relevant.
    pulledStates: Long
    # KnownStates is the number of states the node knows of so far, or null
    # if this is not known or not relevant.
    knownStates: Long
}

# Pending represents the current pending state.
type Pending {
  # TransactionCount is the number of transactions in the pending state.
  transactionCount: Int!
  # Transactions is a list of transactions in the current pending state.
  transactions: [Transaction!]
  # Account fetches an Ethereum account for the pending state.
  account(address: Address!): Account
  # Call executes a local call operation for the pending state.
  call(data: CallData!): CallResult
  # EstimateGas estimates the amount of gas that will be required for
  # successful execution of a transaction for the pending state.
  estimateGas(data: CallData!): Long!  
}

type Query {
    # Block fetches an Ethereum block by number or by hash. If neither is
    # supplied, the most recent known block is returned.
    block(number: Long, hash: Bytes32): Block
    # Blocks returns all the blocks between two numbers, inclusive. If
    # to is not supplied, it defaults to the most recent known block.
    blocks(from: Long!, to: Long): [Block!]!
    # Pending returns the current pending state.
    pending: Pending!
    # Transaction returns a transaction specified by its hash.
    transaction(hash: Bytes32!): Transaction
    # Logs returns log entries matching the provided filter.
    logs(filter: FilterCriteria!): [Log!]!
    # GasPrice returns the node's estimate of a gas price sufficient to
    # ensure a transaction is mined in a timely fashion.
    gasPrice: BigInt!
    # ProtocolVersion returns the current wire protocol version number.
    protocolVersion: Int!
    # Syncing returns information on the current synchronisation state.
    syncing: SyncState
}

type Mutation {
    # SendRawTransaction sends an RLP-encoded transaction to the network.
    sendRawTransaction(data: Bytes!): Bytes32!
}

Main GraphQL types

Account type

Represents Ethereum account information. It provides the address, balance, transaction count, contract code, and the ability to read individual storage slots.

Transaction type

Provides transaction details. These include the sender and recipient, gas, input data, status, block information, any created contract, and logs.

Block type

Represents detailed information about a block. Clients can retrieve its hash, parent block, transaction list, gas usage, timestamp, difficulty, and ommers (uncle blocks). The call and estimateGas fields also allow local simulation of contract calls and gas estimation.

Log type

Represents event log information. Clients can retrieve the originating account, topics (indexed parameters), data (non-indexed parameters), and associated transaction information.

Pending type

Provides information about pending transactions and accounts. Clients can inspect submitted transactions not yet included in a block and execute call or estimateGas against the pending state.

CallData and CallResult types

CallData represents the parameters for a local contract call, while CallResult represents its result. The result includes return data, gas used, and the execution status.

SyncState type

Represents the node's synchronization status. It returns information such as the starting block, current synchronization position, highest block, and number of state entries already retrieved.

Filter input types

  • FilterCriteria specifies filtering criteria for logs spanning multiple blocks.
  • BlockFilterCriteria specifies filtering criteria for logs within a single block.

Both support filtering by addresses and topics (event identifiers).

Query type: read operations

This is the entry point for clients retrieving information from an Ethereum node. It defines operations including:

  • Retrieving blocks by number or hash
  • Retrieving transactions by hash
  • Retrieving filtered logs
  • Inspecting the pending state
  • Retrieving gas prices and synchronization status

Mutation type: write operations

Defines transaction submission operations. The sendRawTransaction mutation allows clients to submit an RLP-encoded transaction to the network.

Extension policy

Individual Ethereum clients, such as Geth and Parity, may extend this schema. Extensions must use explicit client-specific prefixes such as clientGeth or clientParity. Additions to the common specification must be formally proposed in a separate EIP.

Additional considerations

Changes in Ethereum node design

The design of Ethereum nodes has been shifting from a model in which a single node does everything toward a Unix-like approach that delegates specific functionality to dedicated processes. Under this approach, the node primarily provides data, while separate processes handle tasks such as signing transactions and compiling code.

Reflecting this design, the GraphQL API intentionally omits the following functionality.

  • Contract compilation (eth_compile*) was already deprecated and is not included in the GraphQL schema.
  • Account management (eth_accounts), signing (eth_sign), and transaction submission through managed accounts (eth_sendTransaction) were expected to be deprecated in the future and are excluded from the schema.

Applications requiring these capabilities should use external tools or services, such as local wallets or dedicated signing daemons.

Two areas intentionally deferred

The initial GraphQL API specification deliberately excludes two areas of functionality. These omissions reflect design considerations rather than simply a lack of implementation.

The first is filter functionality. Supporting it requires GraphQL subscriptions, which may require nodes to maintain state for individual clients. This could conflict with the design goal of keeping Ethereum nodes stateless with respect to clients. The proposal therefore leaves the standardization of GraphQL filters to a separate future EIP.

The second is mining functionality. At the time of the proposal, it was not widely used, and reimplementing it in GraphQL would provide little benefit. It was therefore excluded and could be defined in a separate EIP if needed.

Compatibility

The GraphQL schema proposed by ERC1767 covers most of the read-only functionality provided by Ethereum nodes through JSON-RPC. Developers switching from JSON-RPC to GraphQL can therefore perform most basic read operations with equivalent functionality.

GraphQL exposes queries corresponding to various RPC methods, and the proposal defines how those calls map to GraphQL operations. The following table summarizes the mappings.

JSON-RPC to GraphQL mappings

RPC method Support GraphQL equivalent
eth_blockNumber Implemented { block { number } }
eth_call Implemented { call(data: { to: "0x...", data: "0x..." }) { data status gasUsed } }
eth_estimateGas Implemented { estimateGas(data: { to: "0x...", data: "0x..." }) }
eth_gasPrice Implemented { gasPrice }
eth_getBalance Implemented { account(address: "0x...") { balance } }
eth_getBlockByHash Implemented { block(hash: "0x...") { ... } }
eth_getBlockByNumber Implemented { block(number: 123) { ... } }
eth_getBlockTransactionCountByHash Implemented { block(hash: "0x...") { transactionCount } }
eth_getBlockTransactionCountByNumber Implemented { block(number: x) { transactionCount } }
eth_getCode Implemented { account(address: "0x...") { code } }
eth_getLogs Implemented { logs(filter: { ... }) { ... } } or { block(...) { logs(filter: { ... }) { ... } } }
eth_getStorageAt Implemented { account(address: "0x...") { storage(slot: "0x...") } }
eth_getTransactionByBlockHashAndIndex Implemented { block(hash: "0x...") { transactionAt(index: x) { ... } } }
eth_getTransactionByBlockNumberAndIndex Implemented { block(number: n) { transactionAt(index: x) { ... } } }
eth_getTransactionByHash Implemented { transaction(hash: "0x...") { ... } }
eth_getTransactionCount Implemented { account(address: "0x...") { transactionCount } }
eth_getTransactionReceipt Implemented { transaction(hash: "0x...") { ... } }
eth_getUncleByBlockHashAndIndex Implemented { block(hash: "0x...") { ommerAt(index: x) { ... } } }
eth_getUncleByBlockNumberAndIndex Implemented { block(number: n) { ommerAt(index: x) { ... } } }
eth_getUncleCountByBlockHash Implemented { block(hash: "0x...") { ommerCount } }
eth_getUncleCountByBlockNumber Implemented { block(number: x) { ommerCount } }
eth_protocolVersion Implemented { protocolVersion }
eth_sendRawTransaction Implemented (Mutation) mutation { sendRawTransaction(data: data) }
eth_syncing Implemented { syncing { ... } }

Unsupported functionality and the reasons for its omission

Some RPC methods are not implemented in the GraphQL schema. The main reasons are as follows.

  • Compiler-related methods (the eth_compile* family) had already been removed from JSON-RPC and are not included in GraphQL.
  • Filter-related methods, such as eth_newFilter, require a future design using GraphQL subscriptions and are intended to be defined in a separate EIP.
  • Account and signing methods (eth_accounts, eth_sign, eth_sendTransaction) are excluded because these operations should be handled by external signing tools and wallets rather than the node.
  • Mining methods, such as eth_mining and eth_submitWork, were not widely used and would benefit little from a GraphQL redesign. Their definition was left to a separate EIP.

References

Nick Johnson (@arachnid), Raúl Kripalani (@raulk), Kris Shinn (@kshinn), "EIP-1767: GraphQL interface to Ethereum node data [DRAFT]," Ethereum Improvement Proposals, no. 1767, February 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1767.

Conclusion

This article examined ERC1767, which proposes a standard GraphQL interface as an alternative to conventional JSON-RPC for more flexible and efficient retrieval of data from Ethereum nodes.

If you have questions, feel free to contact me via direct message on Twitter.

Twitter @cardene777

I also publish articles on other platforms:

https://chaldene.net/