services
Get a key

library / Blockchain ideas / BI0008

Point-of-sale recent sales

A Recent Sales page for a Solana Pay shop: amount, time and the sender's full public key for each finalized payment, read from the merchant's address with one listing call plus one read per sale, with runnable code and plan costs.

By Carbium · Commerce · BI0008 · updated 2026-11-22

01

Who uses it

A shop that takes Solana Pay at the counter needs a screen for the person behind it. After a customer pays, the cashier wants to see the sale land: how much, when, and which wallet sent it. The sender's key is in the transaction, but the usual first attempt reads the wrong field.

The cashier checks a sale against the customer's wallet app by comparing the first and last four characters of the key. The owner scrolls the day's sales at closing. A support person answers "I paid, where is it?" by finding the payment and reading the sender key back to the customer.

A hackathon team can build the whole page against any busy public wallet standing in as the merchant, because every read is public. Swap in your own address when your counter is ready.

02

What it shows

Each sale is one row. The signature and status come from the signature list, so every row has them. The time comes from the same list and reads unknown time when the node has none for that signature. Amount and sender come from the transaction.

ColumnWhere it comes fromExample
TimeblockTime on the listed signature, or unknown time when it is null2026-11-22T09:14:03.000Z
Signaturesignature on the listed signaturethe first 8 characters on screen, the full value on click
Statuserr on the listed signaturefailed payments are skipped
Amountthe merchant's balance change in the transaction12.5 units of one token mint, or 0.42 SOL
Senderthe owner of the balance that fellthe full public key, shortened on the counter screen

The sender comes from balance changes, and the fee payer is the usual wrong answer. A transfer can arrive as a System transfer, a token transfer, a checked transfer or a call through another program. The balances recorded in meta describe the outcome in every case: the wallet whose balance fell is the sender. The fee payer is only the account that paid the network fee, and a service can pay that fee for a customer.

$A sender key is a wallet address. It names a wallet, and the page cannot say who holds it.
03

The build

The page needs one file with @solana/kit and what Node 24 ships. It is read-only: no private key, nothing sent. Run it with the merchant's wallet in MERCHANT and it prints the latest finalized sales, one line each.

  1. Read MERCHANT (the wallet that takes payments), LIST_AT (the address to list, which is the wallet for SOL sales and the wallet's token account for token sales) and LIMIT.
  2. Create one RPC client for https://services.carbium.sh and reuse it for every call.
  3. Call getSignaturesForAddress on the listed address with the limit at commitment finalized.
  4. Skip signatures whose err is set, since a failed payment is not a sale.
  5. For each remaining signature, wait GAP_MS, then call getTransaction at finalized with jsonParsed encoding and maxSupportedTransactionVersion 1.
  6. Work out the amount and the sender from the balance changes: first the token balances (the merchant's row rose, and the row of the same mint that fell is the sender), then the lamport balances.
  7. Print time, signature prefix, amount and the sender's full public key.
main.ts
// BI0008 · Point-of-sale recent sales// https://carbium.sh/library/blockchainideas/point-of-sale-recent-sales// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, isSolanaError, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR } from "@solana/kit";const key = process.env.CARBIUM_KEY ?? "";const merchant = process.env.MERCHANT ?? "";if (!key || !merchant) {  console.error("Set CARBIUM_KEY to your Carbium API key and MERCHANT to the wallet that takes payments.");  process.exit(1);}// SOL sales are listed at the wallet; token sales at the wallet's token account (LIST_AT).const listed = process.env.LIST_AT ?? merchant;const LIMIT = Number(process.env.LIMIT ?? 5);const GAP_MS = Number(process.env.GAP_MS ?? 4500); // 50 cells per call: one call per 4.5 s stays under Free's 0.24 req/sconst rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);type Bal = { accountIndex: number; mint: string; owner?: string; uiTokenAmount: { amount: string; decimals: number } };type Tx = {  meta: { preBalances: (number | bigint)[]; postBalances: (number | bigint)[]; preTokenBalances?: Bal[]; postTokenBalances?: Bal[] } | null;  transaction: { message: { accountKeys: { pubkey: string; signer: boolean }[] } };};const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));// One retry after a 429, waiting the retry-after seconds the door sends.async function call<T>(f: () => Promise<T>): Promise<T> {  try {    return await f();  } catch (e) {    if (isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) && e.context.statusCode === 429) {      await sleep(Number(e.context.headers.get("retry-after") ?? 5) * 1000);      return f();    }    throw e;  }}// The sender is whoever's balance fell: read the balances, never the fee payer.function sale(tx: Tx): { amount: string; sender: string } | undefined {  const m = tx.meta;  if (!m) return undefined;  const keys = tx.transaction.message.accountKeys;  const pre = m.preTokenBalances ?? [];  const post = m.postTokenBalances ?? [];  const change = (b: Bal) =>    Number(b.uiTokenAmount.amount) - Number(pre.find((p) => p.accountIndex === b.accountIndex)?.uiTokenAmount.amount ?? 0);  const got = post.find((b) => b.owner === merchant && change(b) > 0);  if (got) {    const from = post.find((b) => b.mint === got.mint && change(b) < 0);    if (!from) return undefined;    const sender = from.owner ?? keys.find((k) => k.signer)?.pubkey ?? "unknown";    return { amount: `${change(got) / 10 ** got.uiTokenAmount.decimals} of mint ${got.mint}`, sender };  }  const lamports = keys.map((_, i) => Number(m.postBalances[i]) - Number(m.preBalances[i]));  const at = keys.findIndex((k) => k.pubkey === merchant);  if (at < 0 || lamports[at] <= 0) return undefined;  return { amount: `${lamports[at] / 1e9} SOL`, sender: keys[lamports.indexOf(Math.min(...lamports))].pubkey };}async function main() {  const sigs = await call(() => rpc.getSignaturesForAddress(address(listed), { limit: LIMIT, commitment: "finalized" }).send());  console.log(`${sigs.length} recent signatures at ${listed}`);  for (const s of sigs) {    if (s.err !== null) continue; // a failed payment is not a sale    await sleep(GAP_MS);    const tx = (await call(() =>      rpc.getTransaction(s.signature, { commitment: "finalized", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 }).send(),    )) as unknown as Tx | null;    const r = tx ? sale(tx) : undefined;    const when = s.blockTime === null ? "unknown time" : new Date(Number(s.blockTime) * 1000).toISOString();    console.log(r ? `${when} ${s.signature.slice(0, 8)} ${r.amount} from ${r.sender}` : `${when} ${s.signature.slice(0, 8)} no payment to the merchant`);  }}main().catch((e) => {  console.error(e instanceof Error ? e.message : e);  process.exit(1);});

run: CARBIUM_KEY=<YOUR_KEY> MERCHANT=<MERCHANT_WALLET> node main.ts

A counter that waits for finalized adds almost nothing to the wait for confirmed, and a sale shown at finalized never has to be taken back. That is why both calls name finalized.

GAP_MS defaults to 4500 because each call costs 50 cells and Free allows 0.24 req/s, about one call every 4.2 seconds. Set it lower on a bigger plan.

04

What it costs

Two methods make a page. One getSignaturesForAddress call lists the signatures and costs 50 cells. One getTransaction call per sale reads it and costs 50 cells, so a ten-row page is eleven calls. The plan sets the rate for each. Limits are per account, so other tools on the same keys draw on the same budget.

PlanCreditsgetTransaction rategetSignaturesForAddress rateTen uncached details, rate floor
Free ($0)500K once, at sign-up0.24 req/s0.24 req/sabout 42 s
Dev ($20)10M per month1.2 req/s1.2 req/sabout 8.3 s
Business ($250)50M per month5 req/s100 req/s2 s
Pro ($500)200M per month25 req/s500 req/s0.4 s

The last column is ten details divided by the plan's getTransaction rate, before network time. Free fills a ten-row page in about 42 seconds the first time, which is why caching matters.

A finalized sale never changes. Store each row in node:sqlite, keyed by signature, the first time you read it. A refresh then costs one getSignaturesForAddress plus one getTransaction per new sale. A listing poll every 10 seconds is 0.1 req/s, under the Free limit of 0.24, and the cashier's page reads the table, so opening it a hundred times costs no calls.

05

What to add next

  • The table cache above, with a poller that fills it and a page that only reads it. It also keeps sales after they leave the 30-day index.
  • Live rows: open wss://services.carbium.sh with the key as ?api-key= and send logsSubscribe with a mention of the merchant. It opens at 25 credits, then costs 20 credits per MiB sent, and each notification carries the signature to hand to getTransaction. For a plain SOL wallet, accountSubscribe stays silent, so use the logs mention plus getBalance. The Failed-mint monitor has the full loop.
  • Order matching: Solana Pay puts a unique reference key in each payment request. Set LIST_AT to that reference and the listing returns the one sale for that order.
  • A closing total: sum the amounts per mint for the day from the cache.
  • A masked display: show the first and last four characters of the sender on the counter and the full key on click or in the exported row. SPL token balance shows the token side of the same reads.
06

Where it ends

  • Token sales are listed at the token account. getSignaturesForAddress on a wallet returns transactions that name the wallet, and a token transfer usually names token accounts instead. Set LIST_AT to the merchant's token account for each mint you accept and merge the lists by signature.
  • History is the 30-day address index at most. An older sale is not served, and an empty page past that is the index's age limit and says nothing about the merchant's first sale. Keep your own rows to show more.
  • The sender is a wallet. A payment from an exchange withdrawal shows the exchange's wallet, and the page cannot name the person behind it.
  • When several balances fall in one transaction, the SOL path takes the largest fall and the token path takes the first matching row. A payment split across senders shows one of them.
  • Refunds and payouts from the merchant wallet appear in the listing as no payment rows, because the merchant's balance fell. The page does not label them as refunds.
  • Only landed, finalized transactions show. A payment the wallet has submitted but the chain has not finalized does not appear yet, and a failed one never does.
07

When it goes wrong

what goes wrongwhat to do
The listing is empty for a merchant who takes token payments.List at the merchant's token account with LIST_AT. A token transfer usually does not name the wallet, so the wallet's own listing misses it.
The sender of a SOL payment is a program-owned account.A smart wallet or a program moved the SOL, so the balance that fell belongs to a program account. Print the signer from accountKeys next to it: that is the wallet that approved the payment.
getTransaction keeps answering 429.Raise GAP_MS to match your plan's rate (0.24 req/s on Free) and check what else on the account is calling, because the limit is shared across its keys.
A token sale shows as no payment to the merchant.The row counts only when the receiving token account's owner equals MERCHANT. A sale into an account owned by another wallet, such as a shared till, belongs to that wallet. Check the owner in the post token balances.
Sales from a month ago disappear from the page.The listing comes from the 30-day address index. Read new sales into your own table as they land and serve the page from it.
08

Questions

Is the sender the fee payer?

Often, but not always. The fee payer pays the network fee, and a service can pay it for a customer. The code reads the balance that fell, and a token sale with no owner row falls back to the first signer.

How do I show the sender for one specific order?

Solana Pay puts a unique reference key in each payment request, and the paying transaction names it. Set LIST_AT to the reference. getSignaturesForAddress then returns that one sale, and the same code names its sender.

Will this run on the Free plan?

Yes. A ten-row first load takes about 42 seconds at 0.24 req/s. With a cache, later refreshes cost one listing call plus one getTransaction per new sale.

How much of the key should the screen show?

The key is public on chain, but a counter screen faces other customers. Show the first and last four characters and keep the full key behind a click or in the exported row.