What is double spend?

Spending the same coin twice, the problem a blockchain's consensus mechanism exists to prevent.

Not yet verifiedHow we verify

3 min read

In this entry

Spending the same coin twice, the problem a blockchain's consensus mechanism exists to prevent.

Once a transaction has enough confirmations, reversing it would mean rewriting the chain, which is why exchanges wait before crediting deposits. Digital money without a central ledger has no other way to stop the same balance being promised to two people, and solving it is the whole point of the design set out in the Bitcoin white paper.

The misunderstanding worth clearing up: a double spend is not a hack of your wallet. It is an attempt to undo a payment already shown to a merchant or an exchange, and the party at risk is whoever released goods or credit before the transaction was settled. As a buyer you are on the receiving end of the protection, not the attack.

How it works

Every transaction spends specific prior outputs or debits a specific account balance. Nodes reject a second transaction spending the same input, so the only way to double spend is to get the network to accept a competing history.

  1. The attacker pays a merchant and the transaction enters the mempool.
  2. The merchant releases something of value before the transaction is buried in confirmed blocks.
  3. The attacker publishes a conflicting transaction that returns the coins to themselves.
  4. If miners or validators build on the conflicting version, the first transaction never confirms and the payment evaporates.

Step four is the hard part. On a proof of work chain the attacker must out-produce the honest network to replace confirmed blocks, and the Bitcoin white paper models the attacker's success probability as falling rapidly with each additional confirmation. On a proof of stake chain the equivalent is reverting finalized checkpoints, which the protocol makes expensive by slashing the stake of validators who sign conflicting blocks.

Zero-confirmation payments are the genuinely exposed case, and features such as replace by fee make replacing an unconfirmed transaction routine rather than exotic.

Example

Illustrative arithmetic for why waiting works. Say an attacker controls 10% of a network's hash power. To reverse a payment they must catch up from behind, and each confirmation the honest chain adds makes that catch-up markedly less likely. The practical consequence is the rule exchanges actually apply: they credit nothing until a set number of blocks have been built on top, and they publish that number per asset because a fast chain's block is worth less than a slow chain's.

Why it matters when you buy

Deposit crediting times come directly from this, so a transfer that is confirmed on chain can still show as pending on an exchange until its confirmation threshold is met. Confirmation requirements vary by exchange and by asset, and each exchange publishes its own; see the exchange pages and, for the settlement characteristics of a network, the chain pages.

confirmation — the count that closes the window, finality — when reversal becomes impossible, consensus — the rule set preventing conflicts, mempool — where competing transactions wait, replace by fee — how senders legitimately replace transactions, chain reorganization — the event a double spend needs.

Questions

Has a double spend ever succeeded on a major chain?

Reorganizations of one or two blocks have happened on several networks, and smaller proof-of-work chains with low hash rate have suffered deeper attacks. Successfully reversing a deeply confirmed Bitcoin transaction has not occurred.

Why does my exchange need more confirmations for one coin than another?

Because a confirmation means different amounts of security on different networks. A chain producing blocks every few seconds needs many more of them to match the work behind a single slow block.

Can someone double spend coins already in my wallet?

No. Reversing a payment requires control of the coins being spent, so only the sender of a transaction can attempt it, and only before it is confirmed.