services
Get a key

library / Use cases / Payments and checkout / UC0081

Order reference exposure audit

A Solana Pay reference is a public account key, so it hides nothing. See what a reference exposes, how to generate one that leaks as little as possible, and a Node script that lists key roles and a stranger's view of a key's history.

By Carbium · Payments and checkout · UC0081 · updated 2026-11-22

01

What a reference is on chain

A Solana Pay reference is an extra account key added to the payment instruction. The wallet marks it read-only and non-signing, so the transfer program ignores it and cannot change it, and nothing signs for it. Its only job is to appear in the transaction's account list, which puts the transaction in that key's history. The merchant then asks for the signatures of the reference and finds the payment without scanning the whole receiving account.

The same property makes it public. getSignaturesForAddress takes any address, and it does not ask who is calling or whether the address ever held anything. The reference also travels in the payment link or QR code, so every person or system that sees the checkout screen holds a key that can list the payment. Nothing on chain separates the merchant's lookup from a stranger's.

$Roles come from the message header. The first numRequiredSignatures keys sign, the last numReadonlySignedAccounts of those are read-only, and the last numReadonlyUnsignedAccounts of the remaining keys are read-only. A key loaded from an address lookup table never signs, and the transaction metadata lists it as writable or read-only.
02

What an observer learns

Anyone who holds the reference, or any transaction that lists it, reads the following from the transaction alone.

FactWhere it is read
Payer walletThe first account key, which pays the fee and signs.
AmountThe transfer instruction data, and the token balances before and after in the transaction metadata.
TimeThe slot and the block time of the transaction.
Receiving accountThe destination in the transfer instruction. For a token payment it is the token account.
Order linkageThe reference itself: the signature list of that key holds the payment plus whatever a holder of the key chooses to send.
Memo textThe Memo instruction, when the wallet added one.

Order linkage is the part you control. A reference issued for one order ties exactly one payment to that order for anyone who knows the key, and ties it to nothing else. A reference that can be recomputed from something an outsider already knows ties the payment to that something. Derive it from the order number and anyone with the derivation and a list of order numbers can find every payment, its payer and its amount. A reference reused for a second order puts two payers in one list.

03

Rules for generating one

  • Generate a fresh keypair for each order and keep only the public key. Nothing ever signs for a reference, so the private half can be dropped at once.
  • Never derive it from an order id, a customer id or an email, even through a hash. A hash of a guessable value is guessable: someone with a list of candidates computes the keys and lists each one.
  • Store the pairing of order and reference in your own database and look orders up there. The reference carries no meaning on chain, so it needs none.
  • Use a reference once. After the payment lands, retire it and refuse a second payment on it.
  • Keep personal data out of every memo. A memo is text inside the transaction and lasts as long as the transaction does. An order number is the most it should carry, and the reference already does that job.
  • Assume the reference is seen. It sits in the link or QR code, and a screenshot of a checkout screen passes it on.

Solana Pay confirmation builds the payment check around a reference like this. The Memo instruction reader shows how memo text is read back, which is the same text an observer reads.

04

The audit in one file

The script reads your key from CARBIUM_KEY and sends every call to the Carbium endpoint, or to CARBIUM_RPC_URL when you set it. The optional first argument is an address, and the default is the USDC mint. The script takes the newest successful transaction that lists that address and makes three calls in sequence, each in its own try, so one failure is printed and the next call still runs.

The first call lists the newest signatures of the address and prints each with its slot and status. The second reads the transaction with maxSupportedTransactionVersion: 1 and an encoding, because mainnet carries v1 transactions and the RPC answers -32015 for one when the value is absent or 0. The third lists the history of one read-only key from that transaction. Every call reads at confirmed commitment, set explicitly.

main.ts
// UC0081 · Order reference exposure audit// https://carbium.sh/library/usecase/order-reference-exposure-audit// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only reference audit: read the account roles of a real transaction, then list the history of one read-only key.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Address, type 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 source = address(process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // address whose newest transaction is auditedconst commitment = "confirmed";const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));let failed = 0;const report = (step: string, e: unknown) => { failed++; console.error(`${step} failed:`, e instanceof Error ? e.message : e); };const show = (r: { signature: Signature; slot: bigint; err: unknown }) => console.log(`  ${r.signature} slot ${r.slot} ${r.err === null ? "ok" : "failed"}`);// 1. the newest transactions on the source address, and the newest one that succeededlet signature: Signature | undefined;try {  const rows = await rpc.getSignaturesForAddress(source, { limit: 10, commitment }).send();  rows.forEach(show);  signature = rows.find((r) => r.err === null)?.signature;  console.log(signature ? `auditing ${signature}` : "no successful transaction in the newest 10");} catch (e) { report("getSignaturesForAddress (source)", e); }// 2. every account key with its roletype Role = { key: Address; signer: boolean; writable: boolean };const roles: Role[] = [];const programs = new Set<number>(); // account indexes that an instruction runs as its programif (signature) {  try {    // version 1: mainnet carries v1 transactions, and a lower value answers -32015 for one    const tx = await rpc.getTransaction(signature, { encoding: "json", maxSupportedTransactionVersion: 1, commitment }).send();    if (!tx) throw new Error("answered null: the transaction is not readable here");    const { header, accountKeys, instructions } = tx.transaction.message;    const signers = header.numRequiredSignatures;    accountKeys.forEach((k, i) => roles.push({      key: k,      signer: i < signers,      writable: i < signers ? i < signers - header.numReadonlySignedAccounts : i < accountKeys.length - header.numReadonlyUnsignedAccounts,    }));    // keys loaded from lookup tables never sign    for (const k of tx.meta?.loadedAddresses?.writable ?? []) roles.push({ key: k, signer: false, writable: true });    for (const k of tx.meta?.loadedAddresses?.readonly ?? []) roles.push({ key: k, signer: false, writable: false });    for (const ix of instructions) programs.add(ix.programIdIndex);    for (const r of roles) console.log(`${r.signer ? "signer    " : "non-signer"} ${r.writable ? "writable " : "read-only"} ${r.key}`);  } catch (e) { report("getTransaction", e); }}// 3. any stranger can list the history of a read-only, non-signing account key that is not a programconst probe = roles.find((r, i) => !r.signer && !r.writable && r.key !== source && !programs.has(i));if (probe) {  try {    const rows = await rpc.getSignaturesForAddress(probe.key, { limit: 5, commitment }).send();    console.log(`listed ${rows.length} signatures for read-only key ${probe.key}`);    rows.forEach(show);  } catch (e) { report("getSignaturesForAddress (probe)", e); }}process.exitCode = failed > 0 ? 1 : 0;

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts [address]

Each account key prints with its role: signer or non-signer, writable or read-only. The probe is the first read-only non-signer account key that is not the address you started from and that no instruction runs as its program. In a real checkout the reference is one of those keys, beside the mint and others, so it is not always the first. Here any such key shows the same thing: a stranger with the address gets its signatures, slots and results. Three calls at 50 cells each come to 150 cells, which fits inside the 1,024-cell burst of a rate class. Exit code 0 means every call answered, and 1 means a missing key or a failed call.

Point the script at a reference from one of your own paid test orders to see what a stranger sees. The first step prints the payment's slot and whether it succeeded, and one more read of that signature gives the payer and the amount.

05

Where it ends

  • Amounts are public. Token balances before and after sit in the transaction metadata, and no choice of reference changes that. Hiding an amount needs a different payment design, outside this audit.
  • The payer's wallet is open too. Once a payer is known, anyone can list that wallet's other transactions. A fresh reference per order does not unlink a payer from their other payments.
  • The receiving account lists every payment into it, so a stranger can count orders and add up revenue there without any reference. The reference only adds a second route to the same payments.
  • Carbium's address index keeps up to 30 days, and an empty page past that is its age limit. That bounds what this script sees. The transaction stays on chain after the index stops listing it.
  • The script reads and lists. It builds no payment, and it cannot tell whether your generator is random. Test that in the generator.
06

When it goes wrong

what goes wrongwhat to do
getTransaction answers null for a signature the list returned.The address index lists transactions older than the ones the node still stores in full. Take a newer signature, treat null as unreadable, and test the code on the newest ones.
The read fails with -32015.Pass maxSupportedTransactionVersion: 1 with an encoding. A v1 transaction is refused when the value is absent or 0.
The audit finds every payment from a list of order numbers.The reference is derived from the order id. Replace the derivation with the public key of a fresh keypair per order, and let open orders on the old scheme close.
The history of one reference shows two payers.Either the reference was reused, or a stranger sent a transaction that lists it. Match each payer and amount against your order: a second order's payment points to reuse, and an unknown payer or amount points to a stranger. Issue one reference per order, retire it after the payment, and reject any later payment that lists it.
The list for the probe key comes back empty.An unpaid reference has no history, which is expected. For a reference that was paid, the payment may be older than the 30-day address index.
The script prints no probe line.The transaction had no read-only non-signer account key besides the address you started from and the programs its instructions run. Pass another address, or one whose transactions carry a reference.
07

Questions

Can I make a Solana Pay reference private?

No. The key sits in the payment link and in the transaction, and any address can be listed. You control whether it links to anything you know: make it random, one per order, and keep the order mapping in your own database.

Does a random reference hide the payer?

No. The payer signs the transaction and is its first account key. The reference only decides what the key says about the order.

Can the reference be a hash of the order id?

A hash is as guessable as the ids it covers. Someone with a list of candidates computes the keys and lists each. Use a random key.

Does the reference need a real keypair?

It must be a valid 32-byte address. The public key of a fresh keypair is the easy way to get one, and nothing signs with the private half.

What does the audit cost?

One run draws 150 cells from your key: two address lookups and one transaction read at 50 each. A Free key's 1,024-cell burst allowance covers several runs in quick succession.