---
id: UC0112
title: "Daily transaction count series"
url: https://carbium.sh/library/usecase/daily-transaction-count-series
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
---

# Daily transaction count series

A script reads the chain's one-minute transaction counts, stores them in SQLite and prints transactions per UTC day. Run it on a schedule and the table grows into a daily series, with each day showing how many minutes it covers.

## What a daily count is

Solana keeps no table of transactions per day. The network does record, every 60 seconds, how many transactions it processed in that minute, and a daily figure is the sum of those minutes. Answering the question therefore means collecting the minute counts and adding them up by UTC date.

Two counts come with each minute: all transactions and non-vote transactions. Before the Alpenglow switch of 2026-10-21, validator votes were transactions in blocks and made up most of each day's total. Mainnet blocks carry no vote transactions since the switch, so the two columns in this series sit close together. The series starts on your first run, so any daily figure from before the switch comes from somewhere else and counted the votes: set it beside the non-vote column, the only count that means the same thing on both sides.

A failed transaction still lands in a block and is counted. The series measures activity the network processed, and says nothing about how much of it succeeded.

## Where the counts come from

`getRecentPerformanceSamples` returns up to 720 samples, newest first. Each carries the slot it was taken at, the sample period in seconds (60), `numTransactions`, `numNonVoteTransactions` and `numSlots`. Seven hundred and twenty minutes is 12 hours, so one call reaches back half a day and no further. The series you want has to be built by calling it again and again and keeping what it returns.

A sample has a slot and no clock time. The script asks `getBlockTime` for the slot of the newest sample, then steps back one sample period for each older one. If that call fails or answers null, the script falls back to the local clock and prints a line saying so. A slot is about 200 ms, so a minute holds around 300 of them, and the stored `numSlots` lets you check a minute that looks short.

Each sample is stored under its slot. A slot that is already in the table is skipped on the next run, so two runs whose windows overlap add each minute once.

## The collector script

The script takes no arguments. It reads `CARBIUM_KEY`, exits with a message when it is unset, calls the [RPC endpoint](https://carbium.sh/docs/rpc) for the samples and for one block time, writes the new minutes into `tx-per-day.db` in the folder you run it from, and prints one line per UTC day. Nothing is signed or sent.

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

```ts
// UC0112 · Daily transaction count series
// https://carbium.sh/library/usecase/daily-transaction-count-series
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

// Read-only: stores the network's one-minute transaction counts in SQLite and prints transactions per UTC day.
import { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";
import { DatabaseSync } from "node:sqlite";

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 rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));

const db = new DatabaseSync("tx-per-day.db"); // relative path: the file lives where you run the script
db.exec("CREATE TABLE IF NOT EXISTS samples (slot INTEGER PRIMARY KEY, t INTEGER, secs INTEGER, total INTEGER, nonvote INTEGER)");

// Up to 720 one-minute samples (12 hours), newest first. Each has a slot but no clock time.
const samples = await rpc.getRecentPerformanceSamples(720).send()
  .catch((e: Error) => { console.error(`samples failed: ${e.message}`); return process.exit(1); });
if (samples.length === 0) { console.error("The node returned no samples."); process.exit(1); }

// Clock time of the newest sample from its block; each older sample steps back one sample period.
let end = Math.floor(Date.now() / 1000);
try {
  const bt = await rpc.getBlockTime(samples[0].slot).send();
  if (bt !== null) end = Number(bt); else console.error("block time was null, using the local clock");
} catch (e) { console.error(`block time failed, using the local clock: ${(e as Error).message}`); }

// A slot already stored is skipped, so overlapping runs never double count.
const insert = db.prepare("INSERT OR IGNORE INTO samples VALUES (?, ?, ?, ?, ?)");
let added = 0, t = end;
for (const s of samples) {
  const secs = Number(s.samplePeriodSecs);
  added += Number(insert.run(Number(s.slot), t, secs, Number(s.numTransactions), Number(s.numNonVoteTransactions)).changes);
  t -= secs;
}
console.log(`${samples.length} samples read, ${added} new`);

type Day = { day: string; total: number; nonvote: number; secs: number };
const days = db.prepare(
  "SELECT date(t, 'unixepoch') AS day, sum(total) AS total, sum(nonvote) AS nonvote, sum(secs) AS secs FROM samples GROUP BY day ORDER BY day",
).all() as unknown as Day[];
const fmt = (n: number) => Math.round(n).toLocaleString("en-US");
for (const d of days) {
  const minutes = Math.round(d.secs / 60);
  console.log(`${d.day}  ${fmt(d.total)} transactions  ${fmt(d.nonvote)} non-vote  ${fmt(d.total / d.secs)}/s  ${minutes} of 1440 minutes${minutes < 1440 ? " (partial)" : ""}`);
}
```

The samples call is the job, so its failure ends the run. The block time call only sets the clock, so its failure prints a line and the run goes on with the local time. Neither method takes a commitment.

Each output line shows the day, the transaction total, the non-vote total, the average per second and the number of minutes the table holds for that day. The per-second average divides by the seconds stored, so it stays comparable between a full day and a partial one, where the totals do not.

## Running it on a schedule

Run the script at least once every 12 hours, since that is the span one call covers. Hourly is a comfortable choice: each run re-reads about 11 hours it already stored and adds the newest hour, and about 11 runs in a row can fail before a minute is lost. Two calls an hour sits far under any [req/s limit](https://carbium.sh/docs/limits).

- A cron line such as `0 * * * * cd /srv/txseries && . ./key.env && node main.ts` keeps the database beside the script, with `export CARBIUM_KEY=` and your key in `key.env`, a file only your user can read.
- A systemd timer works the same way, with the key in an environment file the unit reads.
- A run within a minute of the one before it prints `0 new`, which is normal.

Each node takes its own samples, so the slots in the table belong to the node that answered. Keep one database per endpoint: a database fed from two endpoints counts the overlapping minutes twice, and a day can then show more than 1440 minutes. A minute that no run saw within its 12 hours is gone for good.

## Reading the series

| Column | What it holds | Use it for |
|---|---|---|
| day | The UTC date of the sample's end time | Grouping |
| transactions | Sum of `numTransactions` for the day | Total activity |
| non-vote | Sum of `numNonVoteTransactions` | Comparing with figures from before the Alpenglow switch |
| per second | Total divided by the seconds stored | Comparing a partial day with a full one |
| minutes | Seconds stored divided by 60, out of 1440 | Deciding whether the day is complete |

The first row is nearly always partial, because the first run started somewhere in the middle of a day. A day with fewer than 1440 minutes after that means a gap in the runs. Treat only the days that show all 1440 as daily totals, and quote the per-second average for the others.

For a live per-second reading with no stored series, see [Non-vote TPS meter](https://carbium.sh/library/blockchainideas/non-vote-tps-meter). For a series that must be repeatable by someone else, keep the database file itself with the report, as [Reproducible research snapshot](https://carbium.sh/library/usecase/reproducible-research-snapshot) does for its data.

## Where it ends

- The series begins on the day of your first run. The call returns at most 720 minutes, so yesterday cannot be fetched today unless an earlier run stored it.
- Reading old days from blocks is a separate job on a different scale: a day holds about 432,000 slots, each a block to fetch and add up. `getSignaturesForAddress` reaches back [30 days](https://carbium.sh/docs/migrate) at most and counts one address, so it cannot give a network total.
- A sample's time is the block time of the newest one minus 60 seconds per step. The error is a few seconds, and it can move one minute across midnight between two days.
- A gap longer than 12 hours between runs leaves minutes that no later call returns. The minutes column shows it, and the day cannot be repaired.
- The series counts transactions as the network processed them, failed ones included. Successes only, or one program's share, needs a read of the blocks or the logs.
- A day is cut at UTC midnight. A report for a local time zone needs the stored `t` column shifted before it is grouped.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The first day prints a total far below the days after it. | The first run started mid-day. Read its minutes column and compare per-second averages, or use the series from the first full day. |
| A later day shows fewer than 1440 minutes. | Two runs were more than 12 hours apart. Move the schedule to hourly. The lost minutes cannot be fetched again. |
| The run prints that block time failed and uses the local clock. | The samples were stamped from the host clock, which is right if the host keeps UTC time. Check the clock. A stamp off by seconds can move one minute across midnight, and the stored slot keeps its first stamp on later runs. |
| The call answers 401 UNKNOWN_KEY. | The key was cut or mistyped. [Attach the whole key](https://carbium.sh/docs/errors) in `CARBIUM_KEY`. |
| The run ends with 429 after several reruns in a row. | Reruns that close together went over the key's req/s limit. Run again after the retry-after hint; the hourly schedule stays far below the limit. |

## Questions

### Can I get yesterday's transaction count today?

Only if a run stored it. One call returns 720 one-minute samples, which is 12 hours. For a day that no run saw, the call has no answer.

### Why store minutes and not one number per day?

A day built from minutes can be completed by later runs, and its minutes column shows any gap. A stored daily figure hides both.

### Why do the total and non-vote columns differ so little now?

Mainnet blocks carry no vote transactions since the Alpenglow switch on 2026-10-21, so the votes that once filled the gap are gone. A daily total from before the switch, wherever it was recorded, carries the old gap.

### Is the day a UTC day?

Yes. The script groups by the UTC date of each sample's end time. A different time zone means shifting the stored time before the grouping.

## Related

- [Non-vote TPS meter](https://carbium.sh/library/blockchainideas/non-vote-tps-meter) (Blockchain ideas, BI0063)
- [Reproducible research snapshot](https://carbium.sh/library/usecase/reproducible-research-snapshot) (Use cases, UC0114)
- [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/migrate](https://carbium.sh/docs/migrate)
