Reorgs and confirmations: how many blocks is safe?
Every backend that credits a deposit has to answer one question: when is a transaction final enough to act on? Treat a block as final too early and a reorg can erase a deposit you already credited. Wait too long and you frustrate users. The right answer is per-chain.
Why reorgs happen at all
When two valid blocks are produced at nearly the same height, the network temporarily disagrees on the tip. One branch wins as more blocks build on it, and transactions in the losing branch return to the mempool. This is normal consensus behaviour, not an attack. Short one- to two-block reorgs happen routinely on most chains.
Finality models differ
Proof-of-work chains like Bitcoin have probabilistic finality: deeper confirmations mean exponentially lower reversal odds, never exactly zero. Ethereum post-Merge adds economic finality through checkpoints roughly every two epochs (~13 minutes), after which reversal requires slashing a third of stake. L2s inherit their own reorg surface from the sequencer plus the settlement layer. One threshold does not fit all.
Practical thresholds
Common production settings: Bitcoin 3–6 confirmations depending on value, Ethereum 12–32 blocks (or wait for the finalized tag), high-throughput EVM chains proportionally more blocks because block times are shorter. For anything high-value, key off the finalized/justified tag rather than a raw block count so you inherit the chain's own finality guarantee.
Detecting a reorg in your backend
Track the block hash you credited against, not just the height. On each new head, walk back and confirm the parent hashes still match what you recorded; a mismatch means a reorg you must handle by reversing provisional credits. Subscribing to new heads and reconciling hashes is cheaper than debugging a double-credit after the fact.
Perguntas frequentes
Can I just wait longer to be completely safe?
Waiting longer lowers risk but never reaches zero on probabilistic chains, and it hurts UX. Using a chain's finality tag where one exists is a better lever than simply increasing a block count.
Do L2s reorg?
Yes. A centralized sequencer can reorder or drop unconfirmed transactions, and the L2 also depends on its settlement layer. Treat L2 finality as a function of both the sequencer and L1 settlement.
Related
Recarregue, pegue a chave e publique.
Autoatendimento. Pague em cripto ou cartão. Medido por créditos: primitivas pesadas custam mais, as simples são baratas.
Obter chave de API