library / Blockchain ideas / BI0024
Token vesting schedule viewer
A read-only viewer for one vesting escrow. It reads the locked balance from Carbium, applies the start, cliff and end dates you give it, and prints vested, claimed and claimable amounts, the next 30-day vesting dates and the latest movements on the account.
Who uses it
Three groups ask the same question about a vesting grant: how much has vested today, and how much has the beneficiary already taken. A project team checks that its treasury escrow still matches the schedule it published. A contributor with a grant checks their own position without opening a spreadsheet. A community member who sees a large vesting date on a calendar checks whether tokens are leaving the escrow on time.
A hackathon crew can build the first version in an afternoon. The balance of the locked token account is public, and the rest is computed from the start, cliff and end dates.
What it shows
The viewer takes the address of the escrow token account, the token account that holds the locked tokens until they are claimed. It prints one summary block and then a table of upcoming vesting dates.
| Line | Where it comes from | What it tells you |
|---|---|---|
| Mint, owner, decimals | getAccountInfo with jsonParsed encoding | which token is locked and which address controls the escrow, usually a program-derived address |
| Locked balance | the parsed tokenAmount.amount | tokens still in the escrow right now |
| Total grant | VEST_TOTAL, or the balance when it is unset | what the schedule started with |
| Vested so far | the schedule applied to today's date | what the beneficiary is entitled to by now |
| Claimed | total grant minus locked balance | what has already left the escrow |
| Claimable | vested minus claimed | what the beneficiary can take today |
| Next vesting dates | the schedule at 30-day steps after the cliff | up to six future dates, stopping at the end date, with the cumulative amount and percentage |
| Recent movements | getSignaturesForAddress, last 10 | when the escrow last saw a transaction and whether it failed |
If claimed is larger than vested, the viewer says the grant is ahead of schedule. That usually means the schedule you entered differs from the one in the contract, and it is the first thing to check.
The build
The viewer is one file that needs @solana/kit and what Node 24 ships. It is read-only: no private key, nothing sent.
- Read the escrow address from the command line and the three schedule dates from VEST_START, VEST_CLIFF and VEST_END, each an ISO date such as 2026-04-01. VEST_TOTAL is the grant size in whole tokens, written as a decimal string.
- Call getAccountInfo and getSignaturesForAddress together, both at confirmed commitment, each settled on its own, so a failed history call still leaves the balance on screen.
- Check that the parsed account is a token account, then take the mint, owner and raw amount from it. The raw amount and the grant stay bigints all the way, and the decimals only matter when printing.
- Compute the vested amount at any time as zero before the cliff and the grant times elapsed over duration after it, capped at the grant. Print it for now and for the next six 30-day steps after the cliff that still lie ahead, stopping at the end date.
- Print claimed, claimable and the last 10 movements with their block times.
// BI0024 · Token vesting schedule viewer// https://carbium.sh/library/blockchainideas/token-vesting-schedule-viewer// 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);}const escrow = process.argv[2];if (!escrow) { console.error("Usage: node main.ts <escrow token account>"); process.exit(1);}const rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key }, }),);// The schedule is yours to enter: ISO dates, in whole tokens for VEST_TOTAL.const when = (name: string, fallback: string) => Date.parse(process.env[name] ?? fallback) / 1000;const start = when("VEST_START", "2026-01-01");const cliff = when("VEST_CLIFF", "2026-04-01");const end = when("VEST_END", "2028-01-01");if (!(start <= cliff && cliff < end)) { console.error("Invalid dates: need VEST_START <= VEST_CLIFF < VEST_END, as ISO dates."); process.exit(1);}const [acct, sigs] = await Promise.allSettled([ rpc.getAccountInfo(address(escrow), { encoding: "jsonParsed", commitment: "confirmed" }).send(), rpc.getSignaturesForAddress(address(escrow), { limit: 10, commitment: "confirmed" }).send(),]);if (acct.status === "rejected") { console.error("getAccountInfo failed:", acct.reason instanceof Error ? acct.reason.message : acct.reason); process.exit(1);}interface Parsed { data?: { parsed?: { type?: string; info?: { mint: string; owner: string; tokenAmount?: { amount: string; decimals: number } } } } }const account = acct.value.value as unknown as Parsed | null;if (!account) { console.error("Account not found. It may be closed, or the address is a typo."); process.exit(1);}const parsed = account.data?.parsed;const info = parsed?.info;if (parsed?.type !== "account" || !info?.tokenAmount) { console.error("Not a token account (a mint, a wallet or another program account). Pass the token account address."); process.exit(1);}const { decimals } = info.tokenAmount;const balance = BigInt(info.tokenAmount.amount);const fmt = (raw: bigint) => (Number(raw) / 10 ** decimals).toLocaleString("en-US", { maximumFractionDigits: 2 });let total = balance;if (process.env.VEST_TOTAL) { const m = /^(\d+)(?:\.(\d*))?$/.exec(process.env.VEST_TOTAL.trim()); if (!m || (m[2] ?? "").length > decimals) { console.error(`Invalid VEST_TOTAL: use whole tokens with at most ${decimals} decimals, such as 1500000.25.`); process.exit(1); } total = BigInt(m[1] + (m[2] ?? "").padEnd(decimals, "0"));}const vestedAt = (ts: number): bigint => ts < cliff ? 0n : ts >= end ? total : (total * BigInt(Math.floor(ts - start))) / BigInt(Math.floor(end - start));const now = Date.now() / 1000;const vested = vestedAt(now);const claimed = total > balance ? total - balance : 0n;console.log(`escrow ${escrow}`);console.log(`mint ${info.mint}, owner ${info.owner}, decimals ${decimals}`);console.log(`locked ${fmt(balance)}, total ${fmt(total)}, vested ${fmt(vested)}, claimed ${fmt(claimed)}`);console.log(claimed > vested ? `ahead of schedule by ${fmt(claimed - vested)}` : `claimable ${fmt(vested - claimed)}`);console.log("next vesting dates (30-day steps after the cliff):");const step = 30 * 86_400;const first = now < cliff ? 0 : Math.floor((now - cliff) / step) + 1;for (let i = first; i < first + 6; i++) { const ts = cliff + i * step; if (ts > end) break; const pct = total === 0n ? 0 : Number((vestedAt(ts) * 10_000n) / total) / 100; console.log(` ${new Date(ts * 1000).toISOString().slice(0, 10)} ${fmt(vestedAt(ts))} ${pct.toFixed(2)}%`);}if (sigs.status === "rejected") console.error("getSignaturesForAddress failed:", String(sigs.reason));else { console.log(`recent movements (${sigs.value.length}):`); for (const s of sigs.value) { const at = s.blockTime ? new Date(Number(s.blockTime) * 1000).toISOString() : "unknown time"; console.log(` ${at} ${s.signature.slice(0, 12)} ${s.err ? "failed" : "ok"}`); }}
run: CARBIUM_KEY=<YOUR_KEY> VEST_START=2026-01-01 VEST_CLIFF=2026-04-01 VEST_END=2028-01-01 node main.ts <ESCROW_TOKEN_ACCOUNT>
A grant with 1,000,000 tokens, a start on day 0, a one-year cliff and an end after four years shows the usual shape. Nothing is vested for the first year. On the cliff date a quarter vests at once, because the clock has run since the start. After that the amount grows in a straight line to the end. The viewer needs only the start, cliff and end for this, so a schedule you read off a project's announcement works as long as the contract follows it.
What it costs
One refresh of the view is two reads: getAccountInfo at 10 cells and getSignaturesForAddress at 50 cells, 60 cells together. Cells are the admission charge per call, and each plan allows each method at its own rate.
| Plan | Credits | getAccountInfo | getSignaturesForAddress |
|---|---|---|---|
| Free ($0) | 500K once, at sign-up | 0.5 req/s | 0.24 req/s |
| Dev ($20) | 10M per month | 15 req/s | 1.2 req/s |
| Business ($250) | 50M per month | 50 req/s | 100 req/s |
| Pro ($500) | 200M per month | 400 req/s | 500 req/s |
On Free, the history call is the slower of the two: 0.24 req/s is one call about every four seconds, so a page that refreshes more often than that should drop the movements list or cache it. Limits are per account, so other tools on the same keys draw on the same budget.
To watch many escrows on one screen, read the balances with getMultipleAccounts and skip the history. It charges 10 cells per pubkey, so 100 escrows cost 1000 cells in one call. Below Pro the 1024-cell burst caps a call at 100 pubkeys, and Pro takes up to 300. Fetch history only for the escrow a user opens.
What to add next
- A list view: read a team's escrows with getMultipleAccounts and show vested over locked for each as a bar.
- A calendar file: write the next vesting dates as an .ics file so a beneficiary gets reminders.
- Stepped schedules: replace the straight line with a list of date and amount pairs from a JSON file, for grants that vest in tranches.
- A claim alert: poll the balance and post a message when it falls, using the pattern in Multi-address deposit monitor.
- Contract decoding: read the schedule from the vesting program's own account with its IDL, as in Anchor instruction decoder, and drop the date variables.
Where it ends
- The viewer does not decode any vesting program. The schedule is the three dates you enter, so a contract with a different curve gives a wrong vested figure.
- It reads one token account. A wallet can own more than one token account for one mint, and a program may split a grant across several escrows. Run it once per escrow and add the results by hand.
- The 30-day steps for future vesting dates are an approximation. A calendar month averages about 30.4 days, so the drift grows by about half a day per step. A contract that releases monthly tranches vests in steps that the straight line does not show.
- Claimed is inferred from the balance. Tokens that left the escrow through a cancel, a clawback or a transfer to the team show as claimed.
- Movement history comes from the address index, which keeps up to 30 days. An empty page past that is the index's age limit, and the escrow may have older transactions.
- A closed escrow, emptied after the final claim, has no account to read, and the viewer reports it as not found.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The account is not found. | The escrow may be closed after its last claim, or the address is a typo. Check the address on an explorer and pass the token account itself. |
| The viewer says the address is not a token account. | You passed a wallet, a mint or a program state account such as a stake account. Find the token account with getTokenAccountsByOwner for the escrow owner and the mint, then pass that address. |
| Claimed is zero or the grant looks ahead of schedule. | The balance is above the total, or the schedule dates differ from the contract. Set VEST_TOTAL to the real grant size and compare the dates with the contract. |
| The viewer stops with an invalid date or invalid total message. | Give the dates as ISO strings such as 2026-04-01, with the start on or before the cliff and the cliff before the end. Give VEST_TOTAL as plain digits with an optional decimal part, such as 1500000.25. |
| The movements list is empty for an old escrow. | The address index keeps up to 30 days. An empty list means nothing moved in that window, and older history is not served. |
| The call answers 401. | The key is unknown at the door. Attach the whole key in CARBIUM_KEY, with no trailing space. |
Questions
Can it read the vesting schedule from the contract itself?
Not in this version. Every vesting program stores its schedule in its own account layout, so you would decode that account with the program's IDL. The viewer takes the three dates from you and checks them against the escrow balance.
How do I find the escrow token account for a grant?
Open the transaction that created the grant and look for the token account that received the tokens. Its owner is usually a program-derived address, and a lookup of token accounts by that owner and the mint lists the rest.
Does this run on the Free plan?
Yes. A refresh is 60 cells, and the slower call is the history read at 0.24 req/s, about one call every four seconds. A page that updates less often than that stays inside the limit.
Why does the vesting table use 30-day steps?
The schedule is a straight line, so any step size works. Thirty days keeps the dates easy to compare. If your contract vests on calendar months, change the step in the code to match.