---
id: BI0053
title: "30-day wallet recap"
url: https://carbium.sh/library/blockchainideas/30-day-wallet-recap
collection: Blockchain ideas
category: Consumer and social
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# 30-day wallet recap

A wallet recap card for a consumer app: signatures paged to the 30-day edge give active days, busiest day and success rate, and three sampled transactions add fees and programs. You get the runnable script and the card as JSON.

## Who uses it

A consumer app team wants a card a user can share at the end of a month: how many days the wallet was active, the busiest day, how many transactions landed, what was paid in fees and which programs it touched. The same card works as a profile badge, a push notification or the image on a share page.

The window is 30 days by design. Carbium's [address index](https://carbium.sh/docs#migrate) keeps up to 30 days of signatures per address, so the product is a monthly recap. A yearly one cannot be built from this index.

Most of the card comes from signatures. The code asks `getSignaturesForAddress` for `limit: 500` rows per page, which costs 50 cells a call, and a full transaction costs the same 50 cells, so the counts come from signatures and only a small sample of transactions is read in full.

## What the recap shows

Every field is a count or a sum over rows the code has read. Days are UTC calendar days taken from `blockTime`.

| Card field | Where it comes from | Based on |
|---|---|---|
| Transactions | Rows from `getSignaturesForAddress` inside the 30-day window | All rows read |
| Active days | Distinct UTC days among those rows | All rows read |
| Busiest day | The day with the most rows | All rows read |
| Success rate | Share of rows whose `err` is null | All rows read |
| Fees | Sum of `meta.fee` over the sampled transactions, in lamports | The sample |
| Top programs | `programId` of each instruction in the sampled transactions, counted | The sample |

Fees and programs describe the sample only, and the card has to say so. A card that told a user their month cost 0.00003 SOL in fees, from three transactions, would be wrong for most wallets.

## The build

The recap is one read-only file on `@solana/kit` and Node 24: no key pair, nothing signed, nothing sent. Run it as `node main.ts [wallet address]`. Every call names `confirmed`.

1. Read `CARBIUM_KEY` and exit with a message when it is unset. Create the RPC client once and reuse it for every call.
2. With no address argument, read `getSlot`, then try `getBlock` on slots a few behind it with `transactionDetails: "accounts"` and take the first account key, the fee payer, of a successful transaction. A slot with no block throws, so the loop logs it and moves to the next one.
3. Page `getSignaturesForAddress` 500 rows at a time, setting `before` to the last signature of the previous page. The walk ends after two pages, at a page shorter than the limit, or at the first row older than 30 days. It records whether it reached the edge as `complete`.
4. Bucket each row by the UTC day of its `blockTime`, count the failed ones, and skip a row with a null `blockTime`.
5. Fetch the newest three signatures with `getTransaction` inside `Promise.allSettled`, with `encoding: "jsonParsed"`. Count a null answer, sum `meta.fee` and tally each instruction's `programId`.
6. Print the totals, one text bar per day, the sample's fee sum and the card as JSON.

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

```ts
// BI0053 · 30-day wallet recap
// https://carbium.sh/library/blockchainideas/30-day-wallet-recap
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Signature, type Slot } 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 rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? 'https://services.carbium.sh',
    headers: { 'x-api-key': key },
  }),
);
const PAGES = 2; // page cap; raise it for busy wallets
const PAGE_SIZE = 500;
const SAMPLE = 3; // transactions fetched in full
const cutoff = Math.floor(Date.now() / 1000) - 30 * 86400;
const msg = (e: unknown) => (e instanceof Error ? e.message : String(e));

// No argument: take the fee payer of a successful transaction in a recent block.
async function recentFeePayer(): Promise<string> {
  const slot = await rpc.getSlot({ commitment: 'confirmed' }).send();
  for (let i = 3n; i < 12n; i++) {
    try {
      const block = await rpc
        .getBlock((slot - i) as Slot, { commitment: 'confirmed', transactionDetails: 'accounts', rewards: false, maxSupportedTransactionVersion: 1 })
        .send();
      const tx = block?.transactions.find((t) => t.meta?.err === null);
      if (tx) return tx.transaction.accountKeys[0].pubkey;
    } catch (e) {
      console.error(`slot ${slot - i} skipped:`, msg(e));
    }
  }
  throw new Error('no recent block with a successful transaction');
}

const wallet = address(process.argv[2] ?? (await recentFeePayer()));
const days = new Map<string, number>();
const sigs: Signature[] = [];
let failed = 0;
let complete = false; // true once the walk reaches the window edge or the end of history
let before: Signature | undefined;
try {
  for (let p = 0; p < PAGES && !complete; p++) {
    const page = await rpc.getSignaturesForAddress(wallet, { limit: PAGE_SIZE, before, commitment: 'confirmed' }).send();
    for (const r of page) {
      if (r.blockTime === null) continue;
      if (Number(r.blockTime) < cutoff) { complete = true; break; }
      const day = new Date(Number(r.blockTime) * 1000).toISOString().slice(0, 10);
      days.set(day, (days.get(day) ?? 0) + 1);
      if (r.err !== null) failed++;
      sigs.push(r.signature);
    }
    if (page.length < PAGE_SIZE) complete = true;
    before = page.at(-1)?.signature;
  }
} catch (e) {
  console.error('getSignaturesForAddress failed:', msg(e));
}

const rows = [...days].reverse(); // the API lists newest first
const max = Math.max(1, ...rows.map(([, c]) => c));
const busiest = rows.reduce((a, r) => (r[1] > a[1] ? r : a), ['', 0] as [string, number]);
console.log(`wallet ${wallet}: ${sigs.length} transactions on ${rows.length} days, ${complete ? 'window complete' : `cut at ${PAGES} pages`}`);
for (const [day, c] of rows) console.log(`${day} ${'#'.repeat(Math.ceil((c / max) * 40)).padEnd(40)} ${c}`);

const programs = new Map<string, number>();
let fee = 0n;
let nulls = 0;
const sample = await Promise.allSettled(
  sigs.slice(0, SAMPLE).map((s) =>
    rpc.getTransaction(s, { commitment: 'confirmed', encoding: 'jsonParsed', maxSupportedTransactionVersion: 1 }).send(),
  ),
);
for (const res of sample) {
  if (res.status === 'rejected') { console.error('getTransaction failed:', msg(res.reason)); continue; }
  if (res.value === null) { nulls++; continue; }
  fee += res.value.meta?.fee ?? 0n;
  for (const ix of res.value.transaction.message.instructions) programs.set(ix.programId, (programs.get(ix.programId) ?? 0) + 1);
}
console.log(`sample of ${sample.length}: fees ${Number(fee) / 1e9} SOL, ${nulls} null`);

const card = {
  wallet, windowDays: 30, complete, transactions: sigs.length, activeDays: rows.length, busiestDay: busiest[0] || null,
  successRate: sigs.length ? Math.round(((sigs.length - failed) / sigs.length) * 1000) / 1000 : null,
  days: Object.fromEntries(rows),
  sample: { size: sample.length, nulls, feeLamports: Number(fee), programs: Object.fromEntries(programs) },
};
console.log(JSON.stringify(card, null, 2));
```

Each bar is `#` scaled to 40 characters for the busiest day, which shows the shape of the month in a terminal. An app would feed the same counts to a chart, or to an image route as in [Vercel OG wallet image](https://carbium.sh/library/integrate/vercel-og-wallet-image). The paging itself is the walk described in [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination), ended here at the window edge.

Kit returns a fee as a bigint of lamports. The code sums as a bigint and converts once at the end, because `JSON.stringify` throws on a bigint.

> The sample passes `maxSupportedTransactionVersion: 1`, and so does the block read. Mainnet carries v1 transactions, and a call that leaves the option out, or sets 0, answers -32015 for one.

## The card as JSON

The script prints the card as one JSON object, so an image route or a share page can take it as it is.

| Field | Meaning |
|---|---|
| `wallet` | The address the recap was built for |
| `windowDays` | 30, the length of the index |
| `complete` | True when the walk reached the window edge or the end of the history, false when the page cap stopped it |
| `transactions` | Rows inside the window |
| `activeDays` | Number of UTC days with at least one row |
| `busiestDay` | The day with the most rows, as `YYYY-MM-DD`, or null when there are none |
| `successRate` | Landed rows with a null `err`, divided by all rows, or null when there are none |
| `days` | Row count per day, oldest first |
| `sample` | Size, count of null answers, `feeLamports` and a `programs` map of counts |

Store each card with the date it was built. The window rolls with the clock, so a card rebuilt a day later covers a different 30 days. Twelve stored monthly cards make a year, and only from the month you started keeping them.

When `complete` is false, label the card with the number of transactions it read, for example the latest 1,000, instead of presenting it as the whole month.

## Pacing calls per plan

One recap with an address argument makes at most 2 signature calls and 3 transaction calls. That is at most 5 calls at 50 cells each, 250 cells. Cells are the admission charge per call, and on Free and Dev each rate class absorbs bursts up to 1,024 cells. The `getTransaction` class holds 20 calls, about six recaps back to back, and the signature calls sit in their own class.

| Plan | Credits per month | getSignaturesForAddress | getTransaction |
|---|---|---|---|
| Free ($0) | 500K once, at sign-up | 0.24 req/s | 0.24 req/s |
| Dev ($20) | 10M | 1.2 req/s | 1.2 req/s |
| Business ($250) | 50M | 100 req/s | 5 req/s |
| Pro ($500) | 200M | 500 req/s | 25 req/s |

Once the burst is spent, the 3 `getTransaction` calls set the pace, because the two methods draw on separate rates. That is about 12.5 seconds per recap on Free (3 calls at 0.24 req/s) and about 2.5 seconds on Dev (3 calls at 1.2 req/s). A queue of users on those plans builds each card once, stores it, and serves the stored JSON when the user opens the app.

Limits are per account, so the recap job and the rest of the app draw on one budget.

Raising `SAMPLE` adds one call against the `getTransaction` rate and 50 cells for each transaction. Thirty sampled transactions on Free are 1,500 cells, more than one burst holds, so pace them.

## Where it ends

- Nothing older than 30 days. The address index keeps up to 30 days, and an empty page past that is the index's age limit while the address may have older transactions. A wallet created last week gets a full card, and an old wallet gets only its last month.
- A signature the index lists can sit below the validator's ledger floor, and `getTransaction` then answers null. The sample takes the newest signatures because they are the likeliest to resolve, and the card shows the null count. Fees and programs are missing for a null.
- Two pages of 500 rows cover 1,000 signatures. A busy wallet's walk stops short of the 30-day edge, at the 1,000th signature, with `complete` false, and its counts describe only the newest rows.
- A signature row exists for every transaction that mentions the address, so an incoming transfer or an unsolicited token send counts as an active day. Success rate covers landed transactions only. One that was dropped never appears.
- A token transfer to an existing token account lists only the token accounts and the sender's authority, so the wallet's own signature list misses an incoming USDC payment and the recap undercounts tokens received. A wallet can hold several token accounts for one mint. Read the owner's accounts with `getTokenAccountsByOwner`, list signatures for each and merge them by signature.
- Three transactions are a sample. The fee sum and the program counts describe those three.
- Days follow UTC. A user's local midnight falls inside a different bucket, so shift `blockTime` by the user's offset before bucketing when the card must match their calendar.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| getTransaction answers -32015 in the sample. | The transaction is v1 and the call left out `maxSupportedTransactionVersion`. Pass 1 on `getTransaction` and on `getBlock`. The refusal is uncharged. |
| Every sampled transaction comes back null. | The signatures are below the validator's ledger floor. Sample the newest rows, count the nulls and show the card without fees and programs when all three are null. |
| The card says `complete: false`. | The page cap stopped the walk before the window edge. Raise `PAGES`, remembering each page is 50 cells, or label the card with the row count it did read. |
| The run with no argument fails before any history prints. | The slots tried had no block or no successful transaction. The loop logs each skipped slot. Run again, or pass an address. |
| A call answers 429. | The recap is running faster than the plan allows. Space calls by the table in the pacing section and retry after the hint. |
| A wallet with known activity returns zero rows. | Its last transaction is older than 30 days, so the index is past its age limit. Show an empty-month card and keep your own stored cards from now on. |

## Questions

### Can the recap cover a whole year?

No. The address index keeps up to 30 days, so one recap spans one rolling month. Store each month's card and a year builds up from the month you start.

### Why fetch only three transactions?

Each full transaction costs 50 cells, the same as one signature page, which the code asks for at `limit: 500`. Three keeps one recap at 150 transaction cells. Raise `SAMPLE` to what the plan's `getTransaction` rate allows.

### Does it need a node of my own or a signing key?

No. Every call is a read on services.carbium.sh with one key, and the script never signs or sends.

### Why does the busiest day not match my local calendar?

Days are UTC, taken from `blockTime` in unix seconds. Add the user's offset to `blockTime` before bucketing and the days follow their clock.

### Can the card count token transfers?

Not from the wallet address alone. A payment received in a token is listed under the token account that got it, so list signatures for each of the owner's token accounts too and merge by signature.

## Related

- [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination) (How to use Solana, HS0034)
- [Vercel OG wallet image](https://carbium.sh/library/integrate/vercel-og-wallet-image) (Integrations, I0033)
- [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)
