Returns the chain ID of the current network.
Request Format
{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}
Response Format
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1"
}
Parameters
None.
Return Value
- Chain ID (
uint
): Returns the chain ID of the current network in hexadecimal format (with0x
prefix).
Example
Request
{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}
Response (for Mainnet)
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1"
}
Notes
- This method is useful for checking which blockchain network is currently in use.
- Common chain IDs:
- Ethereum Mainnet:
0x1
- Ropsten Testnet:
0x3
- Rinkeby Testnet:
0x4
- Goerli Testnet:
0x5
- Kovan Testnet:
0x2a
- Ethereum Mainnet: