Make your First RPC Request

Conduit RPC endpoints follow the Ethereum JSON-RPC spec. You send a POST request with a JSON body describing the method you want to call, and the node returns the result.

Anatomy of a request

Every request body has four fields:

FieldDescriptionExample
jsonrpcProtocol version — always "2.0""2.0"
methodThe JSON-RPC method to call"eth_blockNumber"
paramsArguments for the method. Use [] if the method takes no arguments[] or ["0xabc...", "latest"]
idAn identifier you assign, echoed back in the response"1"

To call a different method, replace the method value with any supported JSON-RPC method and update params accordingly. See the examples below.

Steps

1

Write a request

The example below fetches the latest block number. It takes no arguments, so params is an empty array.

You’ll need your network’s RPC URL and API key from the Conduit App. Append them to the request URL as shown above.

Request
1curl -s https://[YOUR_RPC_URL]/[YOUR_API_KEY] -X POST \
2-H 'Content-Type: application/json' \
3-d '{"jsonrpc":"2.0","id":"1","method":"eth_blockNumber","params":[]}'
Response
1{"jsonrpc":"2.0","result":"0x430905","id":"1"}

The result is the block number in hex. 0x430905 = block 4,394,245.

2

Add RPC URL and API key

Replace [YOUR_RPC_URL] and [YOUR_API_KEY] with your values. Supported networks and their RPC URLs can be found in the Conduit app, under the Endpoints tab of your API key page.

If you can’t find the RPC URL you’re looking for, contact the chain owner.

3

Send the request

Run the command in your terminal. You should see a JSON response with a result field. If you see an error, double-check your RPC URL and API key.

More examples

Different methods require different params. Here are a few common ones:

Get the ETH balance of an address

params takes an address and a block tag ("latest", "earliest", or a hex block number).

Request
1curl -s https://[YOUR_RPC_URL]/[YOUR_API_KEY] -X POST \
2-H 'Content-Type: application/json' \
3-d '{"jsonrpc":"2.0","id":"1","method":"eth_getBalance","params":["0xYOUR_ADDRESS","latest"]}'
Response
1{"jsonrpc":"2.0","result":"0x1bc16d674ec80000","id":"1"}

Get the current gas price

Request
1curl -s https://[YOUR_RPC_URL]/[YOUR_API_KEY] -X POST \
2-H 'Content-Type: application/json' \
3-d '{"jsonrpc":"2.0","id":"1","method":"eth_gasPrice","params":[]}'
Response
1{"jsonrpc":"2.0","result":"0x3b9aca00","id":"1"}

Get the number of transactions sent from an address

Request
1curl -s https://[YOUR_RPC_URL]/[YOUR_API_KEY] -X POST \
2-H 'Content-Type: application/json' \
3-d '{"jsonrpc":"2.0","id":"1","method":"eth_getTransactionCount","params":["0xYOUR_ADDRESS","latest"]}'
Response
1{"jsonrpc":"2.0","result":"0x4d","id":"1"}

For the full list of supported methods, refer to the Ethereum JSON-RPC spec.