services
Get a key

library / Use cases / Analytics and research / UC0118

Top programs by activity

A script samples the newest confirmed blocks and ranks programs by the transactions that invoke them, with each share and failed count. You get a snapshot ranking and the route to a 30-day series for any one program.

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

01

What activity means for a program

Activity has no single definition, so the report picks one and states it. A program's count is the number of transactions that invoke it as a top-level instruction, counted once per transaction however many times it appears there. A transaction that calls the token program four times adds one to the token program's count. Failed transactions stay in the count and are shown beside it, because a failed attempt still took block space and paid a fee.

A share reads better than a raw count. Each figure is divided by the transactions read, so two runs over different sample sizes still compare. Two programs are plumbing that many transactions carry whatever else they do: the system program, which moves SOL and creates accounts, and the compute budget program, which sets the compute limit and priority fee. A sample often finds each in half or more of all transactions, and they would fill the top of any ranking. The script reports them on one line and ranks the rest.

Since the Alpenglow switch, mainnet blocks carry no vote transactions. The vote program no longer takes the top of every ranking, and the sample holds only ordinary traffic.

02

Sampling the newest blocks

The script asks getSlot for the head at confirmed commitment, a 1-cell call, then requests that block and the ones before it with getBlock. The block reads name confirmed too, so the head and the blocks come from the same view of the chain.

A slot now lasts about 200 ms, so ten blocks span roughly two seconds of chain time. That is a snapshot, and the summary line says how many blocks it covers. Some slots in the range hold no block because their leader produced none. getBlock answers an error for those, and the script counts them as skipped and reads on.

Each block is read with maxSupportedTransactionVersion: 1. Mainnet carries v1 transactions, and with the field absent or 0 a block holding one answers -32015, which drops a whole block from the sample. The encoding is json, which gives each transaction an account key list and instructions that point into it by index. A top-level program id always sits in the static keys and never in a lookup table, so the index lookup needs no table resolution. A transaction whose message the script cannot read in that shape is counted as unreadable.

03

The ranking script

The script takes an optional block count, 8 when none is given and capped at 10, and reads CARBIUM_KEY, exiting with a message when it is unset. It prints a summary line with the slot range, the transactions read, the skipped slots and the unreadable transactions, then one line with the two programs set apart, then the ten programs that ran in the most transactions, each with its share of the sample and its failed count. It signs and sends nothing.

main.ts
// UC0118 · Top programs by activity// https://carbium.sh/library/usecase/top-programs-by-activity// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: ranks the programs that the transactions in the newest confirmed blocks invoke at the top level.import { 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 count = Math.min(Math.max(Number(process.argv[2] ?? 8) || 8, 1), 10); // blocks to sample, at most 10const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const names: Record<string, string> = {  "11111111111111111111111111111111": "System",  "ComputeBudget111111111111111111111111111111": "ComputeBudget",  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA": "Token",  "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb": "Token-2022",  "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL": "Associated Token",  "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr": "Memo",};const plumbing = Object.keys(names).slice(0, 2); // plumbing in many transactions, so reported aparttype Tx = { transaction?: { message?: { accountKeys?: string[]; instructions?: { programIdIndex: number }[] } }; meta?: { err: unknown } | null };type Block = { transactions: Tx[] } | null;const head = await rpc.getSlot({ commitment: "confirmed" }).send()  .catch((e: Error) => { console.error(`getSlot failed: ${e.message}`); return process.exit(1); });const slots = Array.from({ length: count }, (_, i) => (head - BigInt(i)) as typeof head);const reads = await Promise.allSettled(slots.map((s) => rpc  .getBlock(s, { commitment: "confirmed", encoding: "json", transactionDetails: "full", rewards: false, maxSupportedTransactionVersion: 1 })  .send() as unknown as Promise<Block>));const stats = new Map<string, { txs: number; failed: number }>();let blocks = 0, skipped = 0, txs = 0, unreadable = 0;reads.forEach((r, i) => {  if (r.status === "rejected" || !r.value) {    skipped++; console.error(`slot ${slots[i]}: ${r.status === "rejected" ? (r.reason?.message ?? r.reason) : "no block"}`); return;  }  blocks++;  for (const t of r.value.transactions) {    const keys = t.transaction?.message?.accountKeys, ixs = t.transaction?.message?.instructions;    if (!keys || !ixs) { unreadable++; continue; }    txs++;    for (const id of new Set(ixs.map((ix) => keys[ix.programIdIndex]))) { // once per transaction      const s = stats.get(id) ?? { txs: 0, failed: 0 };      s.txs++; if (t.meta?.err) s.failed++;      stats.set(id, s);    }  }});if (!blocks) { console.error("No block came back; run it again."); process.exit(1); }const pct = (n: number) => `${((100 * n) / txs).toFixed(1)}%`.padStart(6);console.log(`${blocks} blocks (slots ${slots[count - 1]} to ${head}), ${txs} transactions, ${skipped} slots skipped, ${unreadable} unreadable`);console.log(`set apart: ${plumbing.map((id) => `${names[id]} in ${stats.get(id)?.txs ?? 0}`).join(", ")}`);for (const [id, s] of [...stats].filter(([id]) => !plumbing.includes(id)).sort((a, b) => b[1].txs - a[1].txs).slice(0, 10)) {  console.log(`${pct(s.txs)}  ${String(s.txs).padStart(5)} txs  ${String(s.failed).padStart(4)} failed  ${names[id] ?? id}`);}

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts [blocks]

The block reads run through Promise.allSettled. A slot with no block, or a call that fails, is printed on stderr and counted, and the ranking covers the blocks that came back.

Labels come from a small table of six well-known program ids. Any other program prints as its address. Pass that address to getAccountInfo to confirm it is an executable account and see which loader owns it.

04

Sizing the sample

One run is one getSlot and up to ten getBlock calls, the block reads sent together. The getSlot call is a cheap cached read at 5, 30, 100 and 500 req/s on Free, Dev, Business and Pro. A rate class absorbs bursts up to 1,024 cells or one second of its rate, whichever is larger, so ten reads landing in the same instant draw on that allowance before the per-second rate applies.

BlocksChain time coveredCalls
1about 0.2 s2
5about 1 s6
10about 2 s11

The block reads go out together, and each block is a large response. Widen the sample in steps and watch for 429 before you raise the cap above ten. A wider window comes from running the script on a schedule and keeping each result. An account's keys share one budget, so a second key for the report adds no room.

05

From a sample to a series

An eight-block sample covers under two seconds and ranks programs by what ran in that instant, and a quiet minute and a busy minute can order differently. To see one program over days, take its address from the ranking and list its transactions with getSignaturesForAddress. The call costs 50 cells and each entry carries a slot and a block time, so grouping the signatures by hour gives a count per hour. Count entries with no err for the success series and keep the rest for a failure rate. The list also holds transactions that call the program from inside another program, so its counts run above the top-level ranking. A page holds at most 1,000 signatures, and the call runs at 0.24, 1.2, 100 and 500 req/s on Free, Dev, Business and Pro. A program near the top of this ranking runs hundreds of transactions a second, well over a thousand pages per hour of chain time, so on Free or Dev the series suits a quieter program.

The list comes from an address index that keeps up to 30 days. An empty page past that point is the index's age limit, and the program may have older transactions. Store one row per program per run with the slot range it came from, and the daily view builds itself from your own table.

For a dashboard over several dapps at once, see Multi-dapp usage dashboard. For one program's health signals, see Program health dashboard. For a continuous view, logsSubscribe with the all filter streams the logs of every transaction, each listing its program invocations. An all-logs stream costs 200 credits to open and 20 credits per MiB sent, and its volume is high, so sample for a minute and close it.

06

Where it ends

  • The count covers top-level instructions only. A router program shows once, and the programs it calls inside show only when some transaction also calls them directly. Inner instructions would add them, and the script skips them.
  • A count is transactions, with no weight for compute, fees or value. A cheap program called constantly outranks a heavy one called less. Rank by the compute units each transaction's metadata reports if cost matters to you.
  • Ten blocks are about two seconds. A figure for an hour or a day needs stored runs or the signature route above, and the script produces neither.
  • One wallet looping a program counts the same as many users. Distinct fee payers per program would separate the two, and the script does not collect them.
  • Failed transactions count as activity. A program flooded with failed attempts ranks high, so read the failed column beside the share.
  • Skipped slots and unreadable transactions shrink the sample. The summary line shows both, and a high number means the ranking rests on less than it appears.
07

When it goes wrong

what goes wrongwhat to do
getBlock answers -32015.Set maxSupportedTransactionVersion: 1 in the options of the getBlock call, next to the encoding. A block holding a v1 transaction is refused without it.
Every slot in the range reports an error and no ranking prints.A block can lag the slot number just reported. Rerun after a moment and read stderr for the message of the first failed call.
Slots print 429 on stderr and count as skipped, or getSlot fails with 429.Wait for the retry-after hint, then run again with a lower block count. A Free key also gets 429 when its network's shared budget runs out.
The unreadable count is high.Those transactions came back in a message shape without an account key list, so the ranking skips them. Compare the count with the transactions read. A small share leaves the ranking sound.
The call answers 401 with UNKNOWN_KEY.Attach the whole key in the x-api-key header. A truncated or mistyped key is unknown at the door.
08

Questions

Why count transactions and not instructions?

One transaction can repeat a program many times, and a count of instructions rewards that repetition. Counting each program once per transaction answers how many transactions needed it.

Why does the vote program not appear?

Mainnet blocks carry no vote transactions since the Alpenglow switch, so there are none to count. The system and compute budget programs are the ones the script sets aside.

Can I get last month's ranking?

Not from one run. List a program's signatures with getSignaturesForAddress for up to 30 days, or store each run's result and build the history from now on.

Does a program called by another program show up?

Only when some transaction also calls it at the top level. Calls made inside other programs sit in inner instructions, which this script does not read.