---
id: UC0064
title: "Deposit ATA coverage check"
url: https://carbium.sh/library/usecase/deposit-ata-coverage-check
collection: Use cases
category: Exchanges, custodians and on-ramps
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Deposit ATA coverage check

Check that every deposit wallet has a token account for each mint you accept. The script derives the addresses, reads them 100 at a time, prints exists or missing per cell, and prices the accounts you still have to create.

## Derive, do not generate

A Solana wallet has one address, and each token it holds sits in a separate token account. The address of that account is computed from three inputs: the wallet, the token program that owns the mint, and the mint. The result is the associated token address. The same inputs give the same answer on any machine, and no server is asked.

So no new address is needed for USDC or USDT. An exchange or on-ramp that gives each customer one deposit wallet generates nothing extra for USDC or USDT. It computes the token address whenever it needs it, even before the customer has received a single token. [Associated token address lookup](https://carbium.sh/library/howsolana/associated-token-address-lookup) walks through the derivation for one wallet.

What needs action is the account at that address. A computed address is only a name until a transaction creates an account there, and a transfer to an address with no account fails unless the same transaction creates it first. Coverage means that for every deposit wallet and every mint you accept, the account exists.

## Who pays the rent

Every account holds a minimum balance, the rent-exempt reserve, sized by its data length. A standard token account is 165 bytes, and its reserve is 1,488,440 lamports, about 0.00149 SOL. The payer named in the creation instruction funds it, and the reserve goes back to whichever account the close names once the balance is zero. [Rent-exempt minimum calculator](https://carbium.sh/library/howsolana/rent-exempt-minimum-calculator) computes it for any size.

Two parties can pay. Many wallets and swap interfaces notice a missing token account and add the creation instruction to the sender's transaction, so the sender pays. A sender that does not, such as a program or a plain payout script, sees the transfer fail. For an exchange the safe choice is to create the account yourself before the deposit address goes out. An on-ramp paying out to a customer's wallet follows the same rule: the account must exist, or your payout transaction must carry the creation.

The cost scales with the grid. 100,000 deposit wallets accepting two mints are 200,000 accounts, about 298 SOL in reserves. That figure decides whether you create every account when the address is assigned or on the customer's first request for a given mint.

## The coverage matrix

Lay the check out as a grid with one row per deposit wallet and one column per mint. Each cell is one derived address, and the script prints one of three states for it.

| Cell | What it means | What you do |
|---|---|---|
| exists | An account owned by the mint's token program sits at the derived address | Nothing |
| missing | No token account at the address | Create it, funded from your own account, before the address goes out |
| unchecked | The chunk holding this cell failed to read | Run the check again |

An address that holds something owned by another program, such as a system account that received SOL, prints as missing too, because it is not a token account yet.

The grid grows as wallets times mints. 1,000 wallets and two mints are 2,000 addresses, which is 20 reads of 100.

## One batched existence check

`getMultipleAccounts` reads up to 100 accounts in one call, and the script asks for no account data, only whether the account exists and which program owns it. Pass wallets as arguments. With none, the script takes the owners from the newest USDC transactions: it lists recent signatures that mention the USDC mint with `getSignaturesForAddress`, then reads transactions with `getTransaction` until it holds 8 owners. It sets `maxSupportedTransactionVersion` to 1 so a version 1 transaction reads, and it skips a null answer.

It reads the two mints first to learn which token program owns each, derives every cell, and checks the cells in chunks of 100. Every read runs at confirmed commitment. Calls go to the [RPC endpoint](https://carbium.sh/docs#endpoints) through one client, and a failed chunk prints its error while the others finish.

`main.ts` (run: `CARBIUM_KEY=$CARBIUM_KEY node main.ts [<wallet> ...]`)

```ts
// UC0064 · Deposit ATA coverage check
// https://carbium.sh/library/usecase/deposit-ata-coverage-check
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only: derives each wallet's associated token address for USDC and USDT, reads them in batches of 100, prints exists or missing, prices the gaps.
import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressEncoder, getProgramDerivedAddress, type Address } 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 rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({
  url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key } }));
const ATA_PROGRAM = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const MINTS = { USDC, USDT: address("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB") };
const NAMES = Object.keys(MINTS) as (keyof typeof MINTS)[];
const PER_CALL = 100, ACCOUNT_BYTES = 165n;
const opts = { encoding: "base64", commitment: "confirmed", dataSlice: { offset: 0, length: 0 } } as const; // existence and owner only
const enc = getAddressEncoder();
const derive = async (owner: Address, program: Address, mint: Address) => (await getProgramDerivedAddress({
  programAddress: ATA_PROGRAM, seeds: [enc.encode(owner), enc.encode(program), enc.encode(mint)] }))[0];

async function newestUsdcOwners(): Promise<Address[]> {
  const owners = new Set<Address>();
  const sigs = await rpc.getSignaturesForAddress(USDC, { limit: 10, commitment: "confirmed" }).send();
  for (const s of sigs) {
    if (s.err || owners.size >= 8) continue;
    try {
      const tx = await rpc.getTransaction(s.signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" }).send();
      for (const b of tx?.meta?.postTokenBalances ?? []) if (b.mint === USDC && b.owner) owners.add(b.owner);
    } catch (e) { console.error(`getTransaction ${s.signature}: ${(e as Error).message}`); break; }
  }
  return [...owners].slice(0, 8);
}

async function main() {
  const wallets = process.argv.length > 2 ? process.argv.slice(2).map((a) => address(a)) : await newestUsdcOwners();
  if (!wallets.length) { console.error("No wallets found: pass addresses as arguments."); process.exit(1); }
  const mints = await rpc.getMultipleAccounts(NAMES.map((n) => MINTS[n]), opts).send();
  const programs = mints.value.map((m, i) => { if (!m) throw new Error(`${NAMES[i]} mint not found`); return m.owner; });
  const cells = await Promise.all(wallets.flatMap((wallet) => NAMES.map(async (name, i) => ({
    wallet, name, program: programs[i]!, ata: await derive(wallet, programs[i]!, MINTS[name]) }))));
  const exists = new Map<Address, boolean>();
  for (let i = 0; i < cells.length; i += PER_CALL) {
    const part = cells.slice(i, i + PER_CALL);
    try {
      const r = await rpc.getMultipleAccounts(part.map((c) => c.ata), opts).send();
      part.forEach((c, j) => exists.set(c.ata, r.value[j]?.owner === c.program));
    } catch (e) { console.error(`batch at ${i} failed: ${(e as Error).message}`); }
  }
  let missing = 0;
  for (const wallet of wallets) {
    const row = cells.filter((c) => c.wallet === wallet).map((c) => {
      const ok = exists.get(c.ata);
      if (ok === false) missing++;
      return `${c.name} ${ok === undefined ? "unchecked" : ok ? "exists" : "missing"}`;
    });
    console.log(wallet, row.join("  "));
  }
  const rent = await rpc.getMinimumBalanceForRentExemption(ACCOUNT_BYTES).send();
  console.log(`${missing} missing x ${rent} lamports = ${BigInt(missing) * rent} lamports to fill the gaps`);
}
main().catch((e) => { console.error(e instanceof Error ? e.message : e); process.exit(1); });
```

The last line gives the count of missing cells, the reserve for one 165 byte account from `getMinimumBalanceForRentExemption`, and the total in lamports.

The cost sits in the batch. [`getMultipleAccounts` charges 10 cells per pubkey](https://carbium.sh/docs#rpc): 1000 cells for 100 pubkeys, and 1001 when the request body passes 4 KiB. Pro calls can carry up to 300 pubkeys; below Pro the [1,024-cell burst](https://carbium.sh/docs#limits) caps a call at 100, so the script sends 100. Account reads run at 0.5, 15, 50 and 400 requests per second on Free, Dev, Business and Pro. The discovery path adds one `getSignaturesForAddress` call and up to 10 `getTransaction` calls at 50 cells each.

## Token-2022 mints derive under their own program

The token program is the middle seed, so one wallet and one mint give a different address under the original token program and under Token-2022. A mint belongs to exactly one of them, and the owner field of the mint account says which. The script reads that field for each mint and uses it as the seed, so a Token-2022 mint added to `MINTS` derives correctly with no other change. Derive under the wrong program and every cell reads missing, because nothing lives at that address.

The reserve changes too. Associated accounts under Token-2022 are larger than 165 bytes, because they always carry an extension that locks the owner, and a mint's own extensions, a transfer fee for one, add more. The script's 165 bytes is the floor for the original program. For a Token-2022 mint, size the account from the mint's extensions and price that size.

## Where it ends

- The check reads existence only. It reports no balances and watches no arrivals; [Exchange deposit alerts](https://carbium.sh/library/usecase/exchange-deposit-alerts) covers the arrival side.
- It creates nothing. Creating an account is a signed transaction paid from your own funding account, which stays in your signing service.
- The script ships with USDC and USDT. Add any other mint after checking its address against the issuer, since a wrong mint derives valid-looking addresses for a token you do not accept.
- A wallet can own more than one token account for one mint. Only the associated one counts here, and a customer who sent to another account needs a sweep, which this check does not cover.
- Coverage decays. An owner can close an empty token account, so run the check again before a campaign or a batch of assignments. [Closed account detection](https://carbium.sh/library/howsolana/closed-account-detection) covers spotting one.
- The address-less fallback samples up to 8 owners from the newest USDC transactions. The signature index behind it keeps up to 30 days, and a listed signature can still come back null from `getTransaction`.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| A transfer to the derived address fails with an invalid account error. | No account exists there yet. Create it with an idempotent creation instruction funded from your own account, then run the check again. |
| Every cell reads missing for a mint whose accounts you can see in an explorer. | The cell was derived under the wrong token program. Read the owner of the mint account and use it as the middle seed, as the script does. |
| `getTransaction` answers -32015 when you add your own transaction reads. | Set `maxSupportedTransactionVersion` to 1 on the call. Absent or 0, a version 1 transaction is refused. |
| `getMultipleAccounts` answers 429, or a call with more than 100 pubkeys is refused on a plan below Pro. | Keep each call at 100 pubkeys or fewer and wait out the retry-after hint. The script prints the failed chunk and its address range stays unchecked. |
| The fallback finds no wallets, or stops early with an error from `getTransaction`. | Pass wallets as arguments. The fallback reads only the newest signatures, and a transaction read can answer null or 429 under a low rate. |
| The printed rent is too low for a Token-2022 mint. | The 165 byte figure fits the original token program. Size the account from the mint's extensions and ask `getMinimumBalanceForRentExemption` for that length. |

## Questions

### Does a customer need a different deposit address for each token?

No. The customer has one wallet address, and each token account address is derived from it. Most wallets work out the token account on their own when you give them the wallet address, and create it if the sender pays.

### Can I skip creating accounts and let the sender pay?

Many wallets add the creation instruction for the sender, so it often works. A sender that does not add it sees a failed transfer, and creating the account ahead removes that failure.

### Why one batched read when `getAccountInfo` exists?

Both charge 10 cells per account. One call for 100 accounts is one round trip instead of 100, and it returns existence and owner for every cell together.

### How many wallets can one run cover?

Each call checks 100 addresses, so 50 wallets for two mints. A larger set runs as more chunks, and the script loops over them in sequence.

## Related

- [Associated token address lookup](https://carbium.sh/library/howsolana/associated-token-address-lookup) (How to use Solana, HS0022)
- [Exchange deposit alerts](https://carbium.sh/library/usecase/exchange-deposit-alerts) (Use cases, UC0006)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
