Solana RPC and APIs for wallets

Show balances and history, watch every address live, swap inside the wallet and send with a fair priority fee. One key and one host, on hardware Carbium owns in Switzerland.

Free to start. Dev from $20 a month.

Four jobs every wallet does

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

  1. getTokenAccountsByOwner

    Show the balances

    SOL with getBalance, every SPL and Token-2022 holding with getTokenAccountsByOwner, served from Carbium's own token index, and USD prices for up to 64 mints a call with prices.

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

    Watch every address

    Over WebSocket, logsSubscribe with mentions tells you when an address is in a transaction, and signatureSubscribe when a send lands. One socket carries up to 1,000 subscriptions.

    WebSocket reference
  3. quote, then swap

    Swap inside the wallet

    The Carbium Swap API quotes across 15 venue families and builds one unsigned transaction for the user's public key. The user signs it in the wallet; Carbium never holds the funds.

    Carbium Swap API
  4. sendTransaction

    Send and confirm

    Price the fee with getPriorityFeeEstimate or qn_estimatePriorityFees, in the shapes Helius and QuickNode use, send the signed bytes and confirm with getSignatureStatuses.

    Sending and simulating

Watch addresses, not accounts

A plain SOL wallet is a system account, and its balance changes do not arrive as account updates. Follow the address in transactions instead, then read the balance.

Which subscription for which wallet job
Wallet jobSubscribe toThen
An address receives or spendslogsSubscribe with mentions: [address]Read getBalance, and the token balances from the transaction
A send landssignatureSubscribeNothing: it ends itself after its one notification
A token account changesaccountSubscribe on that token accountApply the balance from the notification

After every reconnect

  • Open one socket and reuse it: it carries up to 1,000 subscriptions
  • Subscribe again: subscription ids do not survive a reconnect
  • Re-read balances over HTTPS: nothing is replayed
  • Answer pings, and stay inside your plan's connection cap

Per account: Free opens 5 WebSocket connections and 10 subscriptions, Dev 150 and 5,000, Business 250 and 20,000, Pro 1,000 and 50,000.

WebSocket rules and limits
watch.ts
// Watch a wallet from your backend: one socket, the address in transactions
import WebSocket from "ws";

const KEY = process.env.CARBIUM_KEY;
const rpc = (method, params) => 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 }) }).then((r) => r.json());

const ws = new WebSocket("wss://services.carbium.sh/?api-key=" + KEY);
ws.on("open", () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1,
  method: "logsSubscribe", params: [{ mentions: [WALLET] }, { commitment: "confirmed" }] })));

ws.on("message", async (data) => {
  const msg = JSON.parse(data);
  if (msg.method !== "logsNotification") return;
  const { signature, err } = msg.params.result.value;
  if (err) return;
  const balance = await rpc("getBalance", [WALLET, { commitment: "confirmed" }]);
  const tx = await rpc("getTransaction", [signature,
    { commitment: "confirmed", maxSupportedTransactionVersion: 1 }]);
  update(WALLET, balance.result.value, tx.result?.meta?.postTokenBalances);
});
Written from the WebSocket and RPC sections of carbium.sh's reference. getTransaction needs maxSupportedTransactionVersion 1: mainnet carries version-1 transactions.

A swap inside the wallet

The quote shows the user what they get, the swap call builds the transaction, the user signs it, and your backend sends it once.

  1. Quote and show

    Call quote with src_mint, dst_mint, amount_in and slippage_bps. Show destAmountOut and minAmountOut as they come: amounts are strings in base units, so parse them with BigInt.

  2. Build for the user

    Within 30 seconds, call swap with the quoteId and the user's public key as user_pubkey. It answers one unsigned transaction.

  3. Sign in the wallet

    The user signs as user_pubkey, and nothing in the transaction is changed. The key never leaves the wallet.

  4. Send once, confirm by status

    Send with skipPreflight and confirm with getSignatureStatuses. On an expired quote or a slippage failure (Custom:6004), quote again.

swap.ts
// Swap inside the wallet: quote, build for the user, the user signs, send, confirm
const KEY = process.env.CARBIUM_KEY; // on your backend, never in the app
const call = 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;
};

// Backend: the quote to show, then the transaction for this user
const quote = await call("quote", { src_mint: SOL, dst_mint: USDC,
  amount_in: "10000000", slippage_bps: 50 });
show(quote.destAmountOut, quote.minAmountOut, quote.routePlan);
const { transaction } = await call("swap", { quote_id: quote.quoteId,
  user_pubkey: user.publicKey.toBase58() });

// Wallet: the user signs; nothing in the transaction is changed
const tx = VersionedTransaction.deserialize(Buffer.from(transaction, "base64"));
const signed = await user.signTransaction(tx);

// Backend: send once, then confirm by status
const sig = await call("sendTransaction", [Buffer.from(signed.serialize()).toString("base64"),
  { encoding: "base64", skipPreflight: true, maxRetries: 0 }]);
const { value } = await call("getSignatureStatuses", [[sig]]);
Shortened from the quote and swap sections of carbium.sh's reference. One key covers the quote, the swap and the send.

The router fee

Each swap pays a 0.05% router fee inside the transaction the user signs. It is already counted in destAmountOut and minAmountOut, so the wallet shows those figures as they are. Quotes add no fee.

Swap API plans

Which plan for which wallet

A wallet's plan is set by how many addresses it follows at once and how often it reads. Move up when subscriptions or reads run short.

  • Free

    $0a month

    Build and test

    Build the wallet against mainnet: 5 connections and 10 subscriptions, 500K credits once.

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

    $20a month

    A wallet in beta

    150 connections and 5,000 subscriptions for the first users' addresses.

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

    Fits a wallet with users

    $250a month

    A wallet with users

    20,000 subscriptions to follow users' addresses and 100 cached reads a second.

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

    $500a month

    A large wallet

    50,000 subscriptions over 1,000 connections and 500 cached reads a second.

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

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 wallet

Wallets fail in front of users, usually for the same few reasons: a send repeated, a socket that came back quiet, a key shipped in the app.

  • Never auto-retry a send

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

    Blockhash expiry recovery
  • 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
  • Keep the key out of the app

    A wallet ships to its users, and so would a key inside it. Call Carbium from your backend; a key can carry an IP allowlist.

    API key security
  • Parse amounts with BigInt

    Quote amounts are decimal strings in base units. A JavaScript number loses digits above 2^53.

    Quote reference
  • Know the history window

    getSignaturesForAddress pages come from Carbium's address index, which keeps up to 30 days. getTransaction ends at the ledger floor: read it with getFirstAvailableBlock.

    History methods
  • Pick the commitment

    Show balances 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

What is a Solana wallet API?

The calls a wallet backend makes: balances, token holdings, history, live updates, priority fees, swaps and sends. On Carbium they are all on services.carbium.sh, with one key: JSON-RPC over HTTPS, subscriptions over WebSocket and the Carbium Swap API as JSON-RPC methods.

How do I get every token balance in a Solana wallet?

Call getTokenAccountsByOwner with the owner's address, a programId filter (SPL Token or Token-2022) and jsonParsed encoding. Carbium serves it from its own token index. An answer holds at most 10,000 accounts, and token scans are billed by rows: 205 credits for up to 20 rows, then 10 per row.

Scans in the RPC reference

How do I get a Solana wallet's transaction history?

getSignaturesForAddress pages come from Carbium's address index, which keeps up to 30 days. getTransactionsForAddress, in the shape Helius uses, pages signatures or full transactions with filters for status, slot, time and token transfers. getTransaction reaches back to the RPC node's ledger floor.

History methods

Why does accountSubscribe stay silent for my SOL wallet?

A plain SOL wallet is a system account, and its balance changes do not stream as account updates. Subscribe with logsSubscribe and mentions set to the address, and read getBalance when a notification arrives.

WebSocket reference

Can a wallet offer swaps without holding user funds?

Yes. The Carbium Swap API returns an unsigned transaction built for the user's public key. The user signs it in the wallet, and the swap settles on chain in that one transaction. Carbium never holds the funds or the keys.

Carbium Swap API

Does Carbium support getPriorityFeeEstimate?

Yes, in the shape Helius uses, and qn_estimatePriorityFees in the shape QuickNode uses. Both are derived from getRecentPrioritizationFees over up to 150 slots and answer in micro-lamports per compute unit.

Priority fee methods

Can I get USD prices for a whole portfolio?

Yes. The prices method takes up to 64 mints a call and answers each one's USD price and liquidity. The table is cached for 30 seconds, so poll it on a timer rather than once per screen. Each call counts as one quote on the Swap API plan.

The prices method

Does Carbium serve the DAS API for NFTs?

No. getAsset, getAssetsByOwner and the other DAS methods are not served. Read holdings with getTokenAccountsByOwner, and take token names, symbols and logos from Carbium Token Data.

Carbium Token Data reference

Build the wallet free, then follow every user on Business

Build and test on the Free plan. When users arrive, Business follows up to 20,000 addresses over 250 connections with 50M credits a month. In-app swaps run on the same key.

Carbium Swap API