library / How to use Solana / HS0028
Dropped transaction detector
One TypeScript file takes a signature and its last valid block height, reads the chain height and the signature status, and prints landed, failed, pending, dropped or unknown. With no argument it checks an address's latest signatures and a control that never landed.
What dropped means
A dropped transaction never made it into any block. Your RPC node gave you a signature at send time, yet no leader packed the transaction, and no later query will turn it up. Solana exposes no dropped flag. You deduce the state from two readings: the signature status is null, and the chain has advanced beyond the final height at which the transaction was allowed to land.
That final height is tied to the blockhash. Each transaction names a recent blockhash that stays usable for roughly 150 blocks. getLatestBlockhash hands back the hash together with lastValidBlockHeight, the ceiling after which anything built on it is dead. Store that number beside the signature when you send. Lacking it, a null status tells you little, since the transaction could still be queued somewhere.
The causes are mundane. The node you submitted to may shed it under load, a leader may skip it, the blockhash may age out during the wait, or the slot that held it at processed may be skipped once its fork is abandoned. The detector ignores which of these happened. It reports only whether the signature can still land.
The code
Install @solana/kit at 8.6.0, export CARBIUM_KEY and start the file with Node 24, which strips the types itself. Pass a signature plus the lastValidBlockHeight you stored, or pass an address. For an address it fetches the three newest signatures and appends a control: a signature of 64 zero bytes that nobody ever sent, paired with a window that closed at height 0. The control demonstrates a drop, so you can try the file before you own a transaction to test.
// HS0028 · Dropped transaction detector// https://carbium.sh/library/howsolana/dropped-transaction-detector// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { createDefaultRpcTransport, createSolanaRpcFromTransport, isAddress, signature, type Signature,} 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 rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url, headers: { "x-api-key": key } }),);const fail = (call: string, e: unknown) => console.error(`${call} failed:`, e instanceof Error ? e.message : e);// <signature> [lastValidBlockHeight], or an address (default: the Token program) for its latest signatures.const [target = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", lastArg] = process.argv.slice(2);const checks: { sig: Signature; lastValid?: bigint; label: string }[] = [];if (isAddress(target)) { try { const rows = await rpc .getSignaturesForAddress(target, { limit: 3, commitment: "confirmed" }) .send(); for (const row of rows) checks.push({ sig: row.signature, label: "landed signature" }); } catch (e) { fail("getSignaturesForAddress", e); } // 64 zero bytes: a signature nobody sent, with a window that closed at height 0. checks.push({ sig: signature("1".repeat(64)), lastValid: 0n, label: "control, never sent" });} else { checks.push({ sig: signature(target), lastValid: lastArg === undefined ? undefined : BigInt(lastArg), label: "your signature", });}// Height first: past the window and still null means the transaction can never land.let height: bigint | undefined;try { height = await rpc.getBlockHeight({ commitment: "confirmed" }).send();} catch (e) { fail("getBlockHeight", e);}async function readStatuses(sigs: Signature[]) { try { const res = await rpc.getSignatureStatuses(sigs, { searchTransactionHistory: true }).send(); return res.value; } catch (e) { fail("getSignatureStatuses", e); return undefined; }}const value = await readStatuses(checks.map((c) => c.sig));function verdict(status: NonNullable<typeof value>[number], lastValid?: bigint): string { if (status !== null) { return status.err !== null ? "failed (ran, rolled back)" : `landed (${status.confirmationStatus})`; } if (lastValid === undefined || height === undefined) return "unknown (needs lastValidBlockHeight and the height)"; return height > lastValid ? "DROPPED (window closed, never landed)" : "pending (window still open)";}console.log(`block height ${height ?? "unavailable"}`);for (const [i, c] of checks.entries()) { const v = value === undefined ? "unknown (status read failed)" : verdict(value[i] ?? null, c.lastValid); console.log(`${c.label}: ${c.sig}\n ${v}`);}
run: node main.ts <signature> [lastValidBlockHeight] | <address>
The two reads run in a fixed order: height first, statuses second. Suppose the height is already beyond lastValidBlockHeight and the status read that follows still says null. Then nothing can land any more and the verdict is final. Swap the order and a transaction could land between the reads, which would label a good transaction as dropped.
getSignatureStatuses runs with searchTransactionHistory: true, so the node also searches its ledger beyond the recent-slot cache. That method accepts no commitment option. getBlockHeight has confirmed spelled out. @solana/kit 8.6.0 would supply confirmed for it anyway, while the JSON-RPC server itself defaults to finalized. Each of the three calls sits in its own try block. When one fails, the file prints the name of the call and the error, and reports unknown instead of guessing. In address mode the control is still checked when the address lookup fails.
Reading the verdict
| Status | Block height | Verdict | What to do |
|---|---|---|---|
| Object, err is null | Any | Landed, at the level confirmationStatus names | Stop. It is not dropped. |
| Object, err is set | Any | Failed | It ran and rolled back. Fix the cause and build a new transaction. |
| null | At or below lastValidBlockHeight | Pending | Poll again. Resending the same signed bytes is safe. |
| null | Above lastValidBlockHeight | Dropped | Build a new transaction with a fresh blockhash and sign it again. |
| null | lastValidBlockHeight not supplied | Unknown | Find the saved height, or treat it as pending. |
A slot now takes about 200 ms, so the 150-block window shuts after roughly half a minute. A signature that landed shows a status within a poll or two.
Before you resend
- While the window is open, submit the identical signed bytes. The signature stays the same, so the cluster executes it once and ignores repeats. A sendTransaction call costs 20 cells without preflight and 70 with it.
- Once the window has closed, build a fresh transaction. It carries a new blockhash and so a new signature. Query the old signature one final time first, since a transaction that made the last block would otherwise be paid for twice.
For a push instead of polling, signatureSubscribe delivers one confirmation and then ends. Connect to wss://services.carbium.sh with the key as ?api-key= in the URL. Opening it costs 5 credits and every MiB sent costs 20. A transaction that never confirms sends nothing, so silence is the only hint of a drop, and the height check must still say when that silence is final. For one signature, polling every second is plenty.
A pending verdict also invites a look at why. In congested periods a transaction with a low priority fee and no compute-unit limit can sit in the queue until its blockhash dies. The priority fee per compute unit entry shows how to read current fees before you rebuild.
On Carbium
The status and height reads need no signing key, and the file holds none. Address mode adds one getSignaturesForAddress, which costs 50 cells and runs at 0.24 req/s on Free, 1.2 on Dev, 100 on Business and 500 on Pro.
The control signature never changes, so its answer never changes either: null, with a height far above 0. If the file ever prints anything other than DROPPED for it, the height read or the status read is wrong, and that needs fixing before you trust a verdict on a real transaction.
With several signatures in flight, call getSignatureStatuses once with the whole list and read the height once. That one height read serves every signature, each compared against its own saved lastValidBlockHeight. Signatures that share a blockhash also share that number.
Where it ends
A verdict is only as good as the lastValidBlockHeight you stored. The signature alone cannot tell you when its window closed. Address mode cannot recover the height either: it lists signatures that already landed, so it exercises the landed path, while the control exercises the dropped path. A real drop needs your own send and your own saved height.
A null also comes back for a signature older than the history the node holds. Run against such a signature with a small height, the file would print DROPPED for a transaction that landed long ago. Apply the verdict to signatures you sent inside the current window and never to old ones. The address mode reads getSignaturesForAddress, which on Carbium reaches back 30 days at most, from its own address index. An empty page past that is the index's age limit and does not show the address's first transaction.
Transactions that use a durable nonce carry no blockhash window. They stay valid until the nonce advances, so this rule does not apply to them, and a null status on one never becomes a drop by height.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| A signature that landed long ago prints DROPPED. | The node no longer holds that history, so the status is null. Apply the check only to signatures sent inside the current blockhash window, with the height you saved at send time. |
| The verdict stays unknown. | No lastValidBlockHeight was passed, or the height or status read failed and the file printed the failing call above the verdict. Pass the saved height as the second argument, or rerun when the call answers. |
| A signature that read as processed shows null on the next run. | Its fork was dropped along with the slot. Wait for confirmed or later before you relax, and run the height check again. |
| The file throws on an argument before any request leaves. | A signature is 64 bytes, about 87 or 88 base58 characters. A string of about 43 or 44 characters is an address: pass it alone and the file takes its latest signatures instead. |
| The verdict says pending for far longer than half a minute. | The height you passed is probably from a later blockhash than the one the transaction signed, or the chain height read is stale. Pass the lastValidBlockHeight returned with the transaction's own blockhash. |
Questions
How long until I can call a transaction dropped?
Once the block height passes the lastValidBlockHeight you got with the blockhash and the status is still null. That is about 150 blocks after the blockhash, which at about 200 ms a slot is roughly half a minute.
Can I tell a drop from the signature alone?
No. A null status means the transaction has not landed yet or never will, and only the saved height separates the two. Store it next to every signature when you send.
Is it safe to resend before the window closes?
Yes, if you send the same signed bytes. The signature is identical, so the cluster accepts the transaction once. A new transaction with a new blockhash is a different signature and can land as well, so wait for the window to close first.
Does this need a keypair?
No. It reads a height and a status for signatures, which are public. The Carbium key only identifies your account to the RPC.