---
id: UC0108
title: "Fake token deposit filter"
url: https://carbium.sh/library/usecase/fake-token-deposit-filter
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
---

# Fake token deposit filter

How an exchange or custodian tells real USDC from a lookalike token sent to a deposit address: match the mint address, sum by owner, read finalized, and run a read-only Node script that marks each deposit CREDIT or REJECT.

## How a fake deposit looks

A deposit on Solana arrives as a token transfer into a token account you own. Nothing stops a stranger from creating a new mint, naming it USDC, giving it six decimals and the same logo, and sending a million of it to your deposit address. Explorers and wallet screens print the name and symbol from metadata that the mint's creator wrote, so the lookalike reads as USDC on screen. A deposit system that credits by symbol, or by the label in a transaction summary, books it as dollars, and the customer withdraws real funds against it.

A token has one identity on chain, its mint address. What other chains call the USDC contract is, on Solana, a mint account run by the original SPL Token program, `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`. Mainnet USDC is `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`, and every other mint that calls itself USDC is a different token. The filter below compares that address exactly and looks at nothing else to decide.

## What to match

Credit a deposit when every one of these holds. Quarantine it otherwise.

- The mint address is in an allowlist you keep in your own config, compared as an exact string. Symbol, name, decimals and logo play no part, because the creator of a fake sets all four.
- The transaction's `err` is null. A set `err` means the transaction failed and nothing moved.
- The token account's owner is your deposit wallet, and that owner's net change for the mint is positive. Sum across all of the owner's token accounts for the mint, since a wallet can hold more than one.
- The amount is read in base units as a BigInt from the `amount` string. USDC has 6 decimals, so 25.5 USDC is 25500000. The float `uiAmount` rounds.
- The read is at finalized, so the credit cannot be taken back by a fork.

> Decide per mint line, never per transaction. One transaction can carry a real USDC deposit and an unknown token dropped beside it. Credit the first and quarantine the second.

Keep the allowlist short and explicit, one address per stablecoin you accept. A Token-2022 stablecoin goes in with its own mint address, and the match works the same way.

## A filter in one file

The script takes an address to watch. It lists the five newest successful signatures with `getSignaturesForAddress`, then fetches each with `getTransaction` in `jsonParsed` encoding and `maxSupportedTransactionVersion: 1`, because mainnet carries v1 transactions and Carbium answers [-32015](https://carbium.sh/docs/errors) for one when the value is absent or 0. Both calls set `commitment: "finalized"`. @solana/kit 8.6.0 fills in `confirmed` when a call leaves commitment out, while the server's own default is finalized, so the script states it. The key goes in the [`x-api-key` header](https://carbium.sh/docs/auth) to the [RPC endpoint](https://carbium.sh/docs/endpoints), `https://services.carbium.sh`.

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

```ts
// UC0108 · Fake token deposit filter
// https://carbium.sh/library/usecase/fake-token-deposit-filter
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only: the token deposits in an address's newest transactions, each judged by its mint against the real USDC.
import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, 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 ALLOWED = new Set(["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]);
// With no argument, scan the USDC mint: its newest transactions carry USDC and, in swaps, other mints.
const watch = process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));

type Bal = { mint: string; owner?: string; uiTokenAmount: { amount: string } };
type Tx = { meta: { err: unknown; preTokenBalances?: Bal[] | null; postTokenBalances?: Bal[] | null } | null };

const page = await rpc.getSignaturesForAddress(address(watch), { limit: 5, commitment: "finalized" }).send();
const sigs = page.filter((s) => s.err === null).map((s) => s.signature);
// Mainnet carries v1 transactions: a maxSupportedTransactionVersion of 0 or none gets -32015 for one.
const got = await Promise.allSettled(sigs.map((s) =>
  rpc.getTransaction(signature(s), { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "finalized" }).send()));

let credit = 0, reject = 0;
got.forEach((r, i) => {
  const sig = sigs[i]!.slice(0, 12);
  if (r.status === "rejected") { console.log(`${sig} lookup failed: ${r.reason}`); return; }
  const meta = (r.value as unknown as Tx | null)?.meta;
  if (!meta) { console.log(`${sig} not found at finalized`); return; }
  // Net change per owner and mint; a missing pre or post entry reads as 0 on that side.
  const net = new Map<string, bigint>();
  const add = (list: Bal[] | null | undefined, sign: bigint) => {
    for (const b of list ?? []) {
      const k = `${b.owner ?? "unknown"}\t${b.mint}`;
      net.set(k, (net.get(k) ?? 0n) + sign * BigInt(b.uiTokenAmount.amount));
    }
  };
  add(meta.preTokenBalances, -1n);
  add(meta.postTokenBalances, 1n);
  let lines = 0;
  for (const [k, d] of net) {
    if (d <= 0n) continue;
    lines++;
    const [owner, mint] = k.split("\t") as [string, string];
    const ok = ALLOWED.has(mint);
    ok ? credit++ : reject++;
    console.log(`${sig} ${ok ? "CREDIT" : "REJECT"} owner ${owner.slice(0, 8)} mint ${mint} +${d}`);
  }
  if (lines === 0) console.log(`${sig} no owner gained a token`);
});
console.log(`${credit} deposit lines to credit, ${reject} to reject, from ${sigs.length} transactions of ${watch}`);
```

With no argument it reads the newest transactions that name the USDC mint. Swaps among them move other mints as well, so a run usually prints both verdicts, and a transaction in which no owner gained a token gets its own line saying so. In production you pass your deposit wallet or a deposit token account. The script prints one line per positive owner delta with the owner, the mint, the base units and CREDIT or REJECT, then a count of each. A failed lookup prints its signature and the reason, and the other lookups still finish. Nothing is signed or sent.

## Reading the result

A REJECT line is a record to keep. Store its signature, owner, mint address and amount, and show the raw mint address in your support tool so an agent can tell a customer exactly which token arrived. Deleting the row loses the evidence for the ticket that arrives a week later.

A rejected token still sits in a token account under your wallet. Keep it out of your balance and sweep logic with the same allowlist, so the funds that move on are the ones you credited.

The net per owner can hide a path. A real deposit routed through an intermediary account shows the intermediary at zero and your wallet positive, which is the number you want. A Token-2022 transfer that carries a transfer fee shows a delta below the sender's amount. Settle on the delta, since it is what landed.

## Finding the deposits

A signature list on your wallet address catches transactions that name the wallet in their account keys. That includes a fake token dropped on you with a new token account created for your wallet, which is the common way these arrive. A transfer into a token account you already hold lists that token account and the sender's authority, and the receiving wallet may not appear at all. Keep the signature lists of your deposit token accounts as well, one per accepted mint.

Carbium serves signature pages from its own [address index](https://carbium.sh/docs/migrate), which keeps up to 30 days, so a page can list a signature whose `getTransaction` answers null. The script prints those lookups and moves on. An empty page past 30 days is the index's age limit, so keep your own record of the signatures you have judged.

| Method | Cells per call | 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 |

One filter pass costs one list call plus one getTransaction per signature. The five lookups here cost 250 cells, inside the 1,024-cell burst a rate class absorbs, so they can run together. A deposit address with steady traffic needs a queue sized to your plan's getTransaction rate.

To avoid polling, open a [WebSocket](https://carbium.sh/docs/websocket) with the key as `?api-key=` in the URL and send `logsSubscribe` with a mention filter on your deposit address. Treat each notification as a prompt: take its signature and run the same check, so one code path decides every credit. A mention subscription [opens at 25 credits](https://carbium.sh/docs/limits) and then costs 20 credits per MiB sent. For a larger set of addresses see [Exchange deposit alerts](https://carbium.sh/library/usecase/exchange-deposit-alerts).

## Where it ends

- The allowlist is only as good as the addresses in it. Copy each mint address from the issuer's own published page and review changes to the list like code.
- The filter proves which mint a deposit used. It does not say who sent it or whether the sender is sanctioned. That is a separate screen.
- A lookalike whose name matches a mint you accept is caught only because you compare addresses. A [copycat name matcher](https://carbium.sh/library/si/copycat-token-name-matcher) helps when you list tokens for users to see.
- The script reads the newest five signatures. A busy deposit address needs paging and your own checkpoint of the last signature judged.
- The script is read-only. Crediting the account, quarantining a row and moving funds belong to your own ledger.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| A deposit is credited because its token shows the symbol USDC. | Symbol and name are metadata the mint's creator chooses. Credit only when the mint address is in your allowlist. |
| A real deposit is quarantined, or a fake credited, because the whole transaction got one verdict. | Judge each owner and mint line on its own. One transaction can carry both a real and an unknown token. |
| An amount of 25.5 fails or passes by rounding when compared as a float. | Read `uiTokenAmount.amount` as a BigInt in base units. USDC has 6 decimals, so 25.5 is 25500000. |
| The signature list of the account misses a deposit into an existing token account. | That transfer lists the token account and the sender's authority. List signatures on each deposit token account as well. |
| getTransaction fails with -32015 on a v1 transaction. | Pass `maxSupportedTransactionVersion: 1` on every getTransaction call. With the value absent or 0, Carbium answers -32015 for a v1 transaction. |
| getTransaction answers null for a signature the list returned, and the deposit is taken as missing. | The address index reaches below the validator's ledger floor, so an older signature can list yet not fetch. Handle null, retry the check later and keep your own record of judged signatures. |

## Questions

### Can I trust the symbol or name in a transaction summary to spot USDC?

No. Both come from metadata the mint's creator writes, so a lookalike copies them. Compare the mint address with your allowlist.

### Do I need to fetch the mint account to run the filter?

No. The token balance record already carries the mint address, and the allowlist comparison needs nothing more. The decision is a string match.

### Why does a deposit I expected never show in my account's signature list?

A transfer into an existing token account lists that token account and the sender's authority. List signatures on the token account too.

### How many transactions can the check read each second?

getTransaction costs 50 cells. That is 1.2 req/s on Dev, 5 on Business and 25 on Pro, and 0.24 on Free.

### Should rejected deposits be deleted?

Keep them with the signature, owner, mint and amount. Support will need the raw mint address when the customer asks where the deposit went.

## Related

- [Exchange deposit alerts](https://carbium.sh/library/usecase/exchange-deposit-alerts) (Use cases, UC0006)
- [Copycat token name matcher](https://carbium.sh/library/si/copycat-token-name-matcher) (AI and blockchain, SI0037)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/websocket](https://carbium.sh/docs/websocket)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/migrate](https://carbium.sh/docs/migrate)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
