RPC examples
Copy-paste Solana JSON-RPC examples for getBalance, getAccountInfo, and getTransaction in TypeScript, Rust, Python, and curl.
// updated 2026-08-26
Copy-paste working examples for the four most common languages.
Prerequisites
- An active Supanode Bundle subscription or free trial. Don't have one? Contact @supanode_tgs on Telegram.
- Your access token, issued on provisioning - see Authentication.
- The RPC endpoint URL (default:
https://fra.sol.supanode.xyz:8899).
The token goes in the x-token header. Authorization: Bearer, x-api-key, and the api-key / api_key query parameters are accepted too - useful for clients that cannot set headers. Prefer a header: a query string ends up in logs.
Test connection
Before writing code, verify your token and endpoint:
curl https://fra.sol.supanode.xyz:8899 \
-H "Content-Type: application/json" \
-H "x-token: sk_your_token_here" \
-d '{"jsonrpc":"2.0","id":1,"method":"getSlot"}'
A JSON response with a result field containing a slot number means the connection works. 401 means the token is missing or wrong.
Get account info
Fetches account balance and owner for a given address.
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://fra.sol.supanode.xyz:8899", {
commitment: "confirmed",
httpHeaders: { "x-token": process.env.SUPANODE_TOKEN! },
});
const accountAddress = new PublicKey("YOUR_ACCOUNT_PUBKEY");
const accountInfo = await connection.getAccountInfo(accountAddress);
console.log("Balance (lamports):", accountInfo?.lamports);
console.log("Owner:", accountInfo?.owner.toBase58());
Get recent transactions for an address
curl https://fra.sol.supanode.xyz:8899 \
-H "Content-Type: application/json" \
-H "x-token: sk_your_token_here" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getSignaturesForAddress",
"params": ["YOUR_ACCOUNT_PUBKEY", {"limit": 10}]
}'
getSignaturesForAddress returns up to 1,000 signatures per call. Follow up with individual getTransaction calls for each signature you want details on.
Production tips
-
Reuse connections. HTTP keep-alive is on by default in most clients. Don't create a new client per request.
-
Keep the token out of your repository. Read it from an environment variable or a secrets manager. Anyone holding it spends your plan's quota - see Authentication.
-
Backoff on
429. Rate-limit responses include aRetry-Afterheader where possible. Implement exponential backoff starting at 1 second. -
Choose commitment carefully.
confirmedis the safe default.finalizedadds ~13 seconds of latency. -
Batch when you can.
getMultipleAccounts(up to 100 accounts per call) is much cheaper than 100 individualgetAccountInfocalls. -
Don't poll for live data. If you find yourself running a tight
getAccountInfoloop, switch to WebSocketaccountSubscribeor gRPCaccountsstream.