JSON-RPC
Use JSON-RPC for account reads, block data, transaction submission, and cluster status.
Before you start
You need a cubestech project with an active node.
- Create a project
Sign in to the dashboard. Create a project and add a Solana node.
- Copy the key
Open the node page. Copy its API key and store the value in
NODE_API_KEY. - Send a request
Call the RPC endpoint with the key in the
x-api-keyheader.
bash
export NODE_API_KEY="YOUR_API_KEY"
curl https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-H "x-api-key: $NODE_API_KEY" \
-d '{"jsonrpc":"2.0","id":"quickstart","method":"getHealth"}'A healthy node returns:
json
{
"jsonrpc": "2.0",
"result": "ok",
"id": "quickstart"
}Read the current slot
javascript
const response = await fetch("https://api.mainnet-beta.solana.com", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.NODE_API_KEY,
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "slot",
method: "getSlot",
params: [{ commitment: "confirmed" }],
}),
})
const body = await response.json()
if (!response.ok || body.error) {
throw new Error(body.error?.message ?? `HTTP ${response.status}`)
}
console.log(body.result)Production checklist
- Set a request timeout.
- Retry
429,500, and503responses with backoff. - Do not retry invalid parameters.
- Keep your key on the server.
- Log the JSON-RPC request ID with each error.
Solana RPC Nodes
See the private JSON-RPC endpoint, supported methods, and Jito capabilities.
RPC overview
Review endpoints, request fields, and commitment levels.
Batching and retries
Reduce request volume and handle temporary failures.