services
Get a key

library / Use cases / Analytics and research / UC0114

Reproducible research snapshot

A data set a reviewer can check months later: one batched read pinned to a slot at finalized, a manifest with block time and a sha256 digest, a check of the stored file, and a second read at or after the slot.

By Carbium · Analytics and research · UC0114 · updated 2026-11-22

01

Why two runs disagree

Two analysts pull the same three mints a day apart and get different supplies. Neither made a mistake. An account changes whenever a transaction writes to it, and the node answers with whatever the account holds when it serves the call. A table with no slot beside it cannot say which moment it describes.

A reviewer who opens the file months later needs three things beside the data: the slot the values came from, how settled the chain considered that slot, and proof that the bytes are the ones first written. A small manifest file next to the data carries all three.

The usual owner is a research lead. The numbers feed a paper, an audit or a board deck, and someone else checks them later. Running the query again will not rebuild the data set, because the chain has moved on.

02

Pinning a read to one slot

One getMultipleAccounts call reads every pubkey from the same bank state, so the whole batch shares one context.slot. Separate getAccountInfo calls for the same addresses can land on different slots, and a set of balances that never coexisted at one moment makes a poor base for a ratio. Batch the reads and take the slot from the reply. Same-slot multi-account snapshot covers that read on its own.

Name the commitment on the call. The server's default is finalized, and @solana/kit 8.6.0 fills in confirmed when a call leaves it out, so an unnamed call changes meaning with the client. The script sends finalized on every read. A finalized slot cannot be rolled back, so the slot in the manifest stays a real slot. Finalized now sits 0 to 1 slots behind processed, so the pin costs about one slot of freshness.

Batch size sets the limit on a single-slot snapshot. Account reads cost 10 cells per pubkey, so 100 pubkeys cost 1000 cells, or 1001 once the body passes 4 KiB. A call takes up to 300 pubkeys on Pro, and below Pro the 1,024-cell burst caps it at 100. A larger set takes several calls, and each call then has its own slot, which the manifest must record per batch.

The follow-up read sets minContextSlot to the pinned slot. A node whose state is older than that slot refuses with error -32016, and a node at or past it answers. The second read therefore lands at the pinned slot or later and never earlier. When it lands later, the values on a busy account may differ, so the follow-up measures drift. It does not replay the first read.

03

What the manifest records

The manifest is a flat JSON file saved beside snapshot.json. Each field answers one question a reviewer will ask.

FieldWhat it records
slotThe context slot of the read, as a string because JSON has no bigint
commitmentThe commitment named on the call, here finalized
blockTimeThe chain's Unix time for that slot as an ISO string, or null
capturedAtYour machine's clock when the job ran
countHow many accounts the data file holds
fileThe name of the data file
sha256Hex digest of the data file's exact text

The digest covers the exact text of the data file, written once with a fixed key order. Any later edit changes it, whitespace included. Each account entry holds the pubkey, the owner, lamports as a string, the executable flag and the base64 data. An account that does not exist is stored as null and is part of the hash.

getBlockTime returns the chain's own timestamp for the slot, which is the one to line up against other chain data. capturedAt is your clock and says when you ran the job. A slot without a block makes the call fail or return null, and the script stores null and goes on.

04

The snapshot script

Install the one dependency with npm i @solana/[email protected]. The script reads CARBIUM_KEY and exits with a message when it is unset. PUBKEYS takes a comma-separated list of up to 100 addresses and defaults to the USDC, USDT and wrapped SOL mints, and CARBIUM_RPC_URL overrides the endpoint. The two files land in the working directory.

main.ts
// UC0114 · Reproducible research snapshot// https://carbium.sh/library/usecase/reproducible-research-snapshot// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only: pins one getMultipleAccounts read to a slot, writes the data and a sha256 manifest, verifies the file, then re-reads at or after that slot.import { createHash } from "node:crypto";import { readFileSync, writeFileSync } from "node:fs";import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";import 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 url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const listed = process.env.PUBKEYS ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,So11111111111111111111111111111111111111112";const keys = listed.split(",").filter(Boolean).slice(0, 100).map((a) => address(a));const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const sha256 = (text: string) => createHash("sha256").update(text).digest("hex");// One call reads every pubkey from the same bank state, so the batch shares one context slot.async function read(minContextSlot?: Slot) {  const { context, value } = await rpc.getMultipleAccounts(keys, { commitment: "finalized", encoding: "base64", minContextSlot }).send();  const accounts = value.map((a, i) => a && { pubkey: keys[i], owner: a.owner, lamports: String(a.lamports), executable: a.executable, data: a.data[0] });  const text = JSON.stringify(accounts);  return { slot: context.slot, text, digest: sha256(text) };}const first = await read();let blockTime: string | null = null;try {  const t = await rpc.getBlockTime(first.slot).send();  blockTime = t === null ? null : new Date(Number(t) * 1000).toISOString();} catch (e) { console.log("getBlockTime failed:", e instanceof Error ? e.message : e); }writeFileSync("snapshot.json", first.text);const manifest = { slot: String(first.slot), commitment: "finalized", blockTime, capturedAt: new Date().toISOString(), count: keys.length, file: "snapshot.json", sha256: first.digest };writeFileSync("manifest.json", JSON.stringify(manifest, null, 1));console.log(`slot ${manifest.slot} time ${blockTime ?? "unknown"} digest ${first.digest.slice(0, 16)}`);// Verify the stored bytes against the manifest, as a reviewer would.const saved = JSON.parse(readFileSync("manifest.json", "utf8")) as typeof manifest;console.log("stored file matches manifest:", sha256(readFileSync(saved.file, "utf8")) === saved.sha256);try {  const again = await read(first.slot);  console.log(`second read at slot ${again.slot}, ${again.slot - first.slot} slots later, same digest: ${again.digest === first.digest}`);} catch (e) { console.log("second read failed:", e instanceof Error ? e.message : e); }

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts

A run prints the pinned slot, its block time and the first 16 hex digits of the digest. The next line says whether the stored file still hashes to the manifest value. The last line gives the second read's slot, the gap in slots, and whether the digest is the same. A busy mint can change supply between the two reads, so a differing digest is a normal result and the gap tells you how much time passed. A failed block time or second read prints a line, and the files are already written by then.

05

Verifying a snapshot against its digest

Verification needs no node and no key. Recompute the sha256 of the data file named in the manifest and compare it with the manifest's sha256. sha256sum snapshot.json gives the same digest the script computes, because both hash the file's bytes. A match shows the file is the one the manifest describes.

A manifest sitting beside its data catches accidents and silent edits to one file. Someone who edits both files can write a matching pair. Put the digest somewhere outside the folder as well, such as a paper's appendix or a commit message, and the pair is anchored.

06

Where it ends

  • Past account state cannot be fetched again. The RPC answers with current state, and minContextSlot only sets a floor. The stored bytes are the record, so a lost file means a lost snapshot.
  • The digest shows the file is unchanged since the manifest was written. It says nothing about whether the values came from the chain, because anyone can write a file and hash it.
  • A call holds up to 100 pubkeys below Pro, so a larger set spans several slots. Record one slot per batch and say so in the write-up.
  • An address's transaction list reaches back 30 days at most, because the pages come from the address index. An empty page past that is the index's age limit, and getTransaction can answer null for an older signature the list returns. Capture activity data while it is inside the window.
  • The script reads accounts. A token balance sits in the base64 data of a token account, which you decode later from the stored bytes.
07

When it goes wrong

what goes wrongwhat to do
The second read fails with error -32016.The node answering is behind the pinned slot. Wait a moment and retry once. The first read and the manifest are already on disk, so the snapshot stands either way.
The stored file no longer matches the manifest digest.The file was edited, reformatted or saved with different line endings. Restore the original from your archive or version control and compare it with the digest you recorded outside the folder.
blockTime is null.The slot had no block, or the node could not serve its time. Keep the null, rely on the slot as the pin, and label capturedAt as your own clock in any write-up.
A pubkey in the list reads back as null.The account does not exist at that slot, or the address is mistyped. The null is stored and hashed on purpose, so check the address before you publish.
A list of more than 100 pubkeys is refused below Pro.The 1,024-cell burst caps a call at 100 pubkeys. Split the list into batches of 100 and write one slot per batch into the manifest.
08

Questions

Can I re-read the same slot later to reproduce a snapshot?

For account state, no. The RPC answers with current state, and minContextSlot only sets a floor under the slot the answer comes from. Keep the stored file and its manifest as the record.

Why pin at finalized?

A finalized slot cannot be rolled back, so the slot in the manifest stays valid, and finalized now trails processed by 0 to 1 slots. Name it on every call, since the client library fills in confirmed when you leave it out.

How many accounts fit in one pinned snapshot?

100 below Pro and 300 on Pro, at 10 cells per pubkey, which is 1000 cells for 100. Past that you take several calls with a slot each.

Can the manifest show who ran the job?

No. It records the slot, the commitment, the times and the digest. Sign the digest with your own key or place it in a commit if the review needs an author.