Solana RPC for dApps and web apps

Read app state, update screens live, swap in the app and send what the user signs. Keep the key on your server, and run it all on hardware Carbium owns in Switzerland.

Free to start. Dev from $20 a month, with 5 keys.

Four jobs behind every screen

Read, update, swap, send. Carbium has a surface for each, on one key and one host: services.carbium.sh.

  1. getMultipleAccounts

    Read app state

    getMultipleAccounts reads up to 100 accounts a call, 300 on Pro. getProgramAccounts answers from Carbium's own index for provisioned programs, with up to 4 filters and 10,000 accounts an answer.

    RPC reference
  2. wss://services.carbium.sh

    Update screens live

    Over WebSocket, accountSubscribe follows token accounts and the programs the stream carries, logsSubscribe with mentions any address, and signatureSubscribe a send. One socket carries up to 1,000 subscriptions.

    WebSocket reference
  3. quote, then swap

    Swap in the app

    The Carbium Swap API quotes across 17 venue families and builds one unsigned transaction for the connected wallet. The user signs it; Carbium never holds the funds.

    Carbium Swap API
  4. sendTransaction

    Send and confirm

    Price the fee with getPriorityFeeEstimate, simulate when you need the logs, send the signed bytes once and confirm with getSignatureStatuses.

    Sending and simulating

Keep the key on your server

Everything in a web app's bundle is public, and a Carbium key spends your account's credits and rate. Call Carbium from a thin route on your server, and let the browser hold only the user's wallet.

What changes when a call comes from your server or from the browser
From your serverFrom the browser
Where the key livesAn environment variable, sent as x-api-keyIn the page, where any user can read it
HTTPS RPCAny clientCORS is answered: content-type, x-api-key, x-token, authorization and solana-client may be sent
Reading a 429retry-after-ms, the exact waitretry-after only, in whole seconds
WebSocket keyThe x-api-key headerThe subprotocol api-key.YOUR_KEY, out of the URL
A refused socketThe ws package shows the HTTP statusA close with code 1006; the status is hidden
IP allowlistLock the key to your server's addressesUsers call from anywhere, so it cannot help

A thin route, four rules

  • Pass on only the methods your screens call, never everything
  • Send the key in a header, not the URL, so it stays out of logs
  • Cache what every user shares: finalized transactions never change
  • Limit your own route per user: every caller spends your plan

Live keys per account: Free 1, Dev 5, Business 10, Pro 50. Each key has its own scopes, IP allowlist and per-method caps, so a key for the browser's socket can carry only WebSocket and stay apart from the server's.

Keys and how they travel
route.js
// app/api/rpc/route.js: the browser calls you, you call Carbium; the key never ships
const KEY = process.env.CARBIUM_KEY;
const ALLOWED = new Set(["getMultipleAccounts", "getLatestBlockhash", "getPriorityFeeEstimate",
  "sendTransaction", "getSignatureStatuses", "getBlockHeight"]);

export async function POST(req) {
  const { method, params } = await req.json();
  if (!ALLOWED.has(method)) {
    return Response.json({ error: "method not allowed here" }, { status: 400 });
  }
  const res = await fetch("https://services.carbium.sh", {
    method: "POST",
    headers: { "content-type": "application/json", "x-api-key": KEY },
    // "method" before "params": the door refuses the other order
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  });
  return new Response(await res.text(), {
    status: res.status,
    headers: { "content-type": "application/json" },
  });
}
Written from the wire rules in the RPC section of carbium.sh's reference. Bodies are at most 50 KB, and a batch holds at most 100 calls.

From a click to a confirmed transaction

Your server prices the transaction, the user's wallet signs it, and your server sends it once and confirms it by status.

  1. Price it

    Read a blockhash with getLatestBlockhash, then a fee with getPriorityFeeEstimate for the accounts the transaction writes. It answers in micro-lamports per compute unit; the default level is Medium.

  2. The user signs

    The browser builds the transaction with that blockhash and fee, and the user's wallet signs it. Your server never sees the user's key.

  3. Send once

    Send the signed bytes with skipPreflight. To check a transaction first, simulateTransaction runs it without sending: 55 credits, one at a time per key.

  4. Confirm by status

    Poll getSignatureStatuses. Until the block height passes lastValidBlockHeight, sending the same bytes again is safe: one signature cannot run twice.

send.js
// From a click to a confirmed transaction: price it, the user signs, send once, confirm
const KEY = process.env.CARBIUM_KEY; // on your server, never in the bundle
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const rpc = async (method, params) => {
  const res = await fetch("https://services.carbium.sh", { method: "POST",
    headers: { "content-type": "application/json", "x-api-key": KEY },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }) });
  const { result, error } = await res.json();
  if (error) throw new Error(method + " failed: " + error.message);
  return result;
};

// Server: a blockhash and a fee for the accounts the transaction writes
const { value: { blockhash, lastValidBlockHeight } } =
  await rpc("getLatestBlockhash", [{ commitment: "confirmed" }]);
const { priorityFeeEstimate } = await rpc("getPriorityFeeEstimate",
  [{ accountKeys: writable, options: { priorityLevel: "Medium" } }]);

// Browser: build the transaction with them; the user's wallet signs it

// Server: send the signed bytes once, then confirm by status
const send = () => rpc("sendTransaction", [wire, { encoding: "base64", skipPreflight: true, maxRetries: 0 }]);
const sig = await send();
for (;;) {
  const [st] = (await rpc("getSignatureStatuses", [[sig]])).value;
  if (st?.err) throw new Error("failed on chain: " + JSON.stringify(st.err));
  if (st?.confirmationStatus === "confirmed" || st?.confirmationStatus === "finalized") break;
  const height = await rpc("getBlockHeight", [{ commitment: "confirmed" }]);
  if (height > lastValidBlockHeight) throw new Error("expired: build it again");
  await sleep(2000);
  await send().catch(() => {}); // same bytes, same signature: safe to send again
}
Shortened from "Send and confirm" in the RPC section of carbium.sh's reference. getPriorityFeeEstimate is the shape Helius uses; qn_estimatePriorityFees, the shape QuickNode uses, is served too.

Swaps in the app

quote and swap run on the same key and host. swap answers one unsigned transaction for the connected wallet, and each swap pays a 0.05% router fee inside it, already counted in destAmountOut and minAmountOut. Quotes add no fee.

Swap API plans

Which plan for which dApp

A dApp's plan is set by how often its screens read and how often it scans. Free and Dev serve getProgramAccounts and token scans at a floor rate: cache them on your server, or move to Business when every page load scans.

  • Free

    $0a month

    Build and test

    Build against mainnet with 500K credits once and 1 key. Free keys share one request budget with every free caller on the same network.

    Requests a second, account reads
    0.5
    Requests a second, cached reads
    5
    WebSocket connections
    5
    Credits, granted once
    500K
    Live API keys
    1
  • Dev

    Fits a dApp at launch

    $20a month

    A dApp at launch

    15 account reads a second, 10M credits a month and 5 keys, so the server and a browser socket each hold their own.

    Requests a second, account reads
    15
    Requests a second, cached reads
    30
    WebSocket connections
    150
    Credits a month
    10M
    Live API keys
    5
  • Business

    $250a month

    A dApp with steady users

    Program and token scans leave the floor rate, with 50 account reads a second and 50M credits a month.

    Requests a second, account reads
    50
    Requests a second, cached reads
    100
    WebSocket connections
    250
    Credits a month
    50M
    Live API keys
    10
  • Pro

    $500a month

    A large dApp

    400 account reads a second, 500 cached reads and 200M credits a month.

    Requests a second, account reads
    400
    Requests a second, cached reads
    500
    WebSocket connections
    1,000
    Credits a month
    200M
    Live API keys
    50

Plans are bought on carbium.sh. Prices are in US dollars; card through Stripe is the main way to pay. You can also pay in USDC or USDT from your own wallet. In-app swaps run on the Carbium Swap API, on the same key: add the Quote module on carbium.sh, which starts on a Free plan.

What breaks in a dApp

Web apps fail in front of users for a few familiar reasons: a key in the bundle, a send repeated, a scan too wide.

  • Keep the key off the page

    A key in the bundle is a key every user holds. Call Carbium from your server, and lock that key to your server's addresses.

    API key security
  • Never auto-retry a send

    Check getSignatureStatuses first. To resend, send the same signed bytes until the block height passes lastValidBlockHeight.

    Blockhash expiry recovery
  • Narrow every scan

    A scan answers at most 10,000 accounts, with no paging. Use up to 4 filters, at most one dataSize, and base64 or jsonParsed: base58 fails on accounts over 128 bytes.

    Scans in the RPC reference
  • Ask for version 1

    Send maxSupportedTransactionVersion 1 on getTransaction and getBlock. Mainnet carries version-1 transactions, and without it they answer -32015.

    History methods
  • Subscribe again after a reconnect

    Subscription ids do not carry over to a new socket, and nothing is replayed. Subscribe again, then re-read state over HTTPS.

    WebSocket reference
  • Pick the commitment

    Show state at confirmed, and tell users a send is final only when it is. Processed can still roll back.

    Commitment levels

Questions

carbium.sh's reference covers every method and limit. For anything else, talk to the team on the Carbium Discord.

Technical reference, on carbium.sh

Can I call Carbium RPC from the browser?

Yes. The endpoint answers the CORS preflight and accepts the content-type, x-api-key, x-token, authorization and solana-client headers. But a key in the page can be read by every user, and it spends your account's credits and rate. Call Carbium from your server, or give the browser a key of its own with only the planes it needs.

Keys and how they travel

How do I keep my Solana RPC key out of the frontend?

Put it in a server route that the browser calls, read it from the environment and send it as the x-api-key header. Pass on only the methods your screens use, and lock the key to your server's addresses with an IP allowlist of up to 16 addresses or CIDRs.

API key security

How does a browser open a WebSocket with an API key?

A browser cannot set headers on a WebSocket, so pass the key as the subprotocol: api-key. followed by the key. It keeps the key out of the URL. A refused handshake shows in the browser only as a close with code 1006, so test the key from a server first.

WebSocket reference

Does Carbium serve the DAS API (getAsset)?

Yes. Carbium RPC serves ten DAS methods on every plan, getAsset, getAssetsByOwner and searchAssets among them. Compressed NFTs, their proofs, the off-chain JSON and prices are not served, so take token logos from Carbium Token Data.

Solana DAS API on Carbium RPC

Which Solana RPC suits NFT and DeFi dApps?

One that serves the calls your screens make, measured from your own region. On Carbium, getProgramAccounts answers from its own index for provisioned programs: SPL Token, Token-2022, Raydium, Orca Whirlpool, Meteora, Phoenix and others. Metaplex Token Metadata and Metaplex Core accounts stream over programSubscribe, and the DAS API answers what a wallet holds and what an NFT is.

Provisioned programs

Can getProgramAccounts be paginated?

No. An answer holds at most 10,000 accounts, there is no pagination cursor, and getProgramAccountsV2 is not served. Narrow the scan with up to 4 filters, at most one of them dataSize and the rest memcmp, or read known accounts with getMultipleAccounts.

Scans in the RPC reference

How do I estimate priority fees on Solana?

Call getPriorityFeeEstimate, in the shape Helius uses, with the accounts the transaction writes. It answers in micro-lamports per compute unit, with levels from Min to UnsafeMax, and recommended set to true returns High. Both it and qn_estimatePriorityFees come from getRecentPrioritizationFees over up to 150 slots.

Priority fee methods

Which Carbium plan suits a dApp?

Build on Free. Dev ($20 a month) fits a dApp at launch: 15 account reads a second, 10M credits a month and 5 keys. Scans run at a floor rate on Free and Dev, so cache them on your server; Business ($250) serves them at full rate with 50M credits. Plans are bought on carbium.sh. Prices are in US dollars; card through Stripe is the main way to pay. You can also pay in USDC or USDT from your own wallet.

Compare Carbium RPC plans

Build the dApp free, then launch on Dev

Build and test on the Free plan. At launch, Dev gives 15 account reads a second, 150 WebSocket connections and 10M credits a month, with 5 keys. In-app swaps run on the same key.

Carbium Swap API