services
Get a key

library / Blockchain ideas / BI0003

Transaction explainer

A command that takes a signature or an address and prints each transaction as plain lines: status, fee, who gained or lost SOL and tokens, and what each instruction did. One file, read-only, on Carbium's RPC with one key.

By Carbium · Developer tools · BI0003 · updated 2026-11-22

01

Who uses it

A support desk gets a signature and the question "where did my money go?" The raw transaction holds the answer, but only a person who can read account indexes and balance arrays gets it out. The explainer turns it into a short block of lines an agent can paste into a reply.

A wallet or app team wants the same sentences inside its own activity feed: what the fee was, who gained or lost which token, which program was called. Each line traces to one field of the reply, so the logic moves into your code without changes.

A hackathon team can demo it with nothing but a key. Point it at the address of any busy program and it explains that program's newest transactions on stage.

02

What it prints

Each transaction becomes a block of lines. Every line comes from one field of one getTransaction reply, so a reader can check any claim against the raw data.

LineWhere it comes fromExample
Status, slot, timemeta.err, slot, blockTimesucceeded in slot 412345678 at 2026-11-22T09:14:03.000Z
Fee and payermeta.fee in lamports, the first account key, computeUnitsConsumedfee 0.000005 SOL paid by 7xK...abc, 450 compute units
SOL changepost balance minus pre balance for each account that moved, to nine decimalsSOL 7xK...abc -1.500005000
Token changethe pre and post token balance lists, in the token's own decimalstoken 9wF...def +25.000000 of mint EPj...
Instructionthe parsed instruction: program name, action and its fieldsspl-memo: gm
Failure logsthe last three of meta.logMessages, only when err is setthe program's own message and its custom error code

The fee payer's SOL line includes the fee, so a plain transfer shows the sender down by the amount plus the fee. A token line is built the same way from the token balance lists. It starts with the owner wallet, or the token account when the record has no owner, and ends with the mint address.

Instructions come back parsed because the call asks for jsonParsed. The node names the program and the action for programs it can decode, such as the System program, SPL Token, the associated token account program and Memo. Any other program prints as its id with an account count, except Compute Budget, which the node does not decode and the code names from its own small table (NAMES) as compute-budget.

03

The build

The explainer is one file that needs @solana/kit and what Node 24 ships. It is read-only and never holds a private key or sends a transaction.

  1. Read CARBIUM_KEY and exit with a message if it is unset. Build one RPC client for https://services.carbium.sh and send the key in the x-api-key header.
  2. Take the first argument. A string of 80 characters or more is a signature, and a shorter one is an address.
  3. For an address, call getSignaturesForAddress with a limit (the second argument, default 2) and read the signatures from the rows.
  4. For each signature, call getTransaction at confirmed commitment with jsonParsed encoding and maxSupportedTransactionVersion: 1. Mainnet carries version 1 transactions, so legacy, version 0 and version 1 are all served. A transaction of a newer version is refused with an error that names the version it needs.
  5. Print the status, slot and block time, then the fee, the fee payer and the compute units.
  6. Print one line per changed SOL balance, one per changed token balance and one per instruction, plus the last three log lines when the transaction failed.
main.ts
// BI0003 · Transaction explainer// https://carbium.sh/library/blockchainideas/transaction-explainer// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, signature } from "@solana/kit";const die = (m: string): never => (console.error(m), process.exit(1));const key = process.env.CARBIUM_KEY ?? die("Set CARBIUM_KEY to your Carbium API key.");const target = process.argv[2] ?? die("Usage: node main.ts <signature or address> [count]");const count = Number(process.argv[3] ?? 2);const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);type Ix = { program?: string; programId: string; parsed?: unknown; accounts?: unknown[] };type Bal = { accountIndex: number; mint: string; owner?: string; uiTokenAmount: { amount: string; decimals: number } };type Num = bigint | number;type Tx = {  slot: Num;  blockTime: Num | null;  transaction: { message: { accountKeys: { pubkey: string }[]; instructions: Ix[] } };  meta: {    err: unknown; fee: Num; preBalances: Num[]; postBalances: Num[]; computeUnitsConsumed?: Num;    preTokenBalances?: Bal[]; postTokenBalances?: Bal[]; innerInstructions?: { instructions: unknown[] }[]; logMessages?: string[];  } | null;};const GAP_MS = 4300; // one call per 4.3 s stays under Free's 0.24 req/s; use 1000 on Devlet last = 0;const pace = async () => {  const wait = last + GAP_MS - Date.now();  if (wait > 0) await new Promise((r) => setTimeout(r, wait));  last = Date.now();};const show = (v: unknown) => JSON.stringify(v, (_, x) => (typeof x === "bigint" ? String(x) : x));const fmt = (d: bigint, dec: number) => {  const s = (d < BigInt(0) ? -d : d).toString().padStart(dec + 1, "0");  return `${d < BigInt(0) ? "-" : "+"}${dec ? `${s.slice(0, -dec)}.${s.slice(-dec)}` : s}`;};const NAMES: Record<string, string> = { ComputeBudget111111111111111111111111111111: "compute-budget" };async function explain(sig: string): Promise<void> {  await pace();  const tx = (await rpc    .getTransaction(signature(sig), { commitment: "confirmed", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 })    .send()) as unknown as Tx | null;  if (!tx?.meta) return console.log(`${sig}\n  not found at confirmed`);  const { meta } = tx;  const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey);  const when = tx.blockTime === null ? "an unknown time" : new Date(Number(tx.blockTime) * 1000).toISOString();  console.log(`${sig}\n  ${meta.err ? `FAILED ${show(meta.err)}` : "succeeded"} in slot ${tx.slot} at ${when}`);  console.log(`  fee ${Number(meta.fee) / 1e9} SOL paid by ${keys[0]}, ${meta.computeUnitsConsumed ?? "?"} compute units`);  keys.forEach((k, i) => {    const d = BigInt(meta.postBalances[i]) - BigInt(meta.preBalances[i]);    if (d !== BigInt(0)) console.log(`  SOL   ${k} ${fmt(d, 9)}`);  });  const tokens = new Map<number, { b: Bal; d: bigint }>();  for (const b of meta.preTokenBalances ?? []) tokens.set(b.accountIndex, { b, d: -BigInt(b.uiTokenAmount.amount) });  for (const b of meta.postTokenBalances ?? []) {    tokens.set(b.accountIndex, { b, d: (tokens.get(b.accountIndex)?.d ?? BigInt(0)) + BigInt(b.uiTokenAmount.amount) });  }  for (const { b, d } of tokens.values()) {    if (d !== BigInt(0)) console.log(`  token ${b.owner ?? keys[b.accountIndex]} ${fmt(d, b.uiTokenAmount.decimals)} of mint ${b.mint}`);  }  for (const ix of tx.transaction.message.instructions) {    const what = ix.parsed === undefined      ? `${NAMES[ix.programId] ?? ix.programId} (unparsed, ${ix.accounts?.length ?? 0} accounts)`      : `${ix.program}: ${typeof ix.parsed === "string" ? ix.parsed : show(ix.parsed)}`;    console.log(`  do    ${what}`.slice(0, 200));  }  const inner = (meta.innerInstructions ?? []).reduce((n, g) => n + g.instructions.length, 0);  if (inner) console.log(`  ${inner} inner instructions`);  if (meta.err) for (const l of (meta.logMessages ?? []).slice(-3)) console.log(`  log   ${l}`);}async function main(): Promise<void> {  let sigs = [target];  if (target.length < 80) {    await pace();    const rows = await rpc.getSignaturesForAddress(address(target), { limit: count, commitment: "confirmed" }).send();    sigs = rows.map((r) => r.signature);    console.log(`${sigs.length} recent transactions for ${target}`);  }  for (const s of sigs) await explain(s).catch((e) => console.error(`${s} failed: ${e instanceof Error ? e.message : e}`));}main().catch((e) => die(e instanceof Error ? e.message : String(e)));

run: CARBIUM_KEY=<YOUR_KEY> node main.ts <signature or address> [count]

The kit 8.6.0 types accept the value 1 without a cast.

Every call waits until GAP_MS (4.3 s) has passed since the previous one, which keeps a Free account under its getTransaction limit. The client is created once and reused for every call.

04

What it costs

A run is one listing call plus one getTransaction per transaction. Both methods cost 50 cells, and each plan allows them at the rates below.

PlanCreditsgetTransaction rate20 calls at the limit
Free ($0)500K once, at sign-up0.24 req/sabout 83 s
Dev ($20)10M per month1.2 req/sabout 17 s
Business ($250)50M per month5 req/s4 s
Pro ($500)200M per month25 req/sunder 1 s

The listing call has its own limit: 0.24 req/s on Free, 1.2 on Dev, 100 on Business and 500 on Pro. On Free the code allows at most one call every 4.3 s, so a listing of 20 takes about 90 seconds. On Dev, set GAP_MS to 1000 and the same listing takes about 21 seconds.

Limits are per account, so other tools on the same keys draw on the same budget.

05

What to add next

  • A cache: a landed transaction does not change, so key a node:sqlite table on the signature and skip the 50-cell call the second time a signature comes up.
  • A live feed: open `logsSubscribe` with a mention of your address. A logs subscription opens at 25 credits and then costs 20 credits per MiB sent. Hand each signature to the explainer.
  • A decoder table: for the programs you care about, read the program's published interface and turn the unparsed data into an action name.
  • A reply formatter: join the lines into one sentence per transaction for a support template or an activity feed.
06

Where it ends

  • Action names and fields appear only for programs the node can decode. A call routed through any other program prints as a program id with its account count.
  • Each instruction line is cut at 200 characters, so long parsed fields are truncated.
  • Inner instructions are counted and not listed, so a transaction with many nested calls shows its top level only.
  • Amounts are in SOL and in each token's own units. There are no symbols, no names for mints and no prices.
  • The fee line is the total in meta.fee. It does not split the base fee from a priority fee.
  • Address mode reaches back 30 days at most, the span of the address index. An empty page past that is the index's age limit and says nothing about the address's first transaction.
  • The address index reaches below the node's ledger floor, so address mode can list a signature that getTransaction answers null for every time. That signature prints "not found at confirmed" on each run, and a retry will not change it.
  • Only landed transactions have a record. One rejected before landing, or one whose blockhash expired, cannot be explained.
07

When it goes wrong

what goes wrongwhat to do
A signature prints "not found".Check the signature for a typo and that the transaction landed: one rejected before landing leaves no record. A fresh signature is served at confirmed commitment, which the code names, so a null for one you just sent can clear on a later try. A signature that address mode listed can sit below the node's ledger floor and stays null on every run.
getTransaction answers 429.At the default gap on Free, a 429 means another caller on the same account is drawing on the shared budget, since the keys on one account share it, or the Free key is over its network's shared budget. On a paid plan, set GAP_MS to 1000 divided by the plan's req/s, in milliseconds.
A signature prints "failed: Transaction version (N) is not supported by the requesting client".The call sent a maxSupportedTransactionVersion lower than N, or none. main.ts sends 1, so this shows up in code you adapt that sends 0 or leaves the field out. Raise the value to the N the message names. The node answers -32015 and charges nothing for the refused call.
A token line shows a token account address where you expected a wallet.Some balance records come back without owner, and the code falls back to the account address. Look up its owner with getAccountInfo, which costs 10 cells, or leave the line as it is.
The listing returns fewer signatures than asked, or none.The address may be quiet, or the page is past the 30-day address index. An empty page there is the index's age limit.
The script prints an invalid address or signature error.Kit checks the base58 text before it calls out. A bad address exits through the script's exit path with that message. A bad signature is caught inside the explain step, prints "<signature> failed: ..." and the script then ends normally. Signatures run up to 88 characters, almost always 87 or 88, and addresses 32 to 44. The code reads a string under 80 characters as an address.
08

Questions

Can it explain a transaction that has not landed yet?

No. getTransaction reads landed transactions only. To follow one you just sent, signatureSubscribe sends one confirmation for the signature and then ends, and you can call the explainer after it.

Why ask for jsonParsed?

It makes the node decode the instructions it knows, so the output carries action names and fields without a decoder in your code. The raw encodings return bytes you would decode yourself.

Will it run on the Free plan?

Yes. The gap keeps it under 0.24 req/s, and a listing of 20 transactions takes about 90 seconds. A Dev account allows 1.2 req/s for the same job.

Does it show dollar values?

No. Amounts are in SOL and in each token's own units. A dollar value needs a price source that you add and that the explainer leaves out.