---
id: UC0104
title: "Missing-memo deposit queue"
url: https://carbium.sh/library/usecase/missing-memo-deposit-queue
collection: Use cases
category: Exchanges, custodians and on-ramps
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Missing-memo deposit queue

Split deposits to one shared Solana address by memo: credit known tags, queue the missing and unknown ones in SQLite with their fee payer, and rescan without double entries. One Node script, the call costs, and where it stops.

## Why deposits arrive without a tag

A shared deposit address gives every customer the same destination, so the memo is the only field that says whose money arrived. When it is present and matches a tag you issued, the credit is automatic. The trouble is everything else: the sender's wallet dropped the memo, the user typed a tag you never issued, an exchange withdrawal form had no memo box, or a contract paid in without a memo instruction. Those deposits are on chain, final and unclaimed.

Guessing an owner for them credits the wrong customer. The workable answer is a queue: every deposit that cannot be matched on its own is written down once, with enough detail for a person to resolve it, and nothing is credited until that person decides.

The sorting needs one call. `getSignaturesForAddress` returns each signature with a `memo` field, null when the transaction carried none, and an `err` field, null when the transaction succeeded. That gives three outcomes for a successful transaction: the memo matches an issued tag and the deposit is credited, the memo exists but matches nothing and the deposit is queued as unknown, or the memo is null and the deposit is queued as missing. A failed transaction moved no funds and is skipped.

Pick the scanned address with care. A SOL transfer lists the receiving wallet, so the shared wallet works. A token transfer into an existing token account lists the token accounts and the sender's authority, never the receiving wallet, so a token deposit is scanned on the shared token account for that mint. A wallet can own more than one token account for a mint, and each one needs its own scan.

## The queue in one file

The script reads its key from `CARBIUM_KEY` and sends every call to the [RPC endpoint](https://carbium.sh/docs/endpoints), or to `CARBIUM_RPC_URL` when you set it. The first argument is the deposit address and the second is a comma-separated list of the tags you have issued. With no address it scans the USDC mint, a busy address where most signatures have no memo, so the first run fills the queue and shows the whole path.

`main.ts` (run: `CARBIUM_KEY=$CARBIUM_KEY node main.ts <deposit-address> <tag1,tag2>`)

```ts
// UC0104 · Missing-memo deposit queue
// https://carbium.sh/library/usecase/missing-memo-deposit-queue
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only deposit sorter: count credited tags, queue missing or unknown memos in SQLite with their fee payer.
import { DatabaseSync } from "node:sqlite";
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 deposit = address(process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // the shared deposit address
const tags = new Set((process.argv[3] ?? "").split(",").filter(Boolean)); // memo tags you have issued
const limit = Number(process.env.LIMIT ?? 100);
const commitment = "finalized";

const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));
const db = new DatabaseSync("deposit-queue.db");
db.exec("CREATE TABLE IF NOT EXISTS queue (signature TEXT PRIMARY KEY, slot INTEGER, reason TEXT, memo TEXT, payer TEXT, status TEXT DEFAULT 'open')");
const add = db.prepare("INSERT OR IGNORE INTO queue (signature, slot, reason, memo) VALUES (?, ?, ?, ?)");

// 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+\] /, "").trim());

try {
  const rows = await rpc.getSignaturesForAddress(deposit, { limit, commitment }).send();
  let credited = 0, failed = 0, queued = 0;
  for (const r of rows) {
    if (r.err !== null) { failed++; continue; } // no funds moved
    const found = r.memo ? parts(r.memo) : [];
    if (found.some((m) => tags.has(m))) { credited++; continue; }
    const reason = found.length === 0 ? "missing" : "unknown";
    queued += Number(add.run(r.signature, Number(r.slot), reason, r.memo ?? null).changes);
  }
  console.log(`${rows.length} signatures: ${credited} credited, ${failed} failed, ${queued} newly queued`);
} catch (e) {
  console.error("RPC call failed:", e instanceof Error ? e.message : e);
  process.exit(1);
}

// the fee payer is the lead for support; version 1 because mainnet carries v1 transactions
const open = db.prepare("SELECT signature FROM queue WHERE payer IS NULL LIMIT 3").all() as unknown as { signature: string }[];
const reads = await Promise.allSettled(open.map((o) =>
  rpc.getTransaction(o.signature as Signature, { encoding: "json", maxSupportedTransactionVersion: 1, commitment }).send()));
const setPayer = db.prepare("UPDATE queue SET payer = ? WHERE signature = ?");
reads.forEach((res, i) => {
  const sig = open[i]!.signature;
  if (res.status === "rejected") return console.error(`read failed ${sig.slice(0, 12)}: ${res.reason}`);
  const payer = res.value ? res.value.transaction.message.accountKeys[0] : "unreadable";
  setPayer.run(payer ?? "unreadable", sig);
  console.log(`queued ${sig.slice(0, 12)}... payer ${payer}`);
});
```

The queue lives in `deposit-queue.db`, a SQLite file beside where you run the script. The signature is the primary key and the insert ignores a duplicate, so scanning the same page twice adds nothing and a rerun after a crash is safe. Credited deposits are only counted here; in a real system they go to your ledger at that point, keyed by the same signature.

After the scan, up to three queued rows with no payer are read with `getTransaction`. The first account key of a transaction is its fee payer, which is usually the sender and is the lead a support agent follows. A read that answers null or fails does not stop the others: each is settled on its own, and a null stores `unreadable` so the same three rows are not retried forever.

The read passes `maxSupportedTransactionVersion: 1`, because mainnet carries v1 transactions and the RPC answers -32015 for one when the value is absent or 0. Both calls read at finalized commitment, so a queue row never describes a transaction that can still be dropped.

## What each queued row needs

| Reason | What it means | First move |
|---|---|---|
| missing | Memo is null on a successful transaction | Read the transaction, confirm the amount that reached the deposit address, then contact the payer or match by the amount and time the customer quotes |
| unknown | A memo exists and no issued tag equals it | Compare against issued tags for a typo, a case change or a trailing space before treating it as foreign |
| unreadable | The payer column reads `unreadable` because getTransaction answered null | Keep the signature as the record and ask the sender for the transfer details |
| failed | err is set, and the script counts it and never queues it | Skip: no funds moved, nothing to claim |

A signature that mentions the deposit address is only a candidate for a deposit. Someone can list the address in a transaction that moves nothing to it, and a deposit can be a token transfer you never meant to accept. Before a row is resolved, compare the address's balance before and after in the `getTransaction` result, or the token balance fields for a token deposit, and credit only what the difference shows.

An exact match on the whole tag keeps a deposit tagged `44712` off customer `4471`, where a prefix match would credit it.

## Keeping the queue current

A scan of one page is one [signatures call](https://carbium.sh/docs/rpc) at 50 cells, and each payer read is another 50. A page can hold up to 1,000 signatures, so the cell price does not grow with the number of deposits on it. The rates below are calls per second for the method named, and every key on an account [shares one budget](https://carbium.sh/docs/limits).

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

A poll every 15 seconds is about 0.07 req/s for the scan and at most 0.2 req/s for the three payer reads, both inside the Free rate of 0.24 for one address. The three reads go out together as 150 cells, and a rate class absorbs a burst of at least 1,024 cells, so they fit on every plan.

For a steady poll, store the newest signature seen and pass it as `until`, so each call returns only what is new. When a gap is longer than one page, read with `before` from the end of the page until you reach the stored signature, or the oldest deposits in the gap are never seen.

A [logs subscription](https://carbium.sh/docs/websocket) with the deposit address as the mention streams each transaction's logs as it lands, and the Memo program's log line carries the tag. It opens at 25 credits for a logs-mentions filter and then costs 20 credits per MiB sent. The subscription finds deposits sooner, and the polled scan stays as the reconciliation that catches whatever a dropped connection missed.

## Working a row to a close

- Read the row's payer and amount from the transaction, then decide: credit a customer, refund, or hold. Write the decision and the person who made it in the status column, and never delete a row.
- Refund through your normal withdrawal path, with the original signature in the reference, so the refund and the deposit stay linked.
- When a customer claims a missing-memo deposit, ask for the sending wallet and the signature, and check both against the row before crediting.
- Count rows per reason each day. A rise in missing rows after a wallet release usually points at one sender's wallet, and the fix is a notice on the deposit page.

The prevention side lives at the deposit page: show the tag with a copy button, say plainly that the memo is required, and check the user's destination before they send. [Required-memo recipient check](https://carbium.sh/library/usecase/required-memo-recipient-check) covers that check, and [Memo instruction reader](https://carbium.sh/library/howsolana/memo-instruction-reader) decodes the memo instruction itself when you need the raw bytes.

## Where it ends

- The address index behind `getSignaturesForAddress` keeps up to 30 days, and an empty page past that is its [age limit](https://carbium.sh/docs/migrate). A deposit older than that is not found by this scan, and the address may still hold older transactions.
- The `memo` field comes from the Memo program. A deposit that carries a tag in another program's instruction data shows as missing here even though a tag exists.
- The script lists candidates and finds the payer. It does not verify the amount, credit a ledger, refund, sign or send anything.
- 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 row then has a signature and a slot but no payer.
- The fee payer is usually the sender and sometimes a relayer or an exchange's hot wallet, so a payer address is a lead for support and never a customer identity.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Every deposit lands in the queue as missing. | Check that you scan the address the transfers list. A token deposit names the token account, so scan that account for the mint, and run one scan per token account when the wallet owns several. |
| A deposit with a valid tag is queued as unknown. | Compare the memo after the length prefix is removed and the text is trimmed, and check the whole tag equals an issued one. The raw field reads `[len] text`, and several memos in one transaction are joined with a semicolon and a space. |
| The same three rows are read again on every run. | A null read must store a marker such as `unreadable` in the payer column, as the script does, so the next run moves on to other rows. |
| The payer read fails with -32015. | Pass `maxSupportedTransactionVersion: 1` with an encoding. A v1 transaction is refused when the value is absent or 0. |
| Deposits from a busy hour never reach the queue. | A single page holds only the newest signatures. Page back with `before` until you reach the stored newest signature, or raise `LIMIT` to cover the busiest interval between polls. |
| A queued row is credited twice after a retry. | Key the ledger entry on the signature as well, so the second write for the same signature is refused, and take the credit decision from the status column only. |

## Questions

### Can I tell which customer sent a deposit that has no memo?

Not from chain data alone. The payer address is a lead, and a customer who sends from a wallet you already hold in your records is the strongest one. Otherwise the sender has to tell you the signature.

### Why not credit the sender of an untagged deposit automatically?

The sender of a transfer is often an exchange or a relayer that pays for many people from one wallet. Crediting the fee payer sends money to whoever shares that wallet.

### How long does a queued row have to wait for a decision?

The chain keeps the transaction, so there is no deadline from the network. The 30-day address index is the limit to plan around, because the script can no longer list a deposit after that. Store the signature at once.

### Does the script need a paid plan?

It runs on Free at one poll every 15 seconds: one list call and at most three reads per run stay under Free's 0.24 req/s for each method. A watch over many addresses or a quick poll needs the higher req/s of a paid plan.

## Related

- [Required-memo recipient check](https://carbium.sh/library/usecase/required-memo-recipient-check) (Use cases, UC0098)
- [Memo instruction reader](https://carbium.sh/library/howsolana/memo-instruction-reader) (How to use Solana, HS0033)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/migrate](https://carbium.sh/docs/migrate)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/websocket](https://carbium.sh/docs/websocket)
