services
Get a key

library / Use cases / UC0022

Memo payment lookup

Find the Solana transaction that carries a given memo: why no RPC method searches memo text, how to scan an address's signatures for it, what each page costs, and a Node script that matches the memo and reads the transaction.

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

02

The lookup 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 first argument is the address to scan and the second is the memo text. With no memo it takes the newest memo it finds on the address, which shows the whole path working before you have an order to look for. PAGES sets how many pages of 200 signatures it will read, 3 by default.

main.ts
// UC0022 · Memo payment lookup// https://carbium.sh/library/usecase/memo-payment-lookup// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only memo lookup: scan an address's recent signatures for a memo, then read the matching transaction.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, 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 where = address(process.argv[2] ?? "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"); // address the payment toucheslet needle: string | undefined = process.argv[3]; // memo text to find; unset takes the newest memo on the addressconst pages = Number(process.env.PAGES ?? 3);const commitment = "finalized";const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));// a memo field reads "[len] text", and several memos in one transaction are joined with "; "const parts = (memo: string) => memo.split("; ").map((p) => p.replace(/^\[\d+\] /, ""));try {  let before: Signature | undefined;  for (let page = 1; page <= pages; page++) {    const rows = await rpc.getSignaturesForAddress(where, { limit: 200, before, commitment }).send();    if (rows.length === 0) { console.log("empty page: end of the address index"); break; }    needle ??= rows.flatMap((r) => (r.memo ? parts(r.memo) : []))[0];    before = rows[rows.length - 1]!.signature;    if (needle === undefined) continue; // no memo on this page yet    const text = needle;    const hits = rows.filter((r) => r.memo && parts(r.memo).includes(text));    console.log(`page ${page}: ${rows.length} signatures, ${hits.length} match ${JSON.stringify(text.slice(0, 60))}`);    if (hits.length === 0) continue;    const hit = hits[hits.length - 1]!; // oldest match on the page    console.log(`match ${hit.signature} slot ${hit.slot} ${hit.err === null ? "succeeded" : "failed"}`);    // version 1: mainnet carries v1 transactions, and a lower value answers -32015 for one    const tx = await rpc.getTransaction(hit.signature, { encoding: "json", maxSupportedTransactionVersion: 1, commitment }).send();    if (!tx) {      console.error("getTransaction answered null: the transaction is not readable here");      process.exit(3);    }    console.log(`read: fee ${tx.meta?.fee} lamports, ${tx.transaction.message.accountKeys.length} accounts`);    process.exit(0);  }  console.error("no match in the pages scanned");  process.exit(2);} catch (e) {  console.error("RPC call failed:", e instanceof Error ? e.message : e);  process.exit(1);}

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts <address> "<memo text>"

A memo field reads [10] order-4471, with the length in front, and a transaction that carries several memos joins them with ; . The script splits the field into its parts, strips the length from each and compares the whole part with your text. It stops at the first page that holds a match, or at an empty page, or after PAGES pages. A hit is then read with getTransaction, and the script prints the fee and the account count.

The read passes maxSupportedTransactionVersion: 1, because mainnet carries v1 transactions and the RPC answers -32015 for one when the value is absent or 0. When getTransaction answers null the script prints a plain message and exits 3. Exit code 0 means a match was found and read, 2 means no match in the pages scanned, 3 means a match whose transaction could not be read, and 1 means a missing key or a failed call.

Both calls read at finalized commitment, so a matched payment is final before you release the goods.

03

Cost and paging

One page of signatures and one transaction read each cost 50 cells. The rates below are calls per second for the method named, and all keys on an account share one budget.

CallCellsFree req/sDev req/sBusiness req/sPro req/s
getSignaturesForAddress500.241.2100500
getTransaction500.241.2525

A lookup that reads three pages and one transaction is four calls and 200 cells. A rate class absorbs a burst of at least 1,024 cells, about 20 of these calls, so a lookup's 200 cells fit inside the burst on every plan.

Rescanning the same pages on every check wastes that budget. Keep the newest signature you have seen for the address and pass it as until on the next call, so each poll returns only the entries added since. One call per address per poll then covers every open order on it: collect the new memos and match all pending order ids against them in one pass. At one poll every 5 seconds an address costs 0.2 req/s, which the Free rate of 0.24 covers for one address, Dev at 1.2 for six and Business at 100 for 500.

When polling stops being enough, subscribe instead. A logsSubscribe with the address as the mention streams each transaction's logs, and the Memo program's log line carries the text, so the match runs on the notification with no scan at all. A subscription opens at 25 credits for a logs-mentions filter and then costs 20 credits per MiB sent. After a match, read the transaction once and check it as you would after a scan.

04

Write the memo so it can be found

  • Put one unique id in every order, such as order-4471, and match the whole id. A substring test finds order-12 inside order-123.
  • Keep the memo short and free of personal data. It is public on chain for good, and every explorer shows it.
  • Treat the memo as a claim. Anyone can write your order id into a memo, so the match only locates the transaction. The amount, the recipient and the success flag come from getTransaction.
  • When the wallet can add an account to the transfer, a fresh reference key per order is a sturdier handle than text, because the signature list of that key holds the payment alone. Solana Pay confirmation builds the check around it.
  • Write the matched signature to your own database at once, next to the order, so later reads never depend on a scan.

The same scan feeds a ledger of incoming payments. Postgres deposit matching shows the database side of matching what you read to what you expect.

05

Where it ends

  • The address index behind getSignaturesForAddress keeps up to 30 days, and an empty page past that is its age limit. A memo older than 30 days is not found by this route, and the address may still hold older transactions.
  • Only text written through the Memo program appears in the memo field. A payment that carries its order id in another program's instruction data has no memo to match.
  • The scan covers the address you give it. A payment sent to a different token account of the same wallet never shows up there, and a busy address needs more pages than PAGES allows.
  • The signature list can name transactions older than the ones the node still stores in full, so getTransaction can answer null for an older signature. The script reports that and stops; a signature you stored when you first found it is the only record for those.
  • The script reads and matches. It does not check the amount, build the payment or sign anything.
06

When it goes wrong

what goes wrongwhat to do
The payment landed but the scan finds no memo.Check the address first: for a token payment, scan the merchant's token account for the mint. Then check that the wallet really added a Memo instruction, and raise PAGES if the address is busy.
Order order-12 is matched to the payment for order-123.Compare the whole memo part for equality, as the script does, and give every order a unique id that no other id contains.
An old order shows as never paid.The address index keeps up to 30 days. Save the signature when you first find it and reconcile older orders from your own record.
getTransaction answers null for a signature the scan listed.The page came from the address index, which lists transactions older than the ones the node still stores in full. Treat null as unreadable, keep the signature you stored, and expect it on older signatures: test the code on recent ones.
The read fails with -32015.Pass maxSupportedTransactionVersion: 1 with an encoding. A v1 transaction is refused when the value is absent or 0.
Every open order scans on its own and 429s start.Poll once per address with until set to the newest signature seen, and match all open ids in that one pass. Sleep for the retry-after value after a 429.
07

Questions

Is there an RPC method that searches by memo text?

No. The methods look up by signature, block or address. Scan the signatures of the address the payment touched and compare the memo field of each, which is what the script does.

Why does the memo come back as "[10] order-4471"?

The number is the length of the memo, written in front of the text. Strip it before comparing, and split on ; when a transaction carries more than one memo.

Can I scan the merchant's wallet to find a USDC payment?

Not reliably. Scan the merchant's token account for that mint, and run one scan per token account when the wallet holds several.

What does one lookup cost?

Each page of signatures is 50 cells and the transaction read is 50 more. Three pages and one read come to 200 cells.