---
id: UC0035
title: "On-ramp fulfilment tracker"
url: https://carbium.sh/library/usecase/on-ramp-fulfilment-tracker
collection: Use cases
category: Exchanges, custodians and on-ramps
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# On-ramp fulfilment tracker

Follow each on-ramp order from payout signature to a finalized credit. A read-only Node script checks the signature status, reads the amount the customer's wallet received from the transaction, and finds the payout when your sender recorded no signature.

## What fulfilment means after the card clears

An on-ramp takes fiat and delivers a token. The fiat leg ends in your payment provider's system. The on-chain leg starts when your treasury signs a transfer of USDC to the customer's wallet. Support questions all sit on that second leg: did it land, for how much, to which wallet, and is it final. The tracker answers them from the chain with your API key and no signer.

Each order needs four values: an id, the customer wallet, the mint, and the expected amount in base units, plus the signature once your sender has one. An order without a signature also carries the treasury owner that pays out, so discovery has a sender to match. USDC has 6 decimals, so 25 USDC is `25000000`. Keep amounts as integers all the way through, and the comparison never meets a rounding error.

The wallet is where the order is addressed, but a token transfer never names it. It lists the token accounts and the sender's authority. A wallet can also own more than one token account for one mint. So the tracker adds up the balances whose `owner` field is the wallet, across every token account in the transaction's metadata. When it has to look for a payout, it lists the wallet's token accounts for the mint first, because listing signatures for the wallet address misses a credit to an existing token account.

## Six states for one order

The script prints one line per order, and the line starts with the state. Support reads it, and a ledger job can branch on it.

| State | Meaning | Evidence |
|---|---|---|
| pending | No signature recorded and no matching credit found | The wallet's token accounts list no transfer of exactly the amount that the treasury owner paid |
| not found | A signature exists but the node does not know it | Empty status and no readable transaction |
| landing | On chain, below finalized | `confirmationStatus` is processed or confirmed |
| failed | On chain with an error | The status carries an `err` |
| short | Finalized, but the wallet received less than expected | Token balance change in the transaction |
| delivered | Finalized and received at least the expected amount | Token balance change in the transaction |

The difference between `not found` and `pending` matters to the person handling it. A pending order has no payout yet, so the question is whether your sender ran. A not-found signature means the sender produced one that never reached the chain or was dropped, and re-sending is your policy to decide, since a second payout is a second payment.

## The tracker in one file

Orders come in as arguments of the form `id,wallet,mint,amount[,signature[,treasury]]`. With no argument the script builds two demo orders from a recent USDC transfer it finds, one with its signature and one with the sending owner but no signature, so a first run shows both paths.

`main.ts` (run: `CARBIUM_KEY=$CARBIUM_KEY node main.ts [<id>,<wallet>,<mint>,<base-unit-amount>[,<signature>[,<treasury-owner>]] ...]`)

```ts
// UC0035 · On-ramp fulfilment tracker
// https://carbium.sh/library/usecase/on-ramp-fulfilment-tracker
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only: follows on-ramp payouts (token transfers) from signature to a finalized credit in the customer's wallet.
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 LEVEL = "finalized" as const;
const PAGE = 10; // newest signatures read per token account when an order has no signature
// version 1, so a v1 transaction reads instead of answering -32015
const opts = { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: LEVEL } as const;

type Bal = { mint: string; owner?: string; uiTokenAmount: { amount: string } };
type Tx = { meta: { err: unknown; preTokenBalances?: Bal[]; postTokenBalances?: Bal[] } | null };
type Order = { id: string; wallet: string; mint: string; amount: bigint; sig?: string; sender?: string };

const getTx = async (sig: string) => (await rpc.getTransaction(signature(sig), opts).send()) as unknown as Tx | null;

// What an owner received in one transaction (negative for a sender), summed over all its token accounts for the mint
function received(tx: Tx, owner: string, mint: string): bigint {
  const sum = (l?: Bal[]) => (l ?? []).filter((b) => b.owner === owner && b.mint === mint)
    .reduce((s, b) => s + BigInt(b.uiTokenAmount.amount), 0n);
  return sum(tx.meta?.postTokenBalances) - sum(tx.meta?.preTokenBalances);
}

// A token credit names the token account, never the wallet: list the wallet's accounts for the mint first.
// A match is the exact amount in and the same amount out of the treasury owner in one transaction.
async function find(o: Order): Promise<string | undefined> {
  const from = o.sender;
  if (!from) return;
  const accts = await rpc.getTokenAccountsByOwner(address(o.wallet), { mint: address(o.mint) }, { encoding: "base64", commitment: LEVEL }).send();
  for (const a of accts.value) {
    const page = await rpc.getSignaturesForAddress(a.pubkey, { limit: PAGE, commitment: LEVEL }).send();
    for (const s of page) {
      const tx = s.err ? null : await getTx(s.signature);
      if (tx && received(tx, o.wallet, o.mint) === o.amount && received(tx, from, o.mint) === -o.amount) return s.signature;
    }
  }
}

async function check(o: Order): Promise<string> {
  const sig = o.sig ?? await find(o);
  if (!sig) return "pending: no signature recorded and no matching credit found";
  const st = (await rpc.getSignatureStatuses([signature(sig)]).send()).value[0];
  if (st?.err) return `failed: ${sig} ${JSON.stringify(st.err, (_k, v) => typeof v === "bigint" ? v.toString() : v)}`;
  if (st && st.confirmationStatus !== LEVEL) return `landing: ${sig} is ${st.confirmationStatus}`;
  const tx = await getTx(sig);
  if (!tx?.meta) return st ? `landing: ${sig} finalized, transaction not readable yet` : `not found: ${sig}`;
  if (tx.meta.err) return `failed: ${sig}`;
  const got = received(tx, o.wallet, o.mint);
  return got >= o.amount ? `delivered: ${sig} received ${got}` : `short: ${sig} received ${got} of ${o.amount}`;
}

// No argument: take a recent USDC transfer and make one order with its signature and one with its sender instead
async function demo(): Promise<Order[]> {
  const mint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
  const page = await rpc.getSignaturesForAddress(address(mint), { limit: 8, commitment: LEVEL }).send();
  for (const s of page) {
    const tx = s.err ? null : await getTx(s.signature);
    if (!tx) continue;
    for (const b of tx.meta?.postTokenBalances ?? []) {
      if (b.mint !== mint || !b.owner) continue;
      const amount = received(tx, b.owner, mint);
      const sender = tx.meta?.preTokenBalances?.find((p) => p.mint === mint && p.owner && received(tx, p.owner, mint) === -amount)?.owner;
      if (amount > 0n && sender) return [
        { id: "demo-signed", wallet: b.owner, mint, amount, sig: s.signature },
        { id: "demo-found", wallet: b.owner, mint, amount, sender }];
    }
  }
  throw new Error("no recent USDC transfer found");
}

const parse = (a: string): Order => {
  const [id, wallet, mint, amount, sig, sender] = a.split(",");
  address(wallet!); address(mint!); // throws on a malformed address
  if (sender) address(sender);
  return { id: id!, wallet: wallet!, mint: mint!, amount: BigInt(amount!), sig: sig || undefined, sender: sender || undefined };
};

const args = process.argv.slice(2);
const orders = args.length ? args.map(parse) : await demo();
for (const o of orders) {
  try { console.log(`${o.id} ${await check(o)}`); }
  catch (e) { console.log(`${o.id} error: ${e instanceof Error ? e.message : String(e)}`); }
}
```

`received` is the one place an amount is decided. It sums the post-transaction token balances for an owner and the mint, subtracts the pre-transaction sum, and returns a `bigint`, negative for a sender. `find` accepts a transaction only when the wallet's balance rose by exactly the amount and the treasury owner's balance fell by the same amount in that transaction. `check` takes the signature from the order, or from `find` when the order has none. It reads the status first, returns early for `failed` and `landing`, and fetches the transaction once the status is finalized or empty. Every `getTransaction` call sets `maxSupportedTransactionVersion` to 1, because a version 1 transaction answers -32015 when the setting is absent or 0, and the kit 8.6.0 types accept 1 without a cast.

A failure on one order prints `error` with the message and moves to the next, so one 429 never hides the other orders. Run the script from a scheduler and keep the order list in your own database. The script keeps no state, so every pass starts from the orders you hand it.

## Which commitment the verdict uses

The status call reports the level a signature has reached and takes no commitment argument, so the script compares `confirmationStatus` with finalized. The transaction read and the signature listing both pass `finalized` explicitly. A kit call that leaves commitment out fills in `confirmed`, while the JSON-RPC server defaults to finalized, so a copied snippet and a curl command can answer at different levels.

Waiting for finalized costs little now. Since Alpenglow went live on mainnet, a payout's finalized read answers within about a slot of the moment it lands, so a pass run seconds after your sender can already report `delivered`. A signature seen at processed can still vanish when its fork is dropped, which is why `delivered` waits for finalized. Telling the customer that funds are on the way at an earlier level is a message choice, and the ledger entry belongs after the finalized read.

For one order you already hold a signature for, a socket can replace polling: [signatureSubscribe](https://carbium.sh/docs#websocket) sends one confirmation and then ends. For wallet-level alerts on many customers, see [Exchange deposit alerts](https://carbium.sh/library/usecase/exchange-deposit-alerts). Polling suits a reconciliation job that sweeps the open orders every minute.

## Calls per order

An order with a signature costs one status read, and one `getTransaction` once the status is finalized or empty. An order without one adds a token-account lookup, one `getSignaturesForAddress` per token account, and a `getTransaction` for each listed signature until one matches, at most `PAGE` of them. The two reads that set the pace of a pass, with their [rates](https://carbium.sh/docs#rpc):

| Call | Cells | Free req/s | Dev req/s | Business req/s | Pro req/s |
|---|---|---|---|---|---|
| getTransaction | 50 | 0.24 | 1.2 | 5 | 25 |
| getSignaturesForAddress | 50 | 0.24 | 1.2 | 100 | 500 |

At the Free rate of 0.24, a sustained pass reads about 14 transactions a minute, so the discovery path is the one to keep small: pass signatures whenever your sender has them. The [limits](https://carbium.sh/docs#limits) are per account, so a second key adds no capacity. The script reports the failed order and the next pass retries it.

## Where it ends

- Discovery matches the newest transfer of exactly the expected amount that the treasury owner you pass paid out. Two orders of the same amount to one wallet from one treasury can match the same transfer, so give each order its own signature or a unique amount. An order with no signature and no treasury owner stays pending.
- Discovery looks at the `PAGE` newest signatures per token account (10). A wallet that moved a lot of tokens since the payout can push it out of view.
- History: `getSignaturesForAddress` pages come from Carbium's own address index, which keeps up to 30 days and reaches below the validator's ledger floor, so a listed signature can read null from `getTransaction`. Discovery skips it and the order can stay pending. Only a recorded signature with no status and no transaction reports `not found`, and an empty page past 30 days only marks the index's age limit.
- The script reads the credit inside the payout transaction. It says nothing about the wallet's balance today, which the customer may have spent.
- One delivery must be a single transfer of at least the amount. Two half payments report `short` for each when you pass each half's signature. With no signatures, discovery finds no single transfer of the full amount and reports `pending`.
- Tokens only. A SOL payout needs the lamport balance change instead, and the fiat leg, the customer checks and the refund policy live in your provider and your ledger.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| An order stays pending although the customer says the funds arrived. | Discovery only reads the 10 newest signatures per token account and needs one transfer of exactly the amount, with a matching drop in the treasury owner's balance. Pass the signature your sender recorded, check the treasury owner you passed, or check whether the payout was split. |
| `getTransaction` answers -32015 for a payout. | The call left out `maxSupportedTransactionVersion` or set it to 0. The script sets 1, and a config object kept in a variable needs `as const` to keep that literal type. |
| Orders print an error with a 429 during a large pass. | A transaction read costs 50 cells and has its own rate by plan. Pass signatures to skip discovery, spread the pass out, or move up a plan. The next pass retries. |
| An order shows landing, then `not found` a pass later. | A signature seen at processed can disappear when its fork is dropped. Keep the order open and re-send only under the sender's retry policy. |
| An order reports `short` for a payout that looks right. | Compare amounts in base units: 25 USDC is 25000000. Check that the order's mint is the mint the sender used, and that one transfer carried the amount. |
| An order with no signature stays pending, although its payout is old. | Discovery pages come from a 30-day address index that reaches below the ledger floor, so a listed signature can read null from `getTransaction`. Discovery skips it and the order stays pending. A recorded signature that is too old to read reports `not found`. Prove the flow on recent payouts. |

## Questions

### Why read the transaction instead of the token account balance?

The balance is a running total with every earlier deposit and spend in it. The transaction shows what that one transfer delivered to the wallet, which is what an order asks.

### Does Carbium handle the fiat side?

No. Carbium serves the Solana side: RPC, WebSocket subscriptions and the stream. The card or bank leg stays with your payment provider.

### How many orders can one pass check on the Free plan?

About 14 transaction reads a minute at the sustained rate of 0.24 per second. Orders that carry a signature need one read each, so they fit best.

### Can the tracker push a result instead of being polled?

Yes. [signatureSubscribe](https://carbium.sh/docs#websocket) delivers one confirmation for a known signature, and the amount check then runs once. See [Transaction status check](https://carbium.sh/library/howsolana/transaction-status-check) for the status call on its own.

## Related

- [Transaction status check](https://carbium.sh/library/howsolana/transaction-status-check) (How to use Solana, HS0008)
- [Stablecoin settlement checks](https://carbium.sh/library/usecase/stablecoin-settlement-checks) (Use cases, UC0003)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
- [carbium.sh/docs#websocket](https://carbium.sh/docs#websocket)
- [carbium.sh/docs#migrate](https://carbium.sh/docs#migrate)
