library / How to use Solana / Confirmation and retries / HS0095
Processed-level transaction reads
One TypeScript file subscribes to a busy program's logs at processed, takes the first signature, asks getSignatureStatuses about it, then polls getTransaction at confirmed until the body arrives. It prints the elapsed time at each step and closes the socket.
Which calls take processed
getParsedTransaction is the web3.js name for getTransaction with the jsonParsed encoding, so it carries the same limit. The call takes confirmed or finalized and refuses processed. web3.js types that option as Finality, which leaves processed out. @solana/kit 8.6.0 types it as any commitment, so processed compiles there, and the validator refuses it at run time with an error that the method does not support commitment below confirmed.
The symptom people report is a null. They see a signature, call getTransaction a moment later, and get null. The transaction is already processed on the node, and the read at confirmed finds nothing until the cluster has voted on its block.
| Call | What it does with processed |
|---|---|
| getTransaction, getBlock | Refuse it. Confirmed or finalized only. |
| getSignaturesForAddress | Refuses it. Confirmed or finalized only. |
| getSignatureStatuses | Has no commitment option. Each entry reports its own confirmationStatus, and processed is a value it can return. |
| getAccountInfo, getBalance, getSlot | Accept it in the commitment option. |
| logsSubscribe, signatureSubscribe | Accept it in the subscription config. |
Account reads take processed, which is why a balance can change before the transaction that changed it is readable. The transaction body is the one read that waits.
The two-step pattern
Take the first sighting from something that speaks at processed, then fetch the body when the transaction has moved up a level.
- A logsSubscribe on the WebSocket pushes a notification when a transaction that mentions your program is processed. It carries the signature, the logs and the error field, plus the slot in its context.
- getSignatureStatuses takes up to 256 signatures and reports where each one stands. Use it to ask whether the signature from step one has reached confirmed.
- getTransaction at confirmed returns the full transaction once the node has it. Call it once the status says confirmed, or poll it gently until it stops answering null.
The file sets commitment: "confirmed" on the transaction read itself. When a call leaves commitment out, kit fills in confirmed, while a bare JSON-RPC request to the server gets finalized. Naming the level in the call removes the difference.
What can still happen to a processed transaction
A processed transaction is a sighting. The slot it sits in can end up skipped when its fork is dropped. The transaction cannot confirm in that slot, though it can still land in another block while its blockhash is valid, so a dropped fork alone does not prove it will never confirm. Nothing arrives to tell you. A later status call can answer null for a signature that a subscription showed you, and a body read at confirmed keeps answering null until the transaction lands somewhere.
Treat processed as the signal to start watching, and release goods only once the body reads at confirmed. Bound the wait. The blockhash window that the transaction was sent under gives the limit, and Transaction status check walks through how to read it. A watcher that only subscribed, with no send of its own, has no window and picks a fixed number of polls instead, as the file here does.
The code
Install @solana/kit at 8.6.0, export CARBIUM_KEY and run the file with Node 24. It takes an optional program address and defaults to the SPL Token program, which writes logs every few hundred milliseconds.
// HS0095 · Processed-level transaction reads// https://carbium.sh/library/howsolana/processed-level-transaction-reads// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { setTimeout as sleep } from "node:timers/promises";import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, signature,} from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) { console.error("Set CARBIUM_KEY to your Carbium API key."); process.exit(1);}const rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key }, }),);const wsUrl = new URL(process.env.CARBIUM_WS_URL ?? "wss://services.carbium.sh");wsUrl.searchParams.set("api-key", key);// A busy program, so the first log arrives within moments.const program = address(process.argv[2] ?? "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");const t0 = performance.now();const at = () => `${Math.round(performance.now() - t0)} ms`;// kit returns bigint values, which plain JSON.stringify refuses.const show = (v: unknown) => JSON.stringify(v, (_, x) => (typeof x === "bigint" ? x.toString() : x));// Step 1: the first sighting, at processed, from a logs subscription.const ws = new WebSocket(wsUrl);const seen = await new Promise<string>((resolve, reject) => { const timer = setTimeout(() => reject(new Error("no log within 15 s")), 15_000); ws.onerror = () => reject(new Error("WebSocket error")); ws.onopen = () => ws.send( JSON.stringify({ jsonrpc: "2.0", id: 1, method: "logsSubscribe", params: [{ mentions: [program] }, { commitment: "processed" }], }), ); ws.onmessage = (ev) => { const msg = JSON.parse(String(ev.data)); if (msg.error) return reject(new Error(msg.error.message)); if (msg.method !== "logsNotification") return; clearTimeout(timer); ws.onmessage = null; ws.close(); const { value, context } = msg.params.result; console.log(`${at()} logsNotification at processed: slot ${context.slot} err=${show(value.err)}`); resolve(value.signature); };}).catch((e: Error) => { console.error(`${at()} subscription failed: ${e.message}`); process.exit(1);});console.log(`${at()} first signature ${seen}`);// Step 2: ask where it stands. Null, processed or confirmed are all possible here.try { const { value } = await rpc.getSignatureStatuses([signature(seen)]).send(); console.log(`${at()} getSignatureStatuses: ${value[0]?.confirmationStatus ?? "null"}`);} catch (e) { console.log(`${at()} getSignatureStatuses failed: ${(e as Error).message}`);}// Step 3: the full transaction exists at confirmed. Poll until it answers.for (let i = 0; i < 20; i++) { try { const tx = await rpc .getTransaction(signature(seen), { commitment: "confirmed", maxSupportedTransactionVersion: 1, encoding: "json", }) .send(); if (tx) { console.log(`${at()} getTransaction at confirmed: slot ${tx.slot} err=${show(tx.meta?.err ?? null)}`); process.exit(0); } console.log(`${at()} getTransaction: null`); } catch (e) { console.log(`${at()} getTransaction failed: ${(e as Error).message}`); } await sleep(500);}console.log(`${at()} no body after 20 tries; the transaction may sit on a dropped fork`);
run: node main.ts [program-address]
The file stamps every line with the milliseconds since start. The socket opens with the key in the URL query. The handler takes the first notification, drops its own message handler and closes the socket, so the file acts on one message. The transaction poll runs every 500 ms for up to 20 tries. A failing call prints its message and the loop goes on. Errors print through a small helper that turns bigint values into strings, because kit returns some numbers as bigint and plain JSON.stringify throws on them.
Reading the gap
Subtract the time on the log line from the time on the getTransaction line and you have your own gap between processed and a readable body. One run is one sample. Run it five or ten times and read the spread, because the number depends on your distance from the node and on which block your first log came from.
The getSignatureStatuses line can show null, processed or already confirmed. All three are normal. The notification and the status cache are separate paths on the node.
Cost matters when the loop runs long. getTransaction costs 50 cells, and a rate class absorbs a burst of up to 1,024 cells. Twenty polls make 1,000 cells, which fits in one burst. The sustained rate for the method is 0.24 req/s on Free and 1.2 on Dev, so a longer loop on those plans reaches 429 and has to slow down.
The subscription costs credits too. A logsSubscribe by mention opens at 25 credits, and a subscription to all logs opens at 200. After that the socket charges 20 credits per MiB sent. A program as busy as the token program fills a socket quickly, so closing in the first handler keeps the bill to the opening charge and one notification. Notifications already in flight when you close are billed too, and a busy program can put several of them in that first batch.
Where it ends
There is no parsed body at processed. The jsonParsed encoding is an option of getTransaction, and that call waits for confirmed. What the subscription gives you at processed is the logs and the error field, with no accounts, balances or instruction data.
A watcher sees only what it subscribed to. A transaction that never mentions the program you named is invisible to it, and a program that is busy hides the one you care about among thousands of others. Subscribe to the address of the account involved when you know it, and expect a fast stream when you do not.
A subscription also has a cap. Free carries 5 sockets per account, so a script that opens one socket per signature runs out quickly. Open one, filter on your side, and close it when the job is done.
The first sighting can be a failed transaction. The error field in the log notification says so, and a failed transaction still reaches confirmed with its meta.err set. Read meta.err on the body and handle the failure there.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| getTransaction with processed answers an error that the method does not support commitment below confirmed. | The call takes confirmed or finalized. Take the first sighting from a subscription or getSignatureStatuses, then read the body at confirmed. |
| getTransaction answers null long after the signature was seen. | Keep polling to a fixed limit. A processed transaction on a dropped fork may never reach confirmed, so stop after the limit and treat the transaction as unseen. |
| Error -32015 on a transaction you can see in logs. | Add maxSupportedTransactionVersion: 1 and an encoding to the config. It is a v1 transaction, and the option absent or 0 refuses it. |
| "Do not know how to serialize a BigInt" when printing meta.err or other numbers kit returns. | Pass a replacer to JSON.stringify, (_, v) => typeof v === "bigint" ? v.toString() : v, so bigint values print as strings. |
| HTTP 429 from the poll loop. | The loop runs faster than your plan's rate for getTransaction. Poll less often, or stop after fewer tries, and honour the retry-after hint. |
| The socket errors at open or closes before any notification. | Check that the key sits in the api-key query of the socket URL and that the account has a free socket. Free carries 5 sockets across the account. |
Questions
Can I get a parsed transaction at processed?
No. The parsed body comes from getTransaction with the jsonParsed encoding, and that call reads confirmed or finalized. At processed you have the logs from a subscription and the status from getSignatureStatuses.
Why not poll getTransaction from the first sighting?
It answers null until the transaction is confirmed, and each call costs 50 cells. Ask getSignatureStatuses first or poll gently, so that cells go to the one read that returns a body.
Does confirmed follow processed by a fixed delay?
No fixed delay applies. Run the file a few times and read the gap it prints for your own connection.
Would signatureSubscribe fit this job?
It fits when you already hold the signature. It sends one confirmation and then the subscription ends. For a stream of new transactions you need logsSubscribe, which is what the file uses.