services
Get a key

library / Use cases / Exchanges, custodians and on-ramps / UC0106

Deposit address alias map

See every address tied to one deposit wallet. The script lists its token accounts under both token programs, derives the expected associated address for each mint, and prints which accounts are the associated one and which are extras.

By Carbium · Exchanges, custodians and on-ramps · UC0106 · updated 2026-11-23

01

One keypair, one address

A Solana keypair is a private key and the public key computed from it. The public key, written in base58, is the wallet address. Each keypair has exactly one, so it cannot own a second wallet address. Looking for another address for the same key finds nothing, because the address is the key.

What people run into is a set of other addresses around that one. Each is a separate account with its own address and its own owner field, and the keypair controls it only because that account names the keypair as its owner or authority. For an exchange or custodian handing out deposit addresses, this decides the design: you store one key per customer wallet, and a table that maps every related account address back to that wallet.

02

Where the other addresses come from

Five kinds of address show up next to a wallet. Only the first is the key itself.

KindHow the address is madeWho controls it
Wallet addressThe public key of the keypairThe keypair signs
Associated token accountDerived from the wallet, the token program and the mintThe wallet is its owner and signs transfers out
Extra token accountCreated at a fresh address for the same mint with the same ownerThe same wallet
Seeded accountDerived from a base key, a seed string and the owning programThe base key while the System Program owns it, otherwise the owning program
Program derived addressDerived from a program and seeds, off the curveOnly the program signs for it

The associated token account is the one you will meet most. Its address is a pure function of three inputs, so any machine computes it without asking a node, and the same inputs always give the same address. Associated token address lookup walks through the derivation for one wallet.

A wallet can also own more than one token account for a single mint. Anyone can create another account for that mint and name your wallet as its owner, and a sender can pick any of them. Deposits then land at an address you did not derive, even though the wallet is yours.

03

Building the alias map

The script takes a wallet as its argument and lists every token account that wallet owns, once under the original token program and once under Token-2022. For each account it reads the mint and the balance, derives the associated address for that wallet and mint under the same program, and compares. A match prints as associated, anything else prints as extra.

With no argument, it finds a wallet at run time. It lists the newest signatures that mention the USDC mint with getSignaturesForAddress, reads transactions with getTransaction until one shows a token balance owner for USDC, and uses that owner. It sets maxSupportedTransactionVersion to 1 so a version 1 transaction reads, and it skips a null answer. Every read runs at confirmed commitment, and the calls go to the RPC endpoint through one client.

main.ts
// UC0106 · Deposit address alias map// https://carbium.sh/library/usecase/deposit-address-alias-map// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only alias map: every token account one wallet owns, labelled associated or extra against the address derived for its mint.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressEncoder, getProgramDerivedAddress, type Address } from "@solana/kit";const apiKey = process.env.CARBIUM_KEY;if (!apiKey) { console.error("Set CARBIUM_KEY to your Carbium API key."); process.exit(1); }const client = createSolanaRpcFromTransport(createDefaultRpcTransport({  url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": apiKey } }));const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const ASSOCIATED_PROGRAM = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");const TOKEN_PROGRAMS: Record<string, Address> = {  "spl-token": address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),  "token-2022": address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),};const codec = getAddressEncoder();async function expectedAddress(owner: Address, tokenProgram: Address, mint: Address): Promise<string> {  const [pda] = await getProgramDerivedAddress({    programAddress: ASSOCIATED_PROGRAM,    seeds: [codec.encode(owner), codec.encode(tokenProgram), codec.encode(mint)],  });  return pda;}async function pickWallet(): Promise<Address> {  const recent = await client.getSignaturesForAddress(USDC, { limit: 10, commitment: "confirmed" }).send();  for (const { signature, err } of recent) {    if (err) continue;    const tx = await client.getTransaction(signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" })      .send().catch(() => null);    const hit = tx?.meta?.postTokenBalances?.find((bal) => bal.mint === USDC && bal.owner);    if (hit?.owner) return hit.owner;  }  throw new Error("No wallet found in the newest USDC transactions: pass one as an argument.");}const wallet = process.argv[2] ? address(process.argv[2]) : await pickWallet();console.log(`wallet ${wallet}`);console.log(`USDC associated address ${await expectedAddress(wallet, TOKEN_PROGRAMS["spl-token"]!, USDC)}`);const rows: string[] = [];const seenMints = new Set<string>();let extraCount = 0;for (const [label, program] of Object.entries(TOKEN_PROGRAMS)) {  try {    const { value } = await client.getTokenAccountsByOwner(wallet, { programId: program }, { encoding: "jsonParsed", commitment: "confirmed" }).send();    for (const { pubkey, account } of value) {      const { mint, tokenAmount } = account.data.parsed.info as { mint: Address; tokenAmount: { uiAmountString: string } };      const isAssociated = (await expectedAddress(wallet, program, mint)) === pubkey;      seenMints.add(mint);      if (!isAssociated) extraCount++;      rows.push(`${isAssociated ? "associated" : "extra"} | ${label} | ${pubkey} | ${mint} | ${tokenAmount.uiAmountString}`);    }  } catch (e) {    console.error(`${label} read failed: ${e instanceof Error ? e.message : e}`);  }}rows.sort();rows.forEach((r) => console.log(r));console.log(`${rows.length} token accounts, ${seenMints.size} mints, ${extraCount} extra`);

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

The first two lines show the wallet and its USDC associated address under the original token program. Each row after them gives the label, the program, the token account, the mint and the balance, sorted so associated rows come first, and the last line counts accounts, distinct mints and extras. If one program's read fails, its error prints and the other still finishes.

The discovery path costs one `getSignaturesForAddress` call at 50 cells and up to 10 getTransaction calls at 50 cells each. getSignaturesForAddress is served at 0.24, 1.2, 100 and 500 requests per second on Free, Dev, Business and Pro, and getTransaction at 0.24, 1.2, 5 and 25. The loop sends its transaction reads back to back, so on a Free key the second and later reads can get 429, and the script skips each one as if it had come back null. Passing a wallet skips the discovery calls.

04

Storing the map for deposits

Give each customer one wallet, and keep the keypair or its derivation in your signing service. For every mint you accept, compute the associated address and store the row: wallet, mint, token program, token account. That table is the alias map, and it answers the lookups you will need.

The reverse lookup matters most. A token transfer into an existing token account lists the token accounts and the sender's authority, and never the receiving wallet. A deposit processor that only watches wallet addresses sees nothing. Index by token account address instead, and read the owner from the account's own data or from the token balances in the transaction metadata. Token accounts by owner shows the owner-to-accounts read.

Run the alias script on a sample of wallets before launch, then again on a schedule. An account that shows as extra is a deposit path you did not plan: add it to the table, or sweep it and close it. Deposit ATA coverage check covers the other direction, finding wallets that still lack an associated account for a mint.

05

Token-2022 changes the address

The token program is the middle seed of the derivation. One wallet and one mint therefore give one address under the original program and a different address under Token-2022. A mint belongs to exactly one of the two, so only one of them can hold the account, but the program's identity must be right or the derived address points at nothing.

The script reads both programs and derives each account's expected address under the program that owns it, so a Token-2022 mint needs no extra setting. In your own table, store the program with each row.

06

Where it ends

  • The script reads only. It creates no account, moves no tokens and closes nothing; those are signed transactions from your own signing service.
  • It lists token accounts. It does not find seeded accounts or program derived addresses tied to a wallet, because nothing on chain links them back to a key without the seed and the program.
  • A token account closed by its owner leaves the list and the address stays derivable, so a derived address can exist in your table with no account behind it. Closed account detection covers spotting that.
  • The balance printed is the amount at confirmed commitment at read time. It does not track arrivals; Exchange deposit alerts covers the live side.
  • The address-less path samples the newest USDC transactions. The signature index keeps up to 30 days, and a signature it lists can still come back null from getTransaction.
07

When it goes wrong

what goes wrongwhat to do
Every wallet shows zero token accounts even though customers deposited.Check that the argument is the wallet and not one of its token accounts, which owns none. If both program reads printed an error instead, fix what the error names and run it again.
Deposits arrive at a token account that is not in your table.Someone created another account for the mint with your wallet as owner. Add it to the table by token account address, or sweep and close it.
The derived address for a Token-2022 mint finds no account.The address was derived under the original program. Read the mint's owner field and use that program as the middle seed.
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.
Discovery on a Free key ends with No wallet found.Transaction reads past the Free rate got 429 with a retry-after hint, and the script skipped them. Pass a wallet as an argument, or wait out the hint and run it again.
08

Questions

Can I give one keypair several deposit addresses?

The keypair has one wallet address. You can give a customer one wallet and let them use any token account that wallet owns, with the associated address as the default for each mint. If you want a distinct address per deposit, generate a new keypair per deposit.

Is the associated token account a different address from the wallet?

Yes. It is its own account with its own address, derived from the wallet, the token program and the mint, and the wallet is its owner.

Why list accounts by owner instead of only deriving them?

Derivation shows where deposits should go. Listing shows where tokens are, including extra accounts for the same mint that senders created at other addresses.

Do program derived addresses belong to my keypair?

No. A program derived address has no private key, and only the program that derived it can sign for it. Your key has no authority there unless the program grants it.