---
id: UC0142
title: "Points resale detector"
url: https://carbium.sh/library/usecase/points-resale-detector
collection: Use cases
category: Loyalty, rewards and memberships
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Points resale detector

A mint you issue cannot stop a holder's transfer by itself. The token settings that do have to be chosen at creation. Then a read-only watcher lists each transfer of your mint, names the receiving wallet and flags moves that leave a listed holder.

## What an issuer can and cannot block

The rule that stops a holder from moving points has to be set on the mint, and the mint authority alone cannot provide it. The mint authority controls supply. It has no say over what a holder does with tokens already in a wallet. Three settings on a mint do reach holder transfers, and they belong to the mint's setup, so decide them before the first points are issued.

- `NonTransferable`, a Token-2022 extension. Every transfer of the mint fails. It suits points that must never change hands.
- A freeze authority. It can freeze one holder's token account, which stops that account from sending or receiving. It does not undo a transfer already confirmed, and the freeze covers every token in the account.
- A permanent delegate, a Token-2022 extension. The delegate can move tokens out of any holder's account. Holders can see it on the mint, so state it in your terms before you use it.

If you keep the points transferable, the job becomes watching. The rest of this entry reads each transfer, names the receiving wallet and leaves the decision to your rules.

## Read the moves out of a mint

A transfer is an instruction to the token program. Most wallets send `transferChecked` for a mint with decimals, and that instruction names the mint, the source token account, the destination token account and the authority that signed. A plain `transfer` names no mint, so a watcher that filters on the mint reads only `transferChecked`. Carry that limit into your reading of the output.

The destination is a token account, and the instruction does not name the wallet that owns it. A token transfer to an existing token account lists the token accounts and the sender's authority, never the receiving wallet. The watcher reads the destination account with `getAccountInfo` in `jsonParsed` form and takes its owner. That owner is the wallet a resale reaches.

The signatures come from the mint's address history on the [RPC endpoint](https://carbium.sh/docs/endpoints). Each call states its commitment level as `confirmed`, because the server defaults to `finalized` when a call leaves commitment out. Each transaction is read with `maxSupportedTransactionVersion: 1`, since mainnet carries v1 transactions and [getTransaction](https://carbium.sh/docs/rpc) answers -32015 without that setting for a v1 transaction.

The address history keeps up to 30 days. Its pages reach below the validator's ledger floor, so a [getTransaction](https://carbium.sh/docs/rpc) for an old signature in that list can answer null. The watcher skips it and says so.

## A read-only watcher in one file

The file takes the mint as its argument and reads the holder wallets you list in `HOLDERS`. It prints each transfer with its amount, its signing authority and the owner of its destination, and it flags a move that leaves a listed holder for a wallet outside the list. It signs nothing and sends nothing. The key is read from `CARBIUM_KEY` and sent in the `x-api-key` header on each call, as the [auth page](https://carbium.sh/docs/auth) sets out.

`main.ts` (run: `CARBIUM_KEY=$CARBIUM_KEY HOLDERS=<holder1>,<holder2> node main.ts <mint>`)

```ts
// UC0142 · Points resale detector
// https://carbium.sh/library/usecase/points-resale-detector
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only watcher: reads recent transferChecked moves of one mint and flags any that leave a listed holder.
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 mint = process.argv[2];
if (!mint) { console.error("Pass the mint address as the first argument."); process.exit(1); }
const holders = new Set((process.env.HOLDERS ?? "").split(",").filter(Boolean));
const limit = Number(process.env.MAX_TX ?? 5);

let nextId = 1;
async function rpc(method: string, params: unknown[]): Promise<any> {
  const res = await fetch(url, {
    method: "POST",
    headers: { "content-type": "application/json", "x-api-key": key! },
    body: JSON.stringify({ jsonrpc: "2.0", id: nextId++, method, params }),
  });
  if (res.status === 429) throw new Error(`${method} 429, retry after ${res.headers.get("retry-after")} s`);
  const out = await res.json();
  if (out.error) throw new Error(`${method} ${out.error.code}: ${out.error.message}`);
  return out.result;
}

const sigs: { signature: string; err: unknown }[] = await rpc("getSignaturesForAddress", [mint, { limit, commitment: "confirmed" }]);
const reads = await Promise.allSettled(sigs.filter((s) => !s.err).map(async (s) => ({
  sig: s.signature,
  tx: await rpc("getTransaction", [s.signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" }]),
})));

const hops: { sig: string; source: string; authority: string; destination: string; amount: string }[] = [];
for (const r of reads) {
  if (r.status === "rejected") { console.error("read failed:", r.reason instanceof Error ? r.reason.message : r.reason); continue; }
  const { sig, tx } = r.value;
  if (!tx) { console.log(`${sig.slice(0, 12)} null, skipped`); continue; }
  const ixs = [...tx.transaction.message.instructions, ...(tx.meta?.innerInstructions ?? []).flatMap((i: any) => i.instructions)];
  for (const ix of ixs) {
    const p = ix.parsed;
    if (ix.program !== "spl-token" || p?.type !== "transferChecked" || p.info.mint !== mint) continue;
    hops.push({ sig, source: p.info.source, authority: p.info.authority, destination: p.info.destination, amount: p.info.tokenAmount.uiAmountString });
  }
}

for (const h of hops) {
  const acc = await rpc("getAccountInfo", [h.destination, { encoding: "jsonParsed", commitment: "confirmed" }]).catch(() => null);
  const owner: string = acc?.value?.data?.parsed?.info?.owner ?? "unknown";
  const flag = holders.has(h.authority) && !holders.has(owner) ? "FLAG: leaves a listed holder" : "";
  console.log(`${h.sig.slice(0, 12)} ${h.amount} from ${h.authority.slice(0, 8)} to ${owner.slice(0, 8)} ${flag}`.trimEnd());
}
console.log(`${sigs.length} signatures read, ${hops.length} transferChecked moves of this mint, ${holders.size} listed holders`);
```

The run passes USDC, a busy mint, so the output has transfers to show. Point the argument at your own mint and list your holders in `HOLDERS` to see flags. Each read goes through `Promise.allSettled`, so one failed `getTransaction` prints one line and the rest still print. Cost follows the calls: the signature list is 50 cells, each transaction is 50 cells and each owner lookup is 10 cells, so `MAX_TX` sets the price of a run. It defaults to 5.

A Free key has a low per-second allowance for the 50-cell classes. A call over its rate waits once. When it stays over, it gets 429 with a retry-after hint, which the watcher prints as a failed read. The [limits page](https://carbium.sh/docs/limits) sets out each plan's rates.

## Decide what a flag triggers

A flag records a transfer. It does not decide one. A holder may have sent points to their own second wallet, to a friend, or to a merchant you approved, and the output cannot tell these apart. Settle the response before the first alert, so that a flag leads to a known step.

- Store the signature with the flag, so the transfer can be checked on chain later.
- Match the receiving wallet against the customer records you hold. A wallet linked to the same customer is not a resale.
- Freeze or move points only where the authority was set at creation and your terms say so. A freeze needs the freeze authority to sign, and this watcher signs nothing.
- Tell the holder what moved, when, and which rule applies, in the words your terms use.

## Where it ends

- The watcher reads `transferChecked` only. A plain `transfer` names no mint, so it is missing from the output.
- The output covers the newest signatures in the mint's address history, which keeps up to 30 days. An empty page past that marks the index's age limit, and older resales need a history of your own.
- A `getTransaction` can answer null for a signature the index lists, and the watcher skips it. The printed count can be lower than the count read.
- Flags follow the `HOLDERS` list. A transfer from a wallet not on the list is never flagged, and a gift or a move between a holder's own wallets looks the same as a sale.
- A mint issued without `NonTransferable` or a permanent delegate cannot take one later, so plan those settings before the first issue.
- Points that moved before the watcher ran are not reported. Run it on a schedule you control, and store each run's output.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The mint was issued as a plain SPL token, and the team expects the authority to stop resale. | A plain SPL mint has no transfer rule. Set NonTransferable or a freeze authority at creation, or keep the points transferable and run the watcher. |
| getTransaction answers null for a signature the address history lists. | Treat null as not served. Skip it, count it, and do not retry: the signature sits below the ledger floor or past the index's 30 days. |
| getTransaction answers -32015 for a transaction or block. | Pass maxSupportedTransactionVersion: 1 with the jsonParsed encoding. Without it, a v1 transaction is refused. |
| A Free key gets 429 on several transaction reads in a row. | Lower MAX_TX, or wait the retry-after value the 429 names. A read that keeps failing shows as a failed line and does not stop the run. |
| Every move out of a holder's account is printed as a sale. | Flags are a prompt for review. Match the receiving wallet against your records before any freeze or notice. |
| A plain transfer instruction is missing from the output. | The watcher reads mint-named instructions only. Count plain transfers in a separate check on the holder's token account, and record the gap. |

## Questions

### Can I stop a holder from moving points I issued as a normal SPL token?

Not with the mint authority, which controls supply and nothing else on a holder's account. A freeze authority can stop one holder's account, but only if it was set when the mint was created.

### Does the watcher block a transfer?

No. It reads signatures that have already confirmed and prints them. It signs and sends nothing, so it cannot stop a move.

### Why does the output name an owner for the destination?

The transfer names the destination token account, not the wallet that owns it. The watcher reads that account and takes its owner, which is the wallet a resale reaches.

### How far back does the watcher look?

The address history keeps up to 30 days. For an older move, keep your own history or use a source that holds it.

## Related

- [Token authority screening](https://carbium.sh/library/usecase/token-authority-screening) (Use cases, UC0009)
- [Token program detection](https://carbium.sh/library/howsolana/token-program-detection) (How to use Solana, HS0025)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
