services
Get a key

library / Use cases / UC0059

Revenue split verifier

Verify after the fact that one payout transaction divided USDC in the agreed shares: who received what, each share in basis points, rounding dust, Token-2022 fees, and a read-only Node script that works whichever splitter program ran.

By Carbium · Payouts, payroll and remittance · UC0059 · updated 2026-11-22

01

How a split lands

A platform that pays partners out of revenue usually does it in one transaction: one debit from the platform's treasury account and several credits, one per partner, often with a small amount to the platform itself. Some platforms call a splitter program that works out the shares on chain. Others have an ordinary wallet send a batch of transfers. Afterward the ledger holds the same thing in both cases, which is balances that moved.

The credits often sit in inner instructions. A splitter program receives one instruction from the platform and issues the token transfers itself, so the top level of the transaction shows a single call. Instruction data tells you what the program was asked to do, and every program has its own layout. Inner instruction tree shows how to walk them. For verification you can skip that work.

The check here asks a narrower question once the payout has landed. Given a signature, who received how much, and do the amounts match the shares the agreement names? It reads token balance deltas, so it gives the same answer whatever program ran. That also lets a partner audit a payout from a platform whose code they have never read.

02

Recipients and amounts from deltas

Every executed transaction carries preTokenBalances and postTokenBalances in its meta. An entry names the mint, the owner and uiTokenAmount.amount, a string of base units. The change for one owner is the post amount minus the pre amount, summed over every token account that owner holds for the mint. USDC has 6 decimals, so 12.50 USDC is 12500000. Keep the amounts as BigInt and ignore the float uiAmount.

Take the recipient from the owner field of those entries. The account keys of a payout hold token accounts, and a transfer into an existing one never names the wallet that owns it. A verifier that reads wallets from the key list reports token account addresses, or reports nothing for a partner who was paid. A partner can also hold two token accounts for one mint, and the split is only correct once you add them together.

  • A missing pre entry means the account was created in the transaction, and a missing post entry means it was closed. Count the absent side as 0.
  • Read meta.err first. A failed transaction leaves token balances unchanged and nothing was paid.
  • Fetch with maxSupportedTransactionVersion: 1. Mainnet carries v1 transactions, and with the value absent or 0 Carbium answers -32015 for one, uncharged.

Debits come out negative and credits positive. The recipients are the owners with a positive delta. The treasury shows up as a negative you can ignore for the shares.

03

Shares in basis points and dust

Agreements state shares as percentages, and one basis point is 0.01%, so 10000 bps is the whole payout. The script adds up the positive deltas, divides each by that total and rounds to the nearest basis point. A 70/30 agreement should read 7000 and 3000.

On chain the arithmetic is integer. A program that multiplies the payout by 7000 and divides by 10000 drops the fraction on every recipient, and the leftover base units go to one of them, usually the last or the platform. The table shows a payout of 1,000,003 base units, which is 1.000003 USDC, under a 70/30 split.

RecipientAgreed bpsExact amountPaid
Partner A7000700002.1700002
Partner B3000300000.9300000
Dustnonenone1 left over

The paid amounts still round back to 7000 and 3000 bps, so the verifier calls that split correct. On small payouts the dust is visible in the shares, so the script accepts a difference of 1 bp from each expected share and flags anything larger. A split that is off by 100 bps is a wrong split, whatever program made it.

The shares here are shares of what recipients received. If part of the debit went somewhere that is not a recipient, a fee or a burn, the shares of the debit differ from the shares of the credits. The script prints both the credited total and whether the deltas sum to zero, so you can see which one you are reading.

04

Token-2022 transfer fees

A Token-2022 mint can carry a transfer fee. Each transfer withholds a fee, rounded up and capped at the mint's maximum, and the withheld amount stays in the receiving account's extension data. It never shows in that account's balance. The sender is debited the full amount while the recipient's balance rises by the amount minus the fee. The deltas then sum to less than zero, and the gap is the fee. Transfer fee calculator works out the fee for a given amount.

For a split this matters twice. A payout of several transfers pays one fee per transfer, so a small share loses proportionally more than a large one, and the observed shares drift from the agreed ones by an amount you can predict. Second, a nonzero sum is the signal to look. The script prints it beside the shares with a note that a fee, mint or burn took part. The default mint is classic USDC, which has no such extension, so point the constant at a Token-2022 mint to see the effect.

05

The check in one file

Pass a payout signature, then optionally owner:bps pairs for the shares the agreement names. With no arguments the script lists the 12 newest signatures on the USDC mint with getSignaturesForAddress and fetches them one at a time with getTransaction, pausing 250 ms between calls. It stops at the first one that credits two or more owners. When none does, it reports the transaction with the most credited owners, so every run ends with shares on screen. Each fetch sits in its own try, so a transaction that answers null or errors is skipped and named. The calls read at finalized and go to the RPC endpoint with the `x-api-key` header.

main.ts
// UC0059 · Revenue split verifier// https://carbium.sh/library/usecase/revenue-split-verifier// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: how a finalized transaction divided USDC between its recipients, from token balance deltas.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 url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";const [sigArg, ...expect] = process.argv.slice(2);const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));type Bal = { accountIndex: number; mint: string; owner?: string; uiTokenAmount: { amount: string } };type Tx = { meta: { err: unknown; preTokenBalances?: Bal[] | null; postTokenBalances?: Bal[] | null } | null };// Net USDC change per owner; a missing pre or post entry counts as 0.async function deltas(sig: string): Promise<Map<string, bigint> | null> {  const tx = (await rpc.getTransaction(signature(sig), { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "finalized" }).send()) as unknown as Tx | null;  if (!tx?.meta || tx.meta.err) return null;  const net = new Map<string, bigint>();  for (const [list, sign] of [[tx.meta.preTokenBalances, -1n], [tx.meta.postTokenBalances, 1n]] as const) {    for (const b of list ?? []) {      if (b.mint !== USDC) continue;      const who = b.owner ?? `account ${b.accountIndex}`;      net.set(who, (net.get(who) ?? 0n) + sign * BigInt(b.uiTokenAmount.amount));    }  }  return net;}function report(sig: string, net: Map<string, bigint>, credits: [string, bigint][]) {  const total = credits.reduce((a, [, v]) => a + v, 0n);  const bps = new Map(credits.map(([who, v]) => [who, (v * 20000n + total) / (2n * total)] as const));  const sum = [...net.values()].reduce((a, v) => a + v, 0n);  const all = [...bps.values()].reduce((a, v) => a + v, 0n);  const gap = all > 10000n ? all - 10000n : 10000n - all;  console.log(`tx ${sig}\ncredited ${total} base units to ${credits.length} owners`);  for (const [who, v] of credits) console.log(`${who} +${v} ${bps.get(who)} bps`);  console.log(`${gap <= BigInt(credits.length) ? "OK" : "OFF"}: shares add to ${all} bps, deltas sum to ${sum}${sum === 0n ? "" : " (a fee, mint or burn took part)"}`);  for (const e of expect) {    const [who, want] = e.split(":");    const got = bps.get(who ?? "") ?? 0n, w = BigInt(want ?? 0);    const off = got > w ? got - w : w - got;    console.log(`${off <= 1n ? "OK" : "OFF"}: ${who} got ${got} bps, expected ${w}`);  }}const sigs = sigArg ? [sigArg] : (await rpc.getSignaturesForAddress(address(USDC), { limit: 12, commitment: "finalized" }).send()).filter((s) => s.err === null).map((s) => s.signature as string);let best: { sig: string; net: Map<string, bigint>; credits: [string, bigint][] } | null = null;for (const sig of sigs) {  try {    const net = await deltas(sig);    if (!net) { console.log(`skip ${sig}: failed or not found`); continue; }    const credits = [...net].filter(([, v]) => v > 0n);    if (credits.length > (best?.credits.length ?? 0)) best = { sig, net, credits };    if (sigArg || credits.length >= 2) break;    console.log(`skip ${sig}: ${credits.length} recipient`);  } catch (e) { console.log(`skip ${sig}: ${(e as Error).message}`); }  await new Promise((r) => setTimeout(r, 250));}if (best) report(best.sig, best.net, best.credits);else console.log("No USDC credit found; pass a payout signature.");

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts [signature] [owner:bps ...]

It prints each recipient owner with the amount, the share in bps, the total of the shares and whether the deltas sum to zero. The total line starts with OK when the shares add to 10000 bps within 1 bp per recipient and OFF beyond it. Each pair you pass gets a line that reads OK within 1 bp and OFF beyond it. A scan costs the list call at 50 cells and up to 12 lookups at 50 cells each, 650 cells in all, so the whole scan fits inside the 1,024-cell burst of a rate class. Nothing is signed or sent.

To verify payouts as they land, open a WebSocket with the key as ?api-key= and subscribe with logsSubscribe on the treasury token account. A mention filter opens at 25 credits, then costs 20 credits per MiB sent. Take the signature from each notification and run the same check, so one code path judges every payout. Bulk payout preflight check covers the matching step before the money leaves.

06

Where it ends

  • The deltas show what landed. The shares owed come from your agreement, so you pass them in.
  • One transaction at a time. A payout spread over several transactions needs your own ledger to add the deltas that belong together.
  • Recipients are token account owners. A partner paid into a custodian's or a program's account shows that owner's address, so keep a map from owner to partner.
  • One mint per run. A split in SOL needs lamport deltas, and fees and rent make those harder to read.
  • Signature lists reach back 30 days at most, and getTransaction can answer null for an older signature the list returned. Keep the signatures of payouts you have verified.
  • A matching split shows the program paid the right shares, and nothing about whether the revenue figure it split was right.
07

When it goes wrong

what goes wrongwhat to do
Recipients come out as token account addresses, or a paid partner is missing.Group the balances by their owner field.
getTransaction fails with -32015 on a payout.Pass maxSupportedTransactionVersion: 1 on every call. With the value absent or 0, Carbium answers -32015 for a v1 transaction.
A partner with two token accounts for the mint shows up as two small recipients and the shares look wrong.Sum the deltas by owner before dividing, so every account one wallet holds counts once.
The shares add up to 9999 or 10001 bps.Each share rounds on its own. Accept 1 bp of difference per recipient and investigate anything larger.
The deltas do not sum to zero on a Token-2022 mint.A transfer fee is withheld inside the receiving accounts. Compare the gap with the mint's fee settings before you call the split wrong.
A signature from the list answers null.The address index reaches below the validator's ledger floor, so an older signature can come back null. Skip it, and keep your own record of verified payouts.
08

Questions

Does this work for any splitter program?

Yes, because it never reads instructions. It reads the balances before and after, which every program has to change to move tokens.

Why basis points?

A basis point is 0.01%, so a share is a whole number and the shares of an agreement add to 10000. That makes a mismatch easy to read and dust easy to see.

How do I check payouts as they happen?

Subscribe with logsSubscribe on the treasury token account, then run the check on each signature. A mention filter opens at 25 credits and costs 20 credits per MiB sent.

What does one check cost?

One getTransaction is 50 cells. Listing signatures first adds one getSignaturesForAddress call at 50 cells.