Geth vs Erigon: Deep dive into RPC methods on Ethereum clients

Introduction

The JSON-RPC API is an essential tool for blockchain development as it provides a standardized way to interact with blockchain networks through HTTP or WebSocket connections. At the time of writing, there are seven clients for Ethereum, which is a great achievement in terms of decentralization. However, this can cause a problem for developers because different clients often implement different RPC API sets, leading to confusion.

For example, if your DApp was developed on Erigon and you plan to switch to a new RPC provider running Geth, it's possible that the core API used in your application won't be available on the new node. To avoid compatibility issues, it's important to identify the current client you're using and the available API methods.

This article compares the available RPC APIs for two Ethereum clients, Erigon and Geth, that are available on Chainstack. It is important to note that all tests were performed using Erigon version 2.42 and Geth version 1.11.5, which were the most up-to-date versions as of May 2023. It is possible that there may be changes in the future.

APIs available on Chainstack

At Chainstack, you have the flexibility to deploy different types of nodes that best suit your needs. In general, there are six types of nodes available to choose from.

  • Elastic full node (without debug and trace API), running on Geth
  • Elastic archive node (without debug and trace API), running on Geth
  • Elastic archive node (with debug and trace API), running on Erigon
  • Dedicated full node (with debug and trace API), running on Geth
  • Dedicated archive node (with debug and trace API), running on Erigon
  • Dedicated archive node (with debug and trace API), running on Geth

All elastic Geth nodes come without debug and trace API. The three available API namespaces are net, eth, and web3.

The Erigon node is only available when a user deploys an elastic archive node with debug and trace API. It comes with six available API namespaces: eth, erigon, web3, net, debug, txpool, and trace.

A dedicated node is customizable. If a user wants debug APIs on a Geth node, the only choice is to deploy a dedicated Geth node. It has five available API namespaces: net, eth, web3, txpool, and debug.

If you are interested to learn more about the differences between Geth and Erigon at the architecture level, the guide Ethereum clientsā€”Geth and Erigon will give you a good overview.

Find what client your node is running

With Chainstack, you can easily view this information in the console. However, if you prefer a programmatic approach, consider using the web3_clientVersion method. This RPC method returns the client version as a response.

Discover how to use web3_clientVersion and explore code examples in the Ethereum node API reference.

Standard Ethereum JSON RPC methods available

The Ethereum JSON-RPC is a standard collection of methods that all execution clients must implement. The detailed specification can be found in the Ethereum documentation.

Most of the standard methods are implemented in both Geth and Erigon. However, the Erigon team has either deprecated or not implemented a few of them.

Methods available on both Erigon and Geth

eth_blockNumber eth_syncing eth_gasPrice eth_maxPriorityFeePerGas
eth_feeHistory eth_getBlockTransactionCountByHash eth_getUncleCountByBlockHash eth_getUncleCountByBlockNumber
eth_getTransactionByHash eth_getTransactionByBlockHashAndIndex eth_getTransactionByBlockNumberAndIndex eth_getTransactionReceipt
eth_estimateGas eth_getBalance eth_getCode eth_getTransactionCount
eth_getStorageAt eth_call eth_createAccessList eth_newFilter
eth_newBlockFilter eth_newPendingTransactionFilter eth_getFilterLogs eth_getFilterChanges
eth_uninstallFilter eth_getLogs eth_sendRawTransaction

šŸ“˜

Check the Chainstack Ethereum node API reference to learn how these methods work.

Standard methods available on Geth only

eth_accounts eth_sendTransaction eth_sign eth_signTransaction
eth_mining eth_hashrate eth_getWork eth_submitWork
eth_submitHashrate eth_sign eth_signTransaction eth_getProof
eth_sendTransaction debug_getRawBlock debug_getRawTransaction debug_getRawReceipts
debug_getRawHeader debug_getBadBlocks

The following methods require the client to be associated with a wallet address. They are either deprecated or not implemented by Erigon.

  • eth_accounts
  • eth_sendTransaction
  • eth_sign
  • eth_signTransaction

The following methods are only available in miner mode:

  • eth_mining
  • eth_hashrate
  • eth_getWork
  • eth_submitWork
  • eth_submitHashrate

Non-standard methods available on both Geth and Erigon

In addition to the standard methods, Geth and Erigon implement their own RPC methods. Erigon was originally a fork of Geth, so both clients share the majority of the RPC APIs.

eth_subscribe eth_unsubscribe
web3_clientVersion web3_sha3
txpool_content txpool_status
net_listening net_peerCount net_version
eth_getUncleByBlockHashAndIndex eth_getUncleByBlockNumberAndIndex eth_getRawTransactionByHash
eth_getRawTransactionByBlockHashAndIndex eth_getRawTransactionByBlockNumberAndIndex eth_createAccessList
debug_accountRange debug_getModifiedAccountsByNumber debug_getModifiedAccountsByHash
debug_traceBlockByNumber debug_traceBlockByHash debug_traceTransaction
debug_storageRangeAt debug_traceCall

The eth_subscribe and eth_unsubscribe RPC methods, available exclusively through WebSocket Secure (WSS), allow subscribing to real-time data streams for events like new blocks and pending transactions.

The web3_clientVersion function delivers client information, while web3_sha3 calculates the Keccak hash for a given string.

Utilize txpool_content and txpool_status RPC methods for accessing transactions in the mempool.

RPC methods within the net namespace facilitate the monitoring of a node's P2P status.

Leveraging non-standard methods in the eth namespace is advantageous for obtaining extra information that is not accessible via standard RPC methods but is highly valuable for developers.

The debug methods are designed for advanced users and fulfill a range of purposes, including gathering execution traces for single or multiple transactions.

Non-standard methods available on Geth only

txpool_contentFrom txpool_inspect
debug_backtraceAt debug_blockProfile debug_chaindbCompact debug_chaindbProperty
debug_cpuProfile debug_dbAncient debug_dbAncients debug_dbGet
debug_dumpBlock debug_freeOSMemory debug_freezeClient debug_gcStats
debug_getAccessibleState debug_getBadBlocks debug_getRawBlock debug_getRawHeader
debug_getRawTransaction debug_getRawReceipts debug_goTrace debug_intermediateRoots
debug_memStats debug_mutexProfile debug_preimage debug_printBlock
debug_seedHash debug_setBlockProfileRate debug_setGCPercent debug_setHead
debug_setMutexProfileFraction debug_setTrieFlushInterval debug_stacks debug_standardTraceBlockToFile
debug_standardTraceBadBlockToFile debug_startCPUProfile debug_startGoTrace debug_stopCPUProfile
debug_stopGoTrace debug_traceBadBlock debug_traceBlock debug_traceBlockFromFile
debug_traceChain debug_verbosity debug_vmodule debug_writeBlockProfile
debug_writeMemProfile debug_writeMutexProfile

Geth provides two additional methods in the txpool namespace: txpool_contentFrom and txpool_inspect. txpool_contentFrom retrieves the transactions contained within the txpool, and txpool_inspect lists a textual summary of all transactions.

In addition, Geth exposes many execution-time node tuning through the debug namespace. Some of these methods are destructive to the node itself so it should be used with caution. For example:

  • debug_freezeClient forces a temporary client freeze.
  • debug_setHead sets the current head of the local chain by block number.
  • debug_setTrieFlushInterval configures how often in-memory state tries are persisted to disk. If this value is set toĀ 0, the node will essentially turn into an archive node.

Geth also provides handy trace methods in the debug namespace. If you are interested in how they work, the guide Deep Dive into Ethereum debug_trace APIs may be useful for you.

Non-standard methods available on Erigon only

eth_getBlockReceipts eth_protocolVersion eth_callMany eth_callBundle
debug_accountAt debug_traceCallMany
trace_call trace_callMany trace_rawTransaction trace_replayBlockTransactions
trace_replayTransaction trace_block trace_filter trace_get
trace_transaction
erigon_getHeaderByHash erigon_getBlockReceiptsByBlockHash erigon_getHeaderByNumber erigon_getLogsByHash
erigon_forks erigon_getBlockByTimestamp erigon_BlockNumber erigon_getLatestLogs

Erigon inherits some debug and trace methods from Nethermind and Flashbot, which provides more possibilities than a Geth node.

For example, debug_traceCallMany and trace_callMany are handy methods that don't exist on Geth. These two methods perform the same function, allowing users to send multiple transactions in a batch to oversee their execution. The transactions are executed in sequence, with each transaction depending on the resulting state of the previous transactions.

Last but not least

If you would like to learn more about how these methods work in detail, you can visit Chainstackā€™s API documentation. Additionally, there is a Chainstack Postman collection for you to try out these RPC methods.

Hope this article is helpful for you. If you have any questions, feel free to ping me on my social media or in Chainstack's Telegram or Discord.

Happy coding, cheers!

šŸ“˜

See also

About the author

Wuzhong Zhu

šŸ„‘ Developer Advocate @ Chainstack
šŸ› ļø Happy coding!
Wuzhong | GitHub Wuzhong | Twitter Wuzhong | LinkedIN