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 covers EIP695, a proposal to add the eth_chainId method to Ethereum's JSON-RPC interface.
This article translates, summarizes, and supplements the material below.
I have also covered various other EIPs.
Overview
eth_chainId is an Ethereum JSON-RPC method used to retrieve the identifier (CHAIN_ID) of the blockchain to which a client is currently connected. The CHAIN_ID was introduced to prevent signed transactions from being executed again on a different chain (a replay attack). It was proposed by EIP155 (Ethereum Improvement Proposal 155).
For more information about EIP155, see the following article.
[EIP155] How Ethereum Prevents Replay Attacks
When the eth_chainId method is called, it returns a hexadecimal string representing the CHAIN_ID of the connected Ethereum network. For example, Ethereum mainnet's CHAIN_ID is 0x1, and the historical Ropsten testnet's is 0x3.
The CHAIN_ID is important when executing smart contracts and signing transactions because it identifies the target blockchain network. Developers can also use this method to verify that their applications or services are connected to the intended Ethereum network.
Motivation
Ethereum provides an RPC (remote procedure call) method called net_version, which returns the ID of the connected Ethereum network. However, the network ID alone cannot fully identify the actual blockchain to which a client is connected.
Network IDs and chain IDs are different concepts. Network IDs are primarily used for peer-to-peer connections between nodes, while chain IDs are used in transaction signing and were introduced to prevent replay attacks. Consequently, different blockchains can share the same network ID.
The problem identified by the proposal is that the Ethereum RPC interface at the time lacked a direct way to query the chain ID, leaving clients unable to verify through RPC which blockchain they were actually connected to. For applications and services that work with multiple Ethereum-based networks, this means important information for verifying the correct network is missing. A new RPC method for querying the chain ID is therefore needed.
Specification
eth_chainId retrieves the currently configured chain ID through Ethereum's JSON-RPC interface. The chain ID is the value used for replay-protected transaction signing introduced by EIP155.
The chain ID returned by this method should always correspond to the information at the latest known head block. This allows callers to use the returned information when signing transactions intended to build on the latest head block.
If the latest known head block does not specify a chain ID, the client should behave as though the eth_chainId method is unsupported and return an appropriate error.
This method requires no parameters and returns the current chain ID in hexadecimal. For example, invoking the method with a command such as curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":83}' returns {"id": 83, "jsonrpc": "2.0", "result": "0x3d"}. In this case, "result": "0x3d" indicates a chain ID of 61 (the hexadecimal value 0x3d is 61 in decimal).
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":83}'
// Result
{
"id": 83,
"jsonrpc": "2.0",
"result": "0x3d" // 61
}Additional Considerations
Ethereum (ETH) and Ethereum Classic (ETC) are separate blockchains that originally shared the same chain. The fork in 2016 created these two distinct networks. Because they have similar structures and use the same communication protocols, an ETH client may accidentally connect to an ETC RPC endpoint, or vice versa.
Without the proposed method, clients may discover that they are connected to the wrong network only when signing a transaction or fetching a transaction known to have been signed with a particular chain ID. ETH and ETC use different chain IDs, so attempting to sign a transaction for the wrong network can lead to an error.
This situation creates problems for application developers supporting multiple chains, such as developers of wallet services like MetaMask. They must continually verify that users have not inadvertently connected to the wrong network and ensure that the intended network is selected. This requires additional checks and logic, increasing development complexity.
Security
The proposal describes best practices for accurately identifying the network when communicating with an Ethereum blockchain. Specifically, it recommends using eth_chainId in preference to net_version.
Importance of eth_chainId
The eth_chainId method provides the chain ID introduced by EIP155 to prevent replay attacks. This ID ensures that a transaction is specific to a particular chain and prevents the transaction from being executed again on another chain (a replay attack). Using eth_chainId therefore allows developers and users to identify the blockchain with which they are communicating accurately.
Limitations of net_version
The net_version method provides the network ID, which differs from the chain ID and is not directly related to replay protection. Different chains can also use the same network ID, making it unsuitable for accurately distinguishing networks.
Guidance for Implementers
Implementers of eth_chainId, such as blockchain node developers and wallet service providers, are encouraged to implement the method correctly and promote its use. eth_chainId plays an important security role because consumers rely on it to identify the chain with which they are communicating.
Using eth_chainId is recommended because it plays an important role in chain identification and offers security benefits. This gives developers and users confidence that they are communicating with their intended blockchain.
Reference
The proposal addresses encoding of QUANTITY return values in Ethereum's JSON RPC interface. It follows standard JSON RPC hexadecimal value encoding as documented in the Ethereum Wiki.
A QUANTITY is a data type for representing numerical values and is frequently used in Ethereum RPC communications. Following these encoding rules preserves data integrity and compatibility when communicating with Ethereum networks.
Hexadecimal value encoding represents numbers in hexadecimal notation (using 0x as a prefix). For example, the decimal number 16 is represented in hexadecimal as 0x10. This format is used for many parameters and return values, including Ethereum transactions, smart contract addresses, gas prices, and transaction nonces.
The Ethereum Wiki specifies detailed rules for this encoding scheme. Ethereum developers and users must follow them when encoding or decoding data to ensure compatibility and consistency across different systems and applications.
Citation
Isaac Ardis isaac.ardis@gmail.com, Wei Tang (@sorpaas), Fan Torchz (@tcz001), Erik Marks (@rekmarks), "EIP-695: Create eth_chainId method for JSON-RPC," Ethereum Improvement Proposals, no. 695, August 2017. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-695.
Closing Remarks
This article covered EIP695, a proposal to add the eth_chainId method to Ethereum's JSON-RPC interface. I hope it was helpful.
If you have any questions, feel free to reach out via Twitter DM.
I also publish on other platforms, which you can explore below.


