---
id: BI0086
title: "Crowdfund backer tiers"
url: https://carbium.sh/library/blockchainideas/crowdfund-backer-tiers
collection: Blockchain ideas
category: Creator and membership
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Crowdfund backer tiers

A tracker that reads the finalized USDC transfers into one campaign token account, stores each pledge once by signature in SQLite, adds up every backer's running total and prints a reward tier and goal progress. Runnable code and plan pacing included.

## A campaign as one token account

A creator platform team can start crowdfunding on Solana from a plain idea: a campaign is one USDC token account. The creator publishes its address, backers send USDC to it, and the campaign page shows who pledged, how much, and which reward tier each backer has reached. No program is deployed and nothing is held in escrow, so this is the read side of a campaign. Refunds, release rules and all-or-nothing goals would live in a program you write later.

Every read is public, so a hackathon team can build the whole page against a busy token account and swap in the real campaign address afterwards. All calls go to `services.carbium.sh` under one key, and the code is read-only: no signing, no sending, no private key.

## Who the backer is

A token transfer into an existing token account lists the two token accounts and the signing authority of the sender. The creator's wallet is absent from it and only the creator's token account is named, which is why the campaign is keyed by that token account. The backer's wallet does appear, as the signer.

The tracker takes the backer from the transaction's token balance entries. Each entry carries a token account index, the mint, the owner wallet and the amount before and after. The account whose USDC fell is the sender, and its owner is the backer. The campaign account's change is the pledge. The decimals come from the same entries, so the code never guesses how many a mint has.

Grouping by owner matters because a wallet can own more than one token account for one mint. Two token accounts owned by one wallet count as one backer.

> A pledge sent from an exchange or a payment app names that service's wallet, so one backer wallet can stand for many people.

## The ledger

One file on `@solana/kit` and what Node 24 ships. Run it with no argument and it picks a token account itself; pass a token account to track a real campaign.

1. With no argument, list the three newest signatures of the USDC mint, read each, and take the token account with the largest USDC gain as a stand-in campaign.
2. Open `pledges.db` with `node:sqlite`. The table is keyed by campaign and signature, and its `backer` column holds the owner's wallet address.
3. List the campaign's newest `LIMIT` signatures (5 by default). Skip failed transactions and signatures already stored.
4. Read each new signature with getTransaction, `jsonParsed` encoding and `maxSupportedTransactionVersion` set to 1, in up to three tries.
5. Store the backer, the amount in raw units and the decimals. A transaction that moved nothing into the campaign is stored with a zero amount, so it is never read again.
6. Group the ledger by backer, work out each tier from the running total and print progress against `GOAL`.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> node main.ts`)

```ts
// BI0086 · Crowdfund backer tiers
// https://carbium.sh/library/blockchainideas/crowdfund-backer-tiers
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { DatabaseSync } from "node:sqlite";
import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Signature } from "@solana/kit";
const key = process.env.CARBIUM_KEY ?? "";
if (!key) {
  console.error("Set CARBIUM_KEY, then run: node main.ts [campaign token account]");
  process.exit(1);
}
const MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
const LIMIT = Number(process.env.LIMIT ?? 5);
const GAP_MS = Number(process.env.GAP_MS ?? 200);
const GOAL = Number(process.env.GOAL ?? 1000);
const TIERS: [string, number][] = [["Gold", 250], ["Silver", 50], ["Bronze", 10]];
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);
type Bal = { accountIndex: number; mint: string; owner?: string; uiTokenAmount: { amount: string; decimals: number } };
type Tx = {
  meta: { preTokenBalances?: Bal[]; postTokenBalances?: Bal[] } | null;
  transaction: { message: { accountKeys: { pubkey: string }[] } };
};
const db = new DatabaseSync("pledges.db");
db.exec("CREATE TABLE IF NOT EXISTS pledges (campaign TEXT, signature TEXT, backer TEXT, amount INTEGER, decimals INTEGER, PRIMARY KEY (campaign, signature))");
const store = db.prepare("INSERT OR IGNORE INTO pledges VALUES (?, ?, ?, ?, ?)");
async function read(sig: Signature): Promise<Tx | null> {
  for (let i = 1; i <= 3; i++) {
    try {
      await new Promise((r) => setTimeout(r, GAP_MS + (i - 1) * 1500));
      return (await rpc
        .getTransaction(sig, { commitment: "finalized", encoding: "jsonParsed", maxSupportedTransactionVersion: 1 })
        .send()) as unknown as Tx | null;
    } catch (e) {
      console.log(`${sig.slice(0, 8)} try ${i} failed: ${e instanceof Error ? e.message : e}`);
    }
  }
  return null;
}
function moves(tx: Tx | null) {
  const pre = new Map((tx?.meta?.preTokenBalances ?? []).map((b) => [b.accountIndex, b]));
  return (tx?.meta?.postTokenBalances ?? []).filter((b) => b.mint === MINT).map((b) => ({
    account: tx?.transaction.message.accountKeys[b.accountIndex]?.pubkey ?? "",
    owner: b.owner ?? "",
    decimals: b.uiTokenAmount.decimals,
    delta: Number(b.uiTokenAmount.amount) - Number(pre.get(b.accountIndex)?.uiTokenAmount.amount ?? 0),
  }));
}
async function main() {
  let campaign = process.argv[2] ?? "";
  if (!campaign) {
    let top = { account: "", delta: 0 };
    for (const s of await rpc.getSignaturesForAddress(address(MINT), { limit: 3, commitment: "finalized" }).send())
      for (const m of moves(await read(s.signature))) if (m.delta > top.delta) top = m;
    if (!top.account) throw new Error("no USDC gain found in the newest mint transactions, pass a token account");
    campaign = top.account;
  }
  console.log(`campaign token account ${campaign}`);
  const sigs = await rpc.getSignaturesForAddress(address(campaign), { limit: LIMIT, commitment: "finalized" }).send();
  for (const s of sigs) {
    if (s.err !== null || db.prepare("SELECT 1 FROM pledges WHERE campaign = ? AND signature = ?").get(campaign, s.signature)) continue;
    const tx = await read(s.signature);
    if (!tx?.meta) {
      console.log(`${s.signature.slice(0, 8)} not readable, skipped`);
      continue;
    }
    const all = moves(tx);
    const mine = all.find((m) => m.account === campaign);
    const payer = all.filter((m) => m.delta < 0).sort((a, b) => a.delta - b.delta)[0];
    const gain = Math.max(0, mine?.delta ?? 0);
    store.run(campaign, s.signature, gain ? (payer?.owner ?? "") : "", gain, mine?.decimals ?? 0);
    console.log(`${s.signature.slice(0, 8)} +${gain} raw from ${payer?.owner.slice(0, 8) ?? "unknown"}`);
  }
  const rows = db
    .prepare("SELECT backer, SUM(amount) AS total, MAX(decimals) AS d FROM pledges WHERE campaign = ? AND amount > 0 GROUP BY backer ORDER BY total DESC")
    .all(campaign) as unknown as { backer: string; total: number; d: number }[];
  let raised = 0;
  for (const r of rows) {
    const whole = r.total / 10 ** r.d;
    raised += whole;
    console.log(`${(r.backer || "unknown").slice(0, 8)}  ${whole} USDC  ${TIERS.find(([, min]) => whole >= min)?.[0] ?? "Supporter"}`);
  }
  console.log(`${raised} of ${GOAL} USDC, ${Math.min(100, Math.round((raised / GOAL) * 100))} percent`);
}
main().catch((e) => {
  console.error(e instanceof Error ? e.message : e);
  process.exit(1);
});
```

The primary key makes each insert a no-op the second time, so a rerun never counts a pledge twice. Totals come from the stored rows, so a run that stops halfway leaves a ledger the next run finishes.

The listing and the reads both ask for `finalized`, because a reward sent for a pledge that later disappears is hard to take back.

Setting `maxSupportedTransactionVersion` to 1 is needed because mainnet carries v1 transactions, and a pledge sent as one would otherwise fail the read. A read that still fails after three tries is printed and left out of the table, so the next run asks for it again.

## Tiers and progress

A tier comes from a backer's running total, so two pledges of 5 USDC reach Bronze together. The thresholds are one constant at the top of the file.

| Tier | Running total of one backer |
|---|---|
| Supporter | above 0 and below 10 USDC |
| Bronze | 10 USDC or more |
| Silver | 50 USDC or more |
| Gold | 250 USDC or more |

Progress is the sum of every backer's total against `GOAL`, which defaults to 1000 whole USDC. Because tiers are computed when the ledger is read, changing a threshold or the goal needs no new RPC calls: run the file again and the stored rows are regrouped.

## Pacing the reads

Both getSignaturesForAddress and getTransaction cost 50 cells a call. The default run with no argument makes two listings and eight transaction reads, three to find the account and five for its pledges. That is 500 cells, and a rate class absorbs bursts up to 1,024 cells, so the default run sits inside the burst on all four plans. `GAP_MS` defaults to 200 and only spaces the reads a little.

A long backfill with a large `LIMIT` leaves the burst and runs at the plan's sustained rate. Set `GAP_MS` to 1000 divided by the plan's getTransaction rate; each read's own round trip only slows the run further.

| Plan | Credits | getTransaction rate | GAP_MS for a long backfill |
|---|---|---|---|
| Free ($0) | 500K once, at sign-up | 0.24 req/s | about 4200 |
| Dev ($20) | 10M per month | 1.2 req/s | about 840 |
| Business ($250) | 50M per month | 5 req/s | about 200 |
| Pro ($500) | 200M per month | 25 req/s | about 40 |

Limits belong to the account, so every other tool on its keys draws from the same budget. After the first run the table remembers each pledge, and a refresh that finds nothing new costs one listing call.

## Where it ends

- History is the 30-day address index at most. A pledge older than that is not served, so keep `pledges.db`: it is the only record that outlives the window.
- The listing reads only the newest `LIMIT` signatures and never pages back. A campaign that gets more pledges than `LIMIT` between two runs loses the older ones. Raise `LIMIT`, run more often, or page as in [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination).
- A read that fails after three tries stays out of the table, so totals, tiers and progress understate until a later run reads it.
- Only the USDC mint is counted. Pledges in any other token or in SOL are ignored.
- The backer is the owner of the account that sent the USDC. It does not tell you which person that is, and moves out of the campaign account are not subtracted.
- With no argument the stand-in account is whichever token account gained most in the newest mint transactions. It is often a pool or an exchange account, which shows the code working and is not a campaign.
- Delivering rewards, goal deadlines and refunds are off chain or a program's job. For a running total on a page, see [Live donation totals](https://carbium.sh/library/usecase/live-donation-totals).

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Reads come back with 429. | The run asked for cells faster than the plan refills them, or a Free key went over its network's shared budget. Set `GAP_MS` to the plan's value from the pacing table. The code retries each read up to three times with a growing pause. |
| getTransaction answers -32015. | The call left out `maxSupportedTransactionVersion` or set it to 0, and the transaction is v1. Pass 1 on every getTransaction call in code you write. |
| getTransaction returns null for a signature the listing just gave. | The address index reaches below the validator's ledger floor, so an old signature can list and then read as null. The code prints it and skips it. Keep your own rows for anything older. |
| The run stops with 401 and UNKNOWN_KEY. | The key was cut short or mistyped. Attach the whole key in `CARBIUM_KEY`. |
| A backer sits in a lower tier than their pledges suggest. | One of their pledges may be outside the newest `LIMIT` signatures, older than 30 days, failed to read, or sent from a second wallet. Raise `LIMIT`, rerun, and read the printed lines for failed reads. |
| The run ends with no USDC gain found. | None of the three newest mint transactions moved USDC between token accounts. Run again, or pass a campaign token account as the argument. |

## Questions

### Why key the ledger by signature?

A signature is unique for a transaction, so the same pledge read twice lands on the same row. Reruns, overlapping listings and a restart after a crash cannot double count.

### Can the campaign be in SOL or another token?

Yes, with a change in the reader. Change `MINT` for another token. For SOL, compare the lamport balances in the transaction instead of the token balance entries.

### How do I see a pledge the moment it lands?

Open a logsSubscribe on `wss://services.carbium.sh` with a mention of the campaign token account. Each notification carries a signature, and you hand it to the same reader. The ledger stays the record.

### Do I need a database server?

No. `node:sqlite` writes one file, `pledges.db`, next to where you run the script. Copy that file to move the campaign's history.

## Related

- [Live donation totals](https://carbium.sh/library/usecase/live-donation-totals) (Use cases, UC0021)
- [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination) (How to use Solana, HS0034)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/migrate](https://carbium.sh/docs/migrate)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
