services
Get a key

library / Blockchain ideas / Developer tools / BI0111

Confirmation time estimator

A read-only check to run before a large swap. It prints the current slot pace, how much of the last 150 slots your bid would have cleared on your accounts, how long your blockhash has left, and a rough wait.

By Carbium · Developer tools · BI0111 · updated 2026-11-23

01

Who uses it

Someone about to send a large swap wants two answers first: how long will it take to land, and will the blockhash I sign outlive that wait. Solana has no public list of pending transactions to watch. The answer has to come from what the chain has already published: how fast slots are passing, what the last 150 slots charged as a minimum fee on the accounts your order writes to, and how many blocks your blockhash has left.

The script reads those three, takes the bid you plan to pay in micro-lamports per compute unit, and prints a rough wait beside the time the blockhash allows. A treasury team can run it before a rebalance, a hackathon team can put it behind the confirm button of a swap form, and a wallet can show a warning when the wait looks long. Every call goes to services.carbium.sh with one key, and nothing is signed or sent.

02

What it reads

SignalWhere it comes fromHow the estimate uses it
Slot pacegetRecentPerformanceSamples: sample period divided by slots, one sample per minuteSeconds per slot now, against the median of the last 30 minutes
Blockhash lifegetLatestBlockhash and getBlockHeight, both at confirmed commitmentBlocks left before the hash stops being accepted, turned into seconds with the slot pace
Fee floorgetRecentPrioritizationFees for each account you listThe share of the last 150 slots whose minimum fee your bid meets

A slot lasts about 200 ms since the Alpenglow switch, so one minute's sample holds around 300 slots. Pace matters because a slow minute stretches every wait in the estimate by the same factor.

The fee read returns one number per recent slot: the smallest priority fee among the landed transactions in that slot that write-lock the account you named. A slot where nothing wrote to that account reports the smallest fee in the whole block instead, which is often zero. A bid at or above that number does not promise a place in the block. A bid below it means that slot held nothing as low as yours, so the share of slots your bid meets works as a stand-in for the chance that any one slot would have taken your transaction.

With no address the read covers every transaction, and most slots show zero because some transaction in them paid no extra fee. List the pool and the vaults your swap touches, and each account gets its own line, so you can see which one sets the floor.

03

The build

One file, @solana/kit and what Node 24 ships.

  1. Read the last 30 performance samples and turn each into seconds per slot.
  2. Read the latest blockhash and the block height, both at confirmed commitment, and subtract to get the blocks left.
  3. Read recent fees once for the whole chain and once for each account on the command line.
  4. For each list, count the slots whose minimum your bid BID_MICROLAMPORTS meets. Each slot is one chance, so the expected number of slots is the inverse of that share.
  5. Multiply by the slot pace and compare with the seconds the blockhash has left.
main.ts
// BI0111 · Confirmation time estimator// https://carbium.sh/library/blockchainideas/confirmation-time-estimator// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";const apiKey = process.env.CARBIUM_KEY;if (!apiKey) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const client = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": apiKey },  }),);const bid = Number(process.env.BID_MICROLAMPORTS ?? 0);const accounts = process.argv.slice(2).map((a) => address(a));const order = (v: number[]) => v.slice().sort((x, y) => x - y);const mid = (v: number[]) => order(v)[Math.floor(v.length / 2)] ?? 0;const top = (v: number[]) => order(v)[Math.floor((v.length - 1) * 0.9)] ?? 0;const msg = (e: unknown) => (e instanceof Error ? e.message : String(e));async function pace(): Promise<number> {  try {    const rows = await client.getRecentPerformanceSamples(30).send();    const secs = rows.map((r) => Number(r.samplePeriodSecs) / Number(r.numSlots)).filter(isFinite);    console.log(`slot pace ${Math.round(secs[0]! * 1000)} ms now, median ${Math.round(mid(secs) * 1000)} ms over ${secs.length} minutes`);    return secs[0] ?? NaN;  } catch (e) {    console.error(`samples failed: ${msg(e)}`);    return NaN;  }}async function room(slotSecs: number): Promise<number> {  try {    const [h, now] = await Promise.all([      client.getLatestBlockhash({ commitment: "confirmed" }).send(),      client.getBlockHeight({ commitment: "confirmed" }).send(),    ]);    const blocks = Number(h.value.lastValidBlockHeight - now);    console.log(`blockhash has ${blocks} blocks left, about ${(blocks * slotSecs).toFixed(0)} s at that pace`);    return blocks * slotSecs;  } catch (e) {    console.error(`blockhash or height failed: ${msg(e)}`);    return NaN;  }}async function floor(name: string, list: ReturnType<typeof address>[], slotSecs: number, hashSecs: number) {  try {    const mins = (await client.getRecentPrioritizationFees(list).send()).map((f) => Number(f.prioritizationFee));    if (!mins.length) return console.log(`${name}: no fee data`);    const share = mins.filter((m) => m <= bid).length / mins.length;    console.log(`${name}: slot minimums median ${mid(mins)}, p90 ${top(mins)} micro-lamports/CU; bid ${bid} clears ${Math.round(share * 100)}% of ${mins.length} slots`);    if (share === 0) return console.log("  no recent slot would take this bid: the wait outlives the blockhash, raise it");    const slots = Math.ceil(1 / share);    const wait = slots * slotSecs;    console.log(`  rough wait ${wait.toFixed(1)} s (${slots} slots), ${wait > hashSecs ? "longer than the blockhash allows, raise the bid" : "inside the blockhash window"}`);  } catch (e) {    console.error(`fees ${name} failed: ${msg(e)}`);  }}const slotSecs = await pace();const hashSecs = await room(slotSecs);await floor("whole chain", [], slotSecs, hashSecs);for (const a of accounts) await floor(a, [a], slotSecs, hashSecs);

run: CARBIUM_KEY=<YOUR_KEY> BID_MICROLAMPORTS=1000 node main.ts 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2

The reads settle one by one, so a failed fee read for one account prints its message while the pace and blockhash lines still report.

04

Reading the output

Set BID_MICROLAMPORTS to the compute unit price your sender will put on the transaction. Priority fee per compute unit shows where that number goes. Then read the share each account line reports.

  • Clears 100 percent: any recent slot would have taken the bid, so the wait is about one slot at the current pace plus the time your sender needs to reach a leader.
  • Clears 50 percent: the rule gives two slots. Half the recent slots had a minimum above your bid.
  • Clears 0 percent: no recent slot would have taken it, and the line says the wait outlives the blockhash. Raise the bid before you sign.

A blockhash is accepted for 150 blocks, about 30 seconds at the current pace. A wait the script puts past that figure is a reason to raise the bid or to sign again with a fresh hash. Before you resend the same transaction, check that the first one did not land: Duplicate-safe retry check covers that read.

A large swap often writes more accounts and needs more compute units than a transfer, so list every account it locks. The slowest line is the one to plan around.

05

Cost and tuning

One run is three reads plus one fee read for the whole chain and one for each account, so two accounts make six calls. RPC work draws on your credits, each call carries a cell charge against your rate, and limits are per account, so other tools on the same keys share the budget.

Run it a few times in the minute before you send, not once an hour ahead. The fee list spans about 30 seconds and the pace sample is a finished minute, so a run older than that describes a chain that has moved on. For a standing view of load, Network congestion alerts polls the same chain-wide signals on a timer.

06

What to add next

  • A loop: wrap the run in a timer and print only when the estimate crosses your limit.
  • A landing watch: after you send, signatureSubscribe sends one confirmation for your signature and then ends, which gives you the real wait for that transaction.
  • A record of real waits: write the send time and the confirmation time of your own transactions to node:sqlite. After a few days the measured wait is a better guide than the rule here, and you can fit the rule to it.
  • A price check: a long wait moves the quote. Swap slippage settings covers the tolerance to set before you sign.
07

Where it ends

  • It cannot see a queue. Nodes do not expose pending transactions, so it reads what landed and says nothing about transactions in flight ahead of yours.
  • The fee floor is the smallest fee that landed in a slot. A slot where nothing wrote to your account reports the whole block's floor, and a slot the leader never produced has no entry, so on a quiet account the share can look better than the real chance.
  • The rule treats every slot as an independent try. A leader that drops your sender's connection, or a hot account that stays contended for several slots in a row, breaks that, so read the output as a rough figure.
  • Block height moves more slowly than the slot count when slots are skipped, so the blockhash seconds, computed from slot pace, can run a little short: the hash often stays valid longer than the line says.
  • The estimate is for confirmed commitment. A sender that waits for finalized adds up to one more slot.
  • It does not model price. The quote you hold ages while you wait.
08

When it goes wrong

what goes wrongwhat to do
Every fee line says the bid clears 100 percent, even at a bid of 0.No address was given, so the read covers the whole chain and most slots show a minimum of zero. Pass the pool and vault addresses your swap writes to.
A fee line prints a failure message and the pace and blockhash lines still show.The reads settle on their own. Read the message, check the address is a valid public key, and run again. The lines that printed are still good.
Every call answers 401.The key is unknown at the door. Check that CARBIUM_KEY holds the whole key with nothing cut off.
Blocks left sits a few under 150 on every run.That is normal. The two reads answer a moment apart, and a block or two can pass between them. Treat the number as the room you have at read time and subtract the time you need to sign.
The share jumps between runs on a quiet pool.Few transactions write to the account, so a handful of slots decide the share. Run it three times and plan around the smallest share, or list a busier account of the same swap.
09

Questions

Can I see pending Solana transactions before I send mine?

Not through RPC. Transactions travel from senders to the current leader with no public queue, so nodes expose only what has landed. The estimate here is built from that landed history.

How long does a transaction take to confirm?

A slot is about 200 ms since the Alpenglow switch, and a transaction that meets the fee floor can land in the next block or two. The wait grows by one slot for each block that held nothing as low as your bid.

What bid should I use for a large swap?

Start at the 90th percentile of the per-slot minimums for the accounts the swap writes to, run the script with that bid, and raise it until each line clears 90 percent or more.

Does a run cost credits?

Yes. Each read is metered work with a cell charge against your rate, and limits are per account, so other tools on the same keys share the budget. A run with two accounts makes six calls.