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.
getTokenAccountsByOwnerShow 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 referencewss://services.carbium.shWatch 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 referencequote, then swapSwap 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 APIsendTransactionSend 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.
7xKX…9fQ2getBalance$1,259.20$1,284.20
- SOL4.21$403.00
- USDC787.50812.50$787.50$812.50
- USDT68.70$68.70
sendTransactionquote, then swaplogsSubscribe| Wallet job | Subscribe to | Then |
|---|---|---|
| An address receives or spends | logsSubscribe with mentions: [address] | Read getBalance, and the token balances from the transaction |
| A send lands | signatureSubscribe | Nothing: it ends itself after its one notification |
| A token account changes | accountSubscribe on that token account | Apply 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 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);
});
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.
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.
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.
Sign in the wallet
The user signs as user_pubkey, and nothing in the transaction is changed. The key never leaves the wallet.
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 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]]);
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 plansWhich 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 recoverySubscribe 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 referenceKeep 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 securityParse amounts with BigInt
Quote amounts are decimal strings in base units. A JavaScript number loses digits above 2^53.
Quote referenceKnow 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 methodsPick the commitment
Show balances at confirmed, and tell users a send is final only when it is. Processed can still roll back.
Commitment levels
Build from the references
Three references a wallet team keeps open: the socket rules, the swap call and token metadata.
WebSocket subscriptions
Every subscription carbium.sh serves, its cost, its limits and what to do after a disconnect.
Quote and swap
Params, results, the router fee and every error with the action to take, for in-app swaps.
Carbium Token Data
Token names, symbols and logos for the wallet's lists, with ranked search and batch lookups.
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.shWhat 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 referenceHow 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 methodsWhy 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 referenceCan 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 APIDoes 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 methodsCan 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 methodDoes 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 referenceMore use cases
The same key and host, put to other jobs.
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