services
Get a key

library / Use cases / Analytics and research / UC0122

Token holder overlap report

Two mints in, one report out: sample wallets from the newest transactions of each, check whether they hold the other token, and print the overlap in both directions. It reads only and fits a short cron pass.

By Carbium · Analytics and research · UC0122 · updated 2026-11-23

01

Overlap without a holder list

Holder overlap is the share of one token's holders who also hold a second token. Computing it exactly takes both complete holder lists, and the shortcuts are closed: getTokenLargestAccounts and getProgramAccountsV2 are two of the methods that answer -32601, a code that is final, so check the method and drop the call instead of retrying.

A sample gets close enough for most analysis. Take wallets that recently moved the first mint, then ask for each one whether it holds the second. The question is a wallet-side lookup, and Token accounts by owner covers that call. The answer is a share of the sample, an estimate of the overlap among active holders. It says nothing exact about the whole holder base, and the report prints the sample size next to every ratio so nobody reads it as more.

02

Owners from transaction balances

A transaction's metadata carries postTokenBalances: for each token account the transaction touched, the mint, the owner wallet and the amount afterwards. The owner field is what the report needs. A transfer to an existing token account lists the token accounts and the sender's authority and never the receiving wallet, so the metadata is where receivers appear.

A wallet can own more than one token account for one mint, so the script sums amounts per owner and keeps owners with a total above zero. getSignaturesForAddress on the mint address lists the newest transactions that name it, at 50 cells a call. Each getTransaction costs 50 cells too. Failed transactions moved no tokens and get no lookup.

03

Both directions in one file

The script takes two mints. For each one it lists 20 signatures, reads the newest 5 successful transactions, and collects up to 8 owners holding that mint afterwards. It then asks getTokenAccountsByOwner, filtered by the other mint, whether each owner has a positive balance there. Everything goes to the RPC endpoint with CARBIUM_KEY, and it exits with a message when the key is unset. Nothing is signed or sent.

main.ts
// UC0122 · Token holder overlap report// https://carbium.sh/library/usecase/token-holder-overlap-report// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: estimates how many holders of one mint also hold another, by sampling owners from recent transactions.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, 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 url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";if (!process.argv[2] || !process.argv[3]) { console.error("Usage: node main.ts <mintA> <mintB>"); process.exit(1); }const mints = [address(process.argv[2]), address(process.argv[3])]; // throws on anything that is not an addressconst TXS = 5, OWNERS = 8; // transactions read and owners checked per mint and passconst rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));type Bal = { mint: string; owner?: string; uiTokenAmount: { amount: string } };type Tx = { meta: { postTokenBalances?: Bal[] } | null } | null;type Accts = { account: { data: { parsed: { info: { tokenAmount: { amount: string } } } } } }[];// Owners holding the mint after its newest successful transactions, summed over each owner's accounts.async function sample(mint: Address): Promise<string[]> {  const sigs = await rpc.getSignaturesForAddress(mint, { commitment: "confirmed", limit: 20 }).send();  const ok = sigs.filter((s) => !s.err).slice(0, TXS);  const txs = await Promise.allSettled(ok.map((s) =>    rpc.getTransaction(s.signature, { commitment: "confirmed", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 }).send()));  const totals = new Map<string, bigint>();  txs.forEach((r, i) => {    const tx = r.status === "fulfilled" ? (r.value as unknown as Tx) : null;    if (!tx?.meta) { console.error(`read of ${ok[i]?.signature} failed: ${r.status === "rejected" ? (r.reason as Error).message : "answered null"}`); return; }    for (const b of tx.meta.postTokenBalances ?? []) {      if (b.mint === mint && b.owner) totals.set(b.owner, (totals.get(b.owner) ?? 0n) + BigInt(b.uiTokenAmount.amount));    }  });  return [...totals].filter(([, amount]) => amount > 0n).map(([owner]) => owner).slice(0, OWNERS);}async function holds(owner: string, mint: Address): Promise<boolean> {  const r = await rpc.getTokenAccountsByOwner(address(owner), { mint }, { commitment: "confirmed", encoding: "jsonParsed" }).send();  return (r.value as unknown as Accts).reduce((n, x) => n + BigInt(x.account.data.parsed.info.tokenAmount.amount), 0n) > 0n;}for (const [i, j] of [[0, 1], [1, 0]] as const) {  const from = mints[i], to = mints[j];  let owners: string[] = [];  try { owners = await sample(from); } catch (e) { console.error(`sample of ${from} failed: ${(e as Error).message}`); }  const res = await Promise.allSettled(owners.map((o) => holds(o, to)));  res.forEach((r, k) => { if (r.status === "rejected") console.error(`lookup of ${owners[k]} failed: ${(r.reason as Error).message}`); });  const checked = res.filter((r) => r.status === "fulfilled").length;  const yes = res.filter((r) => r.status === "fulfilled" && r.value).length;  console.log(`${from} -> ${to}: ${yes} of ${checked} sampled holders also hold the second mint`);}

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts <mintA> <mintB>

Every call names confirmed commitment. The transaction reads pass maxSupportedTransactionVersion: 1: mainnet carries v1 transactions, and a read with the field absent or 0 comes back as -32015 when it hits one. Each call settles on its own. A lookup that fails or answers null is printed on stderr and left out of the denominator, so one bad call shrinks the sample and never kills the report.

04

Pacing a pass

A pass makes 2 list calls and up to 10 transaction reads, then up to 16 owner lookups. The first two kinds cost 50 cells each and run at these requests per second by plan.

CallCellsFreeDevBusinessPro
getSignaturesForAddress500.24/s1.2/s100/s500/s
getTransaction500.24/s1.2/s5/s25/s

Each rate class absorbs bursts of 1,024 cells or one second of its rate, whichever is larger. One pass spends 100 cells on signature lists and up to 500 on transaction reads, which fits inside that on every plan. On Free the transaction reads refill at 0.24 a second, so passes run back to back drain the burst within a few passes, and the reads after that get 429 with a retry-after hint. All keys of an account draw on one budget, so a second key adds nothing.

Run the report on a schedule of your own choosing and keep each pass small. Sampling the same wallets again adds nothing, so a longer window comes from more passes at different times, and comparing their ratios shows how stable the overlap is.

05

Reading the result

Each line gives a direction, the sample size and the count that hold the other token. Overlap is rarely symmetric. A stablecoin with many small users and a niche token with a few large ones can show 90% of the niche holders also holding the stablecoin and a tiny share the other way. Read both lines together and compare across several passes before drawing a conclusion.

!A sample of 8 wallets moves in steps of 12.5 points. Treat a single pass as a smoke test and raise the caps in the script only as far as your plan's rates allow.
06

Where it ends

  • The sample follows activity. Wallets that moved a mint in the newest transactions are its active holders, so dormant holders are never in it, and the ratio describes active overlap only.
  • Programs count as owners. A liquidity pool vault or an exchange account shows up as one owner like any wallet. Filter known program owners out before you report the share if your definition of a holder excludes them.
  • Coverage follows the account list. A plain transfer instruction does not name the mint, so a transaction that moves tokens only that way may never appear in the mint's signatures.
  • Window: the address index keeps up to 30 days, and a signature it lists can answer null from getTransaction when it falls below the validator's ledger floor. The script counts those as failed lookups. Sampling the newest transactions avoids them.
  • Amounts are ignored. The report asks only whether a wallet holds any of the other token, so a dust balance counts as overlap. The first mint's side is the balance after each sampled transaction, summed per owner, so a wallet that has emptied its account since can still count as a holder.
  • Token-2022 mints work through the same owner and mint fields. A mint with transfer fees changes the amounts that arrive, which matters only for the zero check at the edge.
07

When it goes wrong

what goes wrongwhat to do
A pass prints 429 for several transaction reads.The burst is spent. Wait for the retry-after hint, space passes further apart or lower TXS, and remember that an account's keys share one budget.
getTransaction answers -32015.Pass maxSupportedTransactionVersion: 1 with an encoding. Mainnet carries v1 transactions and the call fails for one when the field is absent or 0.
getTokenLargestAccounts or getProgramAccountsV2 answers -32601 and the client retries it.Treat -32601 as final and remove the call. Sample owners from transaction balances instead.
Every transaction read answers null.The listed signatures are older than the validator's ledger floor, which the address index can still list. Sample the newest signatures and check that the mint has recent activity.
The sample is empty and the report prints 0 of 0.No recent successful transaction held a positive balance for the mint, or every lookup failed. Read the stderr lines, then try a busier mint or raise the signature limit.
08

Questions

Can I get the exact overlap between two mints?

Not with the calls this script makes. Exact overlap needs both full holder lists, and getTokenLargestAccounts and getProgramAccountsV2 answer -32601. A sample of active owners gives an estimate you can repeat over time.

Why check owners one by one instead of reading token accounts?

A token account is keyed by owner and mint, and the other mint's accounts are unknown until you ask. A lookup by owner with a mint filter answers it directly and returns every account the wallet holds for that mint.

Can I compare more than two mints?

Yes. Run the pair routine for each pair of mints, and cut the owners per pass as the pair count grows, since the lookups multiply with the pairs.

How large a sample is enough?

The error shrinks with the square root of the sample size, so 100 wallets give roughly a 10-point margin at a 50% ratio. Collect that across many passes, counting each wallet once.