Sub topic 11
Confirmations and finality
This chapter assumes you know what a transaction, a block and a gas fee are, and that you can read short JavaScript snippets. It covers how to decide when a payment has arrived for good. That decision matters more than the moment a wallet shows "received".
Why inclusion is not the end
A transaction is first included when a block producer puts it in a block. Inclusion does not make it permanent. Two things can still happen:
- The block can be replaced by a competing block at the same height. This is a reorganization, or reorg. The transaction may then return to the pending pool, land in a different block, or be dropped.
- The network can stay on the same chain while your transaction's block is still only weakly protected against future replacement.
Waiting reduces the chance of a reversal. The chapter's central idea is that "safe" is a threshold you choose based on the value at risk and on the rules of the specific network.
Confirmations
A confirmation count is the number of blocks that now sit on the chain at or above the block containing your transaction. When your transaction is in the newest block, it has 1 confirmation. When the next block is added, it has 2, and so on.
The formula is:
confirmations = currentBlock - txBlock + 1This matches the second code example in the topic spine. If txBlock is 100 and the chain head is 105, you have 6 confirmations.
Each new block built on top of yours makes a reorg that removes your transaction more expensive for an attacker, or less likely by chance. The relationship is probabilistic on proof-of-work chains and rule-based on finality-gadget chains, as described below.
In the diagram, the chain head is block 102, so the transaction in block 100 has 102 - 100 + 1 = 3 confirmations.
Two kinds of finality
Finality is the point at which a transaction cannot be reversed under the network's rules, or can only be reversed at a cost the system treats as prohibitive. Networks reach it in different ways.
| Model | How it works | What "final" means | Typical examples |
|---|---|---|---|
| Probabilistic finality | The longest or heaviest chain wins. Each extra block makes reversal less likely. | Never absolute. You choose a confirmation count that makes reversal negligible. | Bitcoin, Litecoin, older proof-of-work chains |
| Economic or deterministic finality | Validators vote to finalize checkpoints. Finalized blocks cannot be reverted without a large fraction of stake being destroyed, or without a protocol failure. | A specific finalized status, reached after a defined delay. | Ethereum (proof of stake), Cosmos chains with instant finality |
Exact numbers vary by network and change over time, so confirm them in the network's documentation before you build a payment rule around them.
Probabilistic finality in practice
On Bitcoin, 6 confirmations became the common rule of thumb for large payments, which takes roughly an hour at about 10 minutes per block. Small payments are often accepted at 1 to 3 confirmations. These are conventions, not protocol guarantees.
Finality on Ethereum
Ethereum proof of stake produces a block in each 12-second slot. Validators also vote on checkpoints once per epoch, which is 32 slots. A block moves through three labels that you can query by name:
latest: the newest block the node has seen. It can still be reorganized.safe: a block that the protocol considers unlikely to be reorganized under normal conditions.finalized: a block that has been finalized by the validator vote. Reverting it would require at least one third of the total staked ether to be slashed.
Finalization normally takes about two epochs, which is roughly 13 to 15 minutes. If the network has trouble reaching agreement, finalization can stall while new blocks still appear. A confirmation count alone will not tell you this has happened, but the finalized label will.
Checking confirmations in code
The topic spine's example computes confirmations from the transaction's block number. Here is the same idea expanded into a reusable function that also checks the finalized block on Ethereum-style networks.
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
async function checkTransaction(txHash) {
const receipt = await provider.getTransactionReceipt(txHash);
if (receipt === null) {
return { state: "pending" };
}
if (receipt.status !== 1) {
return { state: "failed", block: receipt.blockNumber };
}
const head = await provider.getBlockNumber();
const finalizedBlock = await provider.getBlock("finalized");
const confirmations = head - receipt.blockNumber + 1;
const finalized =
finalizedBlock !== null && receipt.blockNumber <= finalizedBlock.number;
return {
state: finalized ? "finalized" : "included",
block: receipt.blockNumber,
confirmations,
};
}
const result = await checkTransaction(process.env.TX_HASH);
console.log(result);Points to note:
getTransactionReceiptreturnsnullwhile the transaction is not in a block. A receipt exists only after inclusion.receipt.statusis1for success and0for a revert. A reverted transaction still has confirmations, and it still costs gas, but it moved no value.- Do not rely on a receipt you fetched earlier. After a reorg, the block hash in the old receipt may no longer be on the canonical chain. Compare
receipt.blockHashwith(await provider.getBlock(receipt.blockNumber)).hashif you need to detect this. - Some chains and RPC providers do not support the
finalizedtag. In that casegetBlock("finalized")throws an error, so wrap the call in a try/catch if your code runs on several networks.
Choosing a threshold
No single number is correct. Use these inputs:
- Value at risk. A coffee payment and a house deposit need different thresholds.
- Network design. A deterministic-finality chain lets you wait for the finalized flag. A proof-of-work chain needs a count.
- Network health and hash power. Smaller proof-of-work chains have been attacked with deep reorgs. They need more confirmations than Bitcoin does for the same value.
- Reversibility of what you hand over. Digital goods you can revoke tolerate fewer confirmations. Physical goods or an irreversible off-chain payout need more.
- Your own system. Exchanges publish a required count per asset, and your service should do the same.
A reasonable policy looks like a table of tiers:
| Payment size | Policy on a proof-of-work chain | Policy on Ethereum |
|---|---|---|
| Small | 1 to 3 confirmations | Included and `safe` |
| Medium | 6 confirmations | `finalized` |
| Large | Exchange-grade count, often well above 6 | `finalized`, plus a manual check |
These tiers are illustrative. Set your own after reading the network's current guidance.
Layer 2 networks and bridges
Rollups add a second notion of finality. A rollup such as Arbitrum or Optimism quickly orders your transaction, which gives you a fast "soft" confirmation. The transaction is only as final as the batch data posted to Ethereum, and optimistic rollups also have a challenge window. Withdrawing from an optimistic rollup to Ethereum can take about a week for that reason. Zero-knowledge rollups generally finalize once a validity proof is verified on Ethereum, which is often much faster.
When you accept funds that come across a bridge, check which layer's finality your counterparty relies on. A payment that is final on the rollup may still depend on events on the base chain.
Edge cases and gotchas
- Dropped transactions. A transaction that never confirms is not reversed, since it was never final. See the chapter on pending and stuck transactions for how to handle it.
- Replaced transactions. A transaction with the same nonce and a higher fee can replace yours before inclusion. Your original hash then never appears in a block. Track by sender and nonce when you can, not just by hash.
- Reorg changes the block, not always the outcome. After a reorg, the same transaction can reappear in a later block with a different block number and sometimes a different result, such as a revert when the state changed. Re-read the receipt rather than assuming.
- Event-based deposits. If you credit users from token
Transferevents, those logs vanish when a block is reorganized. Wait for your threshold before crediting, and handle removed logs if you subscribe to live events. - Single RPC provider. One node can be behind, on a minority fork, or restricted. For large amounts, check a second provider.
- Confirmed is not correct. A final transaction can still go to the wrong address or the wrong network. Finality makes the mistake permanent. It does not validate the recipient.
Summary
Inclusion is a first step. Confirmations measure depth on probabilistic chains. Explicit finality labels measure agreement on chains with validator voting. Choose a threshold from the value at risk and the network's design, re-check the receipt, and treat the recipient and network as your responsibility, because finality only locks in what you sent.
Exercise
A transaction is in block 4,200. The chain head is block 4,205. How many confirmations does it have, and why is that count not enough on its own to call an Ethereum payment final?
Show answer
It has 4,205 - 4,200 + 1 = 6 confirmations. On Ethereum, a confirmation count only shows depth. Finality comes from the validator vote on checkpoints, so you should check that the block number is at or below the finalized block. If finalization is stalled, the count keeps rising while the payment is still not final.
Exercise
Your service credits users from ERC-20 Transfer events as soon as it sees them. Name one risk and one fix.
Show answer
Risk: a reorg can remove the block that contained the event, so the user keeps credit for a transfer that no longer exists. Fix: wait until the transaction's block reaches your threshold, for example the finalized status or a set confirmation count, and handle removed logs if you use live subscriptions.
Exercise
Why can a transaction with a successful receipt still be a problem for the sender, even after finality?
Show answer
Finality only makes the transfer permanent. If the recipient address or the network was wrong, the funds are still lost, because the transaction is irreversible once final.