11f7c4
How to test an Ethereum RPC endpoint with curl and identify its chain
Test an Ethereum RPC endpoint with curl by sending a JSON-RPC POST. Read eth_chainId for the returned chain ID, then use eth_blockNumber as a second check.
The Hashbeam Desk··4 min read

To test an Ethereum RPC endpoint with curl, send it a JSON-RPC POST request and inspect the response body. Ethereum RPC methods travel in JSON-RPC requests, so a successful response can show whether the endpoint responds and which chain it reports.
Have the endpoint URL and curl available, along with access to a JSON-RPC HTTP endpoint. Start with eth_chainId, a read-only method that returns the chain ID as a hexadecimal value. If you need a candidate endpoint, Chainlist lists EVM networks and their RPC endpoints. Its network details can help you find an endpoint to test; the choice between running a node and using a provider is covered in Chainlist’s node-versus-provider choice.
How do you send an Ethereum JSON-RPC request with curl?
Send a POST request to the endpoint URL with a JSON content type and a body containing the JSON-RPC version, method, params, and id. For instance, replace YOUR_RPC_ENDPOINT in this curl command with the endpoint URL:
curl -X POST "YOUR_RPC_ENDPOINT" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
The request body asks the endpoint to run eth_chainId. The empty params array means this call supplies no method parameters. The id value labels the request so the response can be matched to it. It is not a chain ID or a transaction ID.
Think of the id as a ticket number on a request and its reply: it helps match the two. The analogy stops there. The id is just a JSON-RPC label; it does not identify the network or a transaction.
A response might contain "result":"0x1". That result is a hexadecimal chain ID. The endpoint is reporting chain ID 1; the number in the request’s id field has no bearing on that value. Compare the returned chain ID with the network you intended to reach.
Shell quoting varies by operating system. If the command fails before making a request, check how your shell handles the single quotes around the JSON body and the quotation marks around the URL. Some shells require a different quoting arrangement, while the JSON-RPC fields remain the same.
What do eth_chainId and eth_blockNumber return?
eth_chainId returns the endpoint’s chain ID as a hexadecimal value, while eth_blockNumber returns the latest block number the endpoint reports, also in hexadecimal. The second call gives you another read-only response to inspect.
To try it, keep the URL and headers, and change the request body’s method to eth_blockNumber: {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}. The response’s result might look like "0x123abc". That is a hexadecimal block number, not a chain ID. The reported number can move as the endpoint reports newer blocks.
Use both calls to check separate details: eth_chainId identifies the chain the endpoint reports, and eth_blockNumber gives its reported latest block. For a repeatable comparison, keep the method and params fixed and change the id when you want to label a new request. A different id helps distinguish replies; it does not change what either method asks the endpoint to return.
Read the response body as well as curl’s outcome. A connection failure or HTTP problem means the request may not have reached a usable endpoint, or the HTTP exchange did not complete as expected. A JSON-RPC error in the response body means the endpoint returned an RPC-level error; an HTTP request can complete and still contain that error. Look for error rather than result, then use the returned error details to investigate.
Related questions
How do you use curl with Ethereum RPC eth_blockNumber?
Send eth_blockNumber with an empty params array in a JSON-RPC POST request. Read the hexadecimal value in result as the latest block number the endpoint reports.
How do you troubleshoot a curl Ethereum RPC endpoint error?
Inspect the response body for a JSON-RPC error; a completed HTTP request can still return an RPC error. To make the check easier to repeat and compare, save the endpoint URL and reuse the same curl command, changing only the method when you move from eth_chainId to eth_blockNumber. That saves you from accidentally comparing different request bodies.