I am a developer building an application that accepts payments in cryptocurrencies.

Is it possible, in the occurence of a 51% attack, to build a script that detect this, so we can suspend withdrawals automatically?


1 Answer 1


Generally, no, not until it's too late.

A typical 51% attack would look like this:

  1. Attacker privately starts mining their own chain, which diverges from the main chain at some block N.

  2. Attacker deposits coins to your business, sending them from address A. Call this transaction X.

  3. Attacker inserts in his own chain a transaction X' which conflicts with X; typically X' sends the coins from address A to another address belonging to the attacker.

  4. Attacker waits for several confirmations of transaction X, in blocks N+1, ..., N+6 (replace 6 with however many confirmations your business wants) of the main chain.

  5. Once there have been enough confirmations to satisfy you, you deliver goods or services to attacker.

  6. Attacker releases his own chain, which now has blocks up to, say, N+50. Being longer, this chain is accepted by the network. This chain doesn't contain the transaction X but instead X', so you don't have the coins you thought you did.

Notice that up until Step 6, everything on the network looks completely normal; only the attacker knows what is going on.

  • After step 6, would everybody know the IP address of the attacker? Mar 26, 2015 at 8:34
  • @AlexMillar Yes, unless he used a VPN.
    – Nick ODell
    Jun 10, 2015 at 3:01
  • 1
    @NickODell: I don't think everyone would know, with or without a VPN. The attacker will expose his address (or that of his VPN, or Tor exit node) to all the other nodes to whom he sends his chain, but he could plausibly claim that he received it from someone else and was only relaying it. Likewise, an innocent node who relays the blocks can't necessarily prove that they are not the attacker who generated those blocks. Jun 10, 2015 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.