library / Blockchain ideas / Consumer and social / BI0118
Live chain lesson cards
A learning app for people new to Solana where every lesson card carries a number read from mainnet moments ago: the deck, the call behind each card and a runnable main.ts that prints five cards.
Who uses it
People who search for how to learn Solana mostly land on pages that describe slots, rent and commitment in the abstract. A learning app can put each idea next to a value read from mainnet a moment ago, so the learner can check a definition against any explorer and see that it holds.
Three groups build this. A hackathon team wants a first-hour onboarding screen for its own users. A bootcamp or meetup organiser wants a handout that cannot go stale when a network parameter changes. A solo developer wants a study tool for the first week with the chain. Each card teaches one idea, shows one live number and points at one thing to notice.
Carbium serves the node's JSON-RPC at services.carbium.sh under one key, and the deck is a thin layer of lesson text over plain reads. The app needs no database, no WebSocket and no signing key.
The deck
Five cards cover the first concepts a newcomer meets. Each one pairs a sentence of teaching with a read that proves it.
| Card | Idea | Call | Live value |
|---|---|---|---|
| Slots and commitment | A slot is one time step, and commitment says how sure the node is about it | getSlot at processed, confirmed and finalized | three slot numbers and the gap between them |
| Epochs | Epochs group slots into longer periods | getEpochInfo | epoch number and how far into it the chain is |
| Rent | An account must hold a minimum balance for its size | getMinimumBalanceForRentExemption for 165 bytes | lamports a token account must hold |
| Tokens | A mint is an account that stores a supply and belongs to a program | getTokenSupply and getAccountInfo | the supply, its decimals and the owner program |
| A transaction | A transaction has a fee, a compute cost, logs and a status | getSignaturesForAddress and getTransaction | the newest transaction that touched the token program |
The slot card corrects the lesson most tutorials now get wrong. Since the Alpenglow switch on 2026-10-21 a slot is about 200 ms and finalized sits 0 to 1 slots behind processed, where it used to trail by about 32. The card prints the gap it just measured instead of quoting a number. The three reads are separate calls, so two of them can come back equal or briefly out of order, and the lesson text tells the learner to expect that.
The rent card uses 165 because that is the byte size of a token account. A learner can change the size and watch the minimum move, which is the quickest way to see that rent follows data size.
The build
The script prints the deck once and exits. It needs @solana/kit and what Node 24 ships, and it only reads.
- Take the key from CARBIUM_KEY and an optional mint from the command line. The default is the USDC mint. Build one RPC client and reuse it for every card.
- Define each card as a title, a lesson sentence and a function that returns one line of live values.
- Run the cards one after another and catch each failure, so a card that errors prints its message and the deck carries on.
- Pass a commitment level in every call whose answer moves with it. The node's own default is finalized, while @solana/kit 8.6.0 fills in confirmed when a call leaves the level out, so a card that said nothing would teach the wrong one.
- For the transaction card, list the five newest signatures of the token program and call getTransaction with maxSupportedTransactionVersion: 1 until one answers with data. A signature the ledger no longer holds answers null and is skipped.
// BI0118 · Live chain lesson cards// https://carbium.sh/library/blockchainideas/live-chain-lesson-cards// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, 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);}// Any mint works. The default is the USDC mint.const mint = address(process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const TOKEN_PROGRAM = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");const rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key }, }),);const levels = ["processed", "confirmed", "finalized"] as const;const cards: [string, string, () => Promise<string>][] = [ ["Slots and commitment", "A slot is one time step; commitment says how sure the node is.", async () => { const s = await Promise.all(levels.map((c) => rpc.getSlot({ commitment: c }).send())); return `${levels.map((c, i) => `${c} ${s[i]}`).join(" | ")} | processed minus finalized: ${s[0] - s[2]}`; }], ["Epochs", "An epoch is a long run of slots.", async () => { const e = await rpc.getEpochInfo({ commitment: "confirmed" }).send(); return `epoch ${e.epoch}, slot ${e.slotIndex} of ${e.slotsInEpoch} (${Number((e.slotIndex * 1000n) / e.slotsInEpoch) / 10}%)`; }], ["Rent", "An account holds a minimum balance for its size.", async () => { const lamports = await rpc.getMinimumBalanceForRentExemption(165n).send(); return `a 165 byte token account holds at least ${lamports} lamports (${Number(lamports) / 1e9} SOL)`; }], ["Tokens", "A mint is an account that stores a supply and belongs to a program.", async () => { const [supply, info] = await Promise.all([ rpc.getTokenSupply(mint, { commitment: "confirmed" }).send(), rpc.getAccountInfo(mint, { commitment: "confirmed", encoding: "base64" }).send(), ]); return `supply ${supply.value.uiAmountString}, ${supply.value.decimals} decimals, owner ${info.value?.owner ?? "none"}`; }], ["A transaction", "A transaction has a fee, a compute cost, logs and a status.", async () => { const sigs = await rpc.getSignaturesForAddress(TOKEN_PROGRAM, { limit: 5, commitment: "confirmed" }).send(); for (const s of sigs) { const tx = await rpc .getTransaction(s.signature, { commitment: "confirmed", encoding: "json", maxSupportedTransactionVersion: 1 }) .send(); if (!tx?.meta) continue; // listed below the ledger floor: null const m = tx.meta; return `${s.signature.slice(0, 12)} slot ${tx.slot}, fee ${m.fee} lamports, ${m.computeUnitsConsumed ?? "?"} compute units, ${m.logMessages?.length ?? 0} log lines, ${m.err ? "failed" : "ok"}`; } return "the five newest signatures had no readable transaction"; }],];for (const [title, lesson, read] of cards) { try { console.log(`[${title}] ${lesson}\n now: ${await read()}`); } catch (e) { console.log(`[${title}] failed: ${e instanceof Error ? e.message : e}`); }}
run: CARBIUM_KEY=<YOUR_KEY> node main.ts <MINT>
To put the deck on a screen, run the same functions inside a small server, cache the answer for a few seconds and send it to pages as JSON. Every visitor then reads the cache, and the key stays on the server where no page script can see it.
What it costs
One run makes at least nine calls: three getSlot, one getEpochInfo, one rent read, one getTokenSupply, one getAccountInfo, one getSignaturesForAddress and at least one getTransaction. Cells are the admission charge per call. The signatures call costs 50 cells, each getTransaction costs 50 and the getAccountInfo read costs 10.
The getTransaction rate sets how often a fresh deck can be built, and on Free and Dev the signatures call runs at the same rate. Landed transactions never change, so the transaction card is worth caching by signature, and the rest of the deck is cheap to refresh on a short timer.
| Plan | getSignaturesForAddress rate | getTransaction rate | Fresh decks per second, at most |
|---|---|---|---|
| Free | 0.24 req/s | 0.24 req/s | about 0.24 |
| Dev | 1.2 req/s | 1.2 req/s | about 1.2 |
| Business | 100 req/s | 5 req/s | about 5 |
| Pro | 500 req/s | 25 req/s | about 25 |
Limits belong to the account, so another tool on the same keys draws on the same budget. A public page should build one deck on a timer and hand it to every visitor, which keeps the cost the same at ten visitors or ten thousand.
What to add next
- A guess mode: hide the number, ask the learner to estimate the gap or the rent, then reveal the live value.
- A live ticker: slotSubscribe opens for 5 credits and turns the slot card into a counter that moves.
- A block card: getBlock with maxSupportedTransactionVersion: 1 lists the transactions in one slot, and since Alpenglow none of them is a vote, so every row is a user transaction.
- A wallet card: paste an address, read its balance and its token accounts, and explain that one wallet can own several token accounts for the same mint.
- Deeper lessons: Solana commitment levels goes further on the slot card, and Transaction explainer turns the transaction card into a line-by-line reading.
Where it ends
- The node returns numbers. The teaching text, the order of the cards and the quiz are yours to write.
- The transaction card shows whatever touched the token program last, which may be a failed or unusual transaction. A lesson built around one specific example should pin a signature instead.
- History reaches back 30 days at most, since signature pages come from an address index of that age. A card about an old transaction cannot come from getSignaturesForAddress.
- That index lists signatures below the validator's ledger floor, so getTransaction can answer null for a listed signature. The card skips nulls, and a deck of five nulls prints a plain line saying so.
- A holders card built on getTokenLargestAccounts gets -32601 because Carbium does not serve it. Leave that card out and do not retry the call.
- The deck only reads. A lesson that has the learner send a transaction needs a signer and funds, which belong in a separate tool.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The transaction card prints that no transaction was readable. | All five newest signatures answered null. Raise the limit in the signatures call or run the deck again a few seconds later. Signature pages reach below the ledger floor, so some listed entries have no body. |
| getTransaction answers -32015. | The call left maxSupportedTransactionVersion out or set it to 0, and the transaction is version 1. Pass 1 in the config. |
| The slot card shows finalized equal to processed, or one slot ahead. | That is expected. Finalized sits 0 to 1 slots behind processed, and three separate reads can land out of order. Show the three numbers as read and teach the range. |
| The mint card shows an owner other than the classic token program. | Token-2022 mints belong to a different program. Print the owner as read and let the card teach that a mint's owner says which token program governs it. |
| A card fails with 401. | The key is unknown at the door. Attach the whole key in CARBIUM_KEY and check that no characters were cut off. |
Questions
Why read the slot at three commitment levels?
Each level answers how sure the node is. Reading all three at once shows the learner the gap itself, and the gap is now 0 to 1 slots at finalized.
Does the deck need a WebSocket?
No. Every card is a single request and response. Add slotSubscribe later for a live ticker, which costs 5 credits to open.
Can a learner try their own mint?
Yes. Pass any mint as the first argument and the Tokens card reads its supply, decimals and owner. The transaction card keeps reading the token program.
Which commitment does a call use when none is given?
The node's default is finalized, while @solana/kit 8.6.0 sends confirmed when a call leaves the level out. The code names the level in each call so the lesson and the read agree.