JSON-RPC in Ethereum is the JSON 2.0 message format wallets and apps use to ask a node for data or broadcast signed transactions. Ethereum clients share a core set of methods, so a wallet can use a compatible RPC URL for the network it needs. Chainlist shows EVM networks with their chain IDs and RPC endpoints, making it a place to find an address for these calls.
JSON-RPC means remote procedure calls written as JSON, a text format of named fields. A call expecting a reply includes jsonrpc set to "2.0", a method naming the action, params holding its inputs, and an id identifying the call. The reply repeats that id and contains either a result or an error. The JSON-RPC 2.0 specification defines this shape; Ethereum defines methods such as these:
- eth_chainId: Reads the chain ID as a hexadecimal number. Ethereum mainnet returns "0x1", which is 1 in decimal.
- eth_getBalance: Takes an account address and a block tag such as "latest". It returns the balance in wei, the smallest unit of ether, as hexadecimal.
- eth_sendRawTransaction: Submits a transaction already signed by a wallet. The node broadcasts it and returns a transaction hash.
The first two methods read data. The third sends signed data; the wallet handles signing. Each RPC URL is an HTTP or WebSocket address that receives these JSON-RPC calls.
How to Check an RPC URL's Chain ID
An eth_chainId call checks which chain an HTTP RPC URL serves before you add it to MetaMask. Copy an HTTP or HTTPS endpoint from a network entry on Chainlist, and open a terminal with curl. The URL is the destination; JSON-RPC is the message sent there. A WebSocket URL needs a WebSocket client for this test.
Send this POST request, replacing YOUR_RPC_URL with the copied address:
curl -X POST "YOUR_RPC_URL" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
The empty params array is correct because eth_chainId takes no inputs. A successful reply has the same id and a hexadecimal result, such as {"jsonrpc":"2.0","id":1,"result":"0x1"}. Convert the result from base 16 to decimal: "0x1" becomes 1. The check is complete when that number equals the chain ID listed for the network. Use the URL and matching chain ID together in the wallet's network settings.
This comparison matters because a copied URL may serve a different chain from the one you intended. eth_chainId returns the ID from the endpoint itself. If the numbers differ, choose an endpoint for the intended network and repeat the call. If you receive an error, check the URL and any access key the provider requires.
Related Questions
What Is an RPC URL in MetaMask?
An RPC URL in MetaMask is the address the wallet uses to send JSON-RPC requests to a node. MetaMask also uses the network's chain ID when signing transactions. The URL and chain ID must refer to the same network.
JSON-RPC vs REST API
JSON-RPC names an operation in the request body, usually sent to one endpoint. A REST API commonly uses resource URLs and HTTP methods such as GET or POST. In Ethereum, eth_getBalance is a method name rather than a URL path.
Questions Readers Ask Next
What Is the Difference Between HTTPS and WebSocket RPC Endpoints?
HTTPS handles a request and its response over HTTP. A WebSocket connection stays open so a node can push subscription updates, such as new blocks. Both carry JSON-RPC messages, but the curl command above uses HTTP or HTTPS.
What Does JSON-RPC Error -32601 Mean?
Error -32601 means "Method not found": the node does not recognise or expose the requested method. Check its spelling and whether the endpoint supports it.