---
id: UC0113
title: "Holder distribution histogram"
url: https://carbium.sh/library/usecase/holder-distribution-histogram
collection: Use cases
category: Analytics and research
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Holder distribution histogram

A holder distribution chart needs one balance per owner. Sample the owners from a mint's newest transactions, read their token accounts in one call, and group the amounts by power of ten with each group's share of supply.

## What the chart needs

A holder distribution chart groups wallets by how much of a mint they own: how many hold under 1 token, how many hold 1 up to 10, 10 up to 100, and so on, with the share of supply each group controls. The input is one balance per owner. A wallet can own several token accounts for the same mint, so the balances are added up per owner before grouping. Skip that step and one large holder appears as several small ones.

Power-of-ten buckets suit the data. Token holdings spread over many orders of magnitude, and a linear axis puts nearly every wallet into the first bar. Counting the digits of the whole-token balance gives the bucket with integer math only, and the amounts stay in `BigInt` from the RPC to the printout.

## Why there is no full list

The complete answer would come from listing every token account of the mint. Carbium does not serve getTokenLargestAccounts or getProgramAccountsV2. They are among the [methods that answer -32601](https://carbium.sh/docs/rpc), which is a final answer: [check the method](https://carbium.sh/docs/errors) and do not retry. getTokenAccountsByOwner reads from the wallet side and cannot list the wallets of a mint. [Token holder tracker](https://carbium.sh/library/usecase/token-holder-tracker) and [Largest token holders](https://carbium.sh/library/howsolana/largest-token-holders) work around the same gap for other jobs.

The RPC does serve enough for a sample. The mint's recent signatures lead to transactions, the transactions name token accounts of the mint, and one batch call reads those accounts. The owners who touched the mint lately are its active holders, and their balances come back exact.

## Sample, then read in one call

1. List the newest 12 signatures that name the mint with `getSignaturesForAddress`. Failed ones moved no tokens and are dropped.
2. Read each remaining transaction with `getTransaction` in `jsonParsed` encoding. Its `postTokenBalances` carry an `accountIndex` for every token account the transaction touched, and the message's account keys turn that index into an address.
3. Collect the distinct token account addresses of the mint, up to 100, and read them with one `getMultipleAccounts` call. One call means one slot, so every balance in the chart is from the same moment.
4. Read `getTokenSupply` for the total, so each bucket can show its share.

Mainnet carries v1 transactions. The `getTransaction` call passes `maxSupportedTransactionVersion: 1`, because with the field absent or 0 it answers -32015 for one, uncharged. Every call reads at confirmed commitment.

## One pass in one file

The script takes a mint address and defaults to a major stablecoin mint, which has transactions every second. It sends its calls to the [RPC endpoint](https://carbium.sh/docs/endpoints), reads `CARBIUM_KEY` and exits with a message when it is unset, and signs and sends nothing. The transaction reads run together under `Promise.allSettled`, so one failed lookup is printed and the rest still count.

`main.ts` (run: `CARBIUM_KEY=$CARBIUM_KEY node main.ts EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`)

```ts
// UC0113 · Holder distribution histogram
// https://carbium.sh/library/usecase/holder-distribution-histogram
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only: buckets the balances of a mint's recently active holders into a power-of-ten histogram.
import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } 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 mint = address(process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const SAMPLE = 12; // transactions read: 600 cells, inside the burst
const MAX_ACCOUNTS = 100; // below Pro the burst caps getMultipleAccounts at 100 pubkeys

const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));

type Tx = { meta: { postTokenBalances?: { accountIndex: number; mint: string }[] } | null; transaction: { message: { accountKeys: (string | { pubkey: string })[] } } } | null;
type Parsed = { parsed?: { info?: { owner: string; mint: string; tokenAmount: { amount: string } } } };

// 1. Newest signatures that name the mint, then their transactions.
const sigs = (await rpc.getSignaturesForAddress(mint, { commitment: "confirmed", limit: SAMPLE }).send()).filter((s) => !s.err);
const reads = await Promise.allSettled(sigs.map((s) =>
  rpc.getTransaction(s.signature, { commitment: "confirmed", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 }).send()));

// 2. Token accounts of the mint that those transactions touched.
const accounts = new Set<string>();
let failed = 0;
for (const r of reads) {
  if (r.status === "rejected") { failed++; console.error(`lookup failed: ${(r.reason as Error).message}`); continue; }
  const tx = r.value as unknown as Tx;
  if (!tx?.meta) { failed++; continue; } // null for an old signature
  for (const b of tx.meta.postTokenBalances ?? []) {
    const k = tx.transaction.message.accountKeys[b.accountIndex];
    if (b.mint === mint && k) accounts.add(typeof k === "string" ? k : k.pubkey);
  }
}
if (!accounts.size) { console.error(`no token accounts found, ${failed} lookups failed`); process.exit(1); }

// 3. One batch read for every balance, plus the supply for the shares.
const [accs, supply] = await Promise.all([
  rpc.getMultipleAccounts([...accounts].slice(0, MAX_ACCOUNTS).map((a) => address(a)), { commitment: "confirmed", encoding: "jsonParsed" }).send(),
  rpc.getTokenSupply(mint, { commitment: "confirmed" }).send(),
]);
const owners = new Map<string, bigint>();
let closed = 0;
for (const a of accs.value) {
  const info = (a?.data as unknown as Parsed | undefined)?.parsed?.info;
  if (!info || info.mint !== mint) { closed++; continue; }
  if (info.tokenAmount.amount === "0") continue; // emptied since: no longer a holder
  owners.set(info.owner, (owners.get(info.owner) ?? 0n) + BigInt(info.tokenAmount.amount));
}

// 4. Bucket by digits in the whole-token balance: 0 digits is under 1 token.
const unit = 10n ** BigInt(supply.value.decimals);
const total = BigInt(supply.value.amount) || 1n;
const buckets = new Map<number, { n: number; sum: bigint }>();
for (const bal of owners.values()) {
  const d = bal / unit === 0n ? 0 : (bal / unit).toString().length;
  const b = buckets.get(d) ?? { n: 0, sum: 0n };
  buckets.set(d, { n: b.n + 1, sum: b.sum + bal });
}
console.log(`${mint}: ${owners.size} owners from ${accounts.size} accounts, ${failed} lookups failed, ${closed} accounts skipped`);
for (const d of [...buckets.keys()].sort((x, y) => x - y)) {
  const b = buckets.get(d)!;
  const label = d === 0 ? "under 1" : `${10n ** BigInt(d - 1)} to under ${10n ** BigInt(d)}`;
  console.log(`${label.padStart(28)} ${"#".repeat(b.n).padEnd(24)} ${String(b.n).padStart(3)}  ${(Number(b.sum * 10000n / total) / 100).toFixed(2)}% of supply`);
}
```

A bucket is the number of digits in a wallet's whole-token balance: 0 digits means under 1 token, 3 digits means 100 up to 1,000. The output is a text bar chart. Each row shows the bucket, one `#` per owner, the owner count, and the bucket's share of total supply in percent. The shares of the sampled owners add up to less than 100, and the gap is supply held by wallets the sample did not reach.

## Spending the rate limit

Each call costs cells, and each plan allows these requests per second.

| Call | Cells | Free | Dev | Business | Pro |
|---|---|---|---|---|---|
| getSignaturesForAddress | 50 | 0.24/s | 1.2/s | 100/s | 500/s |
| getTransaction | 50 | 0.24/s | 1.2/s | 5/s | 25/s |
| getMultipleAccounts | 10 per pubkey | 0.5/s | 15/s | 50/s | 400/s |

A class [absorbs bursts](https://carbium.sh/docs/limits) up to 1,024 cells or one second of its rate, whichever is larger. The 12 lookups cost 600 cells and the 100-pubkey read costs 1,000 cells, or 1,001 when its body passes 4 KiB, so a single pass fits inside the burst on a Free key. A second pass right after it may wait for cells to refill, and on a Free key the lookups refill at 0.24 `getTransaction` calls per second.

The 100 cap on the batch read is a plan limit. A call may carry up to 300 pubkeys, yet below Pro the 1024-cell burst stops a call at 100. A script written for a Pro key can send 300 in one call and read three times the token accounts per call. An account's keys share one budget, so two keys do not double it.

## Where it ends

- The chart shows recently active holders only. A wallet that has held a mint for months without a transfer never appears in the newest signatures. Read the result as the distribution of owners who moved the mint lately.
- A busy mint's newest transactions are dominated by exchange, pool and market-maker accounts. They count as owners like any wallet, and one of them can fill the top bucket by itself. Filter known owners out if your definition of holder excludes them.
- A larger sample needs more transactions and more reads. Raise the signature limit, read the token accounts in chunks of 100, and space the calls to your plan's rates in the table.
- The address index behind the signature list keeps up to 30 days. An empty page past that is the index's age limit, so a mint with little activity gives a short sample.
- Supply and balances come from separate calls, so a mint or burn between them can leave the shares a hair off.
- Balances of accounts closed since the transaction was read come back null and are skipped. The script prints how many.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| getTokenLargestAccounts or getProgramAccountsV2 answers -32601 and the client retries it. | Treat -32601 as final and remove the call. Build the sample from the mint's transactions and read the token accounts with getMultipleAccounts. |
| 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. |
| One wallet shows up in several low buckets. | Add the balances of every token account per owner before choosing a bucket. A wallet can own more than one token account for a mint. |
| A listed signature answers null from getTransaction. | The signature index reaches below the validator's ledger floor, so an old signature can list and still answer null. Skip it and print the count. The newest signatures resolve. |
| getMultipleAccounts is refused with more than 100 pubkeys on a key below Pro. | Below Pro the 1024-cell burst caps a call at 100 pubkeys. Send chunks of 100, spaced to the rate in the table. |
| The chart has a few owners and one huge bar. | The newest signatures came from a handful of busy accounts. Raise the signature limit within your burst, or run the pass again later and merge the owners by address. |

## Questions

### Can this give the exact holder count of a mint?

No. It counts the owners that appear in recent transactions and are still holding. The two reverse-lookup methods are not served, so an exact count needs a snapshot of your own.

### Why group by powers of ten?

Balances span many orders of magnitude, so decades keep both the small wallets and the large ones visible. Counting digits of a BigInt needs no floating point and no rounding.

### Does it work for Token-2022 mints?

The parsed token account carries the same owner, mint and amount fields for both token programs, so the same code reads them. A mint with the interest-bearing or scaled UI amount extension shows wallets a UI amount that differs from the raw amount the script buckets, so its rows can sit a decade off from what wallets display.

### How do I draw this as an actual chart?

Write the bucket labels, counts and shares from the printout into a CSV or JSON file and load it in any charting library. The script keeps the computation separate from the drawing so the numbers can go anywhere.

## Related

- [Token holder tracker](https://carbium.sh/library/usecase/token-holder-tracker) (Use cases, UC0017)
- [Largest token holders](https://carbium.sh/library/howsolana/largest-token-holders) (How to use Solana, HS0048)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/migrate](https://carbium.sh/docs/migrate)
