Code examples
Copy-paste snippets for curl, ethers.js, web3.js, web3.py, and the Beacon REST API.
All examples use Hoodi — swap the subdomain for mainnet or
sepolia as needed. Replace YOUR_API_KEY with your
key.
curl
With the header (preferred):
curl https://hoodi.rpc.ethnodeops.xyz \
-H "X-API-Key: YOUR_API_KEY" \
-X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' With the key in the URL path:
curl https://hoodi.rpc.ethnodeops.xyz/YOUR_API_KEY \
-X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","latest"],"id":1}' ethers.js (v6)
Pass the key in the URL path:
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider(
"https://hoodi.rpc.ethnodeops.xyz/YOUR_API_KEY"
);
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber); Or send the key as a header using a FetchRequest:
import { ethers, FetchRequest } from "ethers";
const req = new FetchRequest("https://hoodi.rpc.ethnodeops.xyz");
req.setHeader("X-API-Key", "YOUR_API_KEY");
const provider = new ethers.JsonRpcProvider(req);
console.log(await provider.getBlockNumber()); web3.js
import { Web3 } from "web3";
const web3 = new Web3("https://hoodi.rpc.ethnodeops.xyz/YOUR_API_KEY");
const blockNumber = await web3.eth.getBlockNumber();
console.log(blockNumber); web3.py
Key in the URL path:
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://hoodi.rpc.ethnodeops.xyz/YOUR_API_KEY"))
print(w3.eth.block_number) Or with the header:
from web3 import Web3
w3 = Web3(
Web3.HTTPProvider(
"https://hoodi.rpc.ethnodeops.xyz",
request_kwargs={"headers": {"X-API-Key": "YOUR_API_KEY"}},
)
)
print(w3.eth.block_number) Consensus Layer (Beacon REST API)
The Consensus Layer exposes the standard
Beacon Node REST API.
Use the ebeacon subdomain.
Node version (header auth):
curl https://hoodi.ebeacon.ethnodeops.xyz/eth/v1/node/version \
-H "X-API-Key: YOUR_API_KEY" Genesis details (key in URL path):
curl https://hoodi.ebeacon.ethnodeops.xyz/YOUR_API_KEY/eth/v1/beacon/genesis Finality checkpoints for the head:
curl https://hoodi.ebeacon.ethnodeops.xyz/eth/v1/beacon/states/head/finality_checkpoints \
-H "X-API-Key: YOUR_API_KEY" Targeting a specific client
Prepend the client name to the network. For example, query Geth directly on Mainnet:
curl https://geth.mainnet.rpc.ethnodeops.xyz \
-H "X-API-Key: YOUR_API_KEY" \
-X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' See Supported clients for the full list and routing rules.