20

Transactions (using a smart contract like a token or sending ether), by design, are immutable on the blockchain. What methods can be used to (more or less) unilaterally reverse a transaction made by myself or someone else? Situations where one might like to reverse a transaction:

  • Sent a transaction to the wrong account/wrong contract/wrong address.
  • Sent a transaction with the wrong amount of ether.
  • Buyer's remorse (e.g., transaction recipient was a scammer).
  • Recipient is not acknowledging transaction or is holding on to tokens/ether sent as part of the transaction (such as an exchange might).
  • Contract has a bug.
  • Compromised account (e.g., How to reduce the chances of your Ethereum wallet getting hacked?)
  • Transaction is "stuck" due to low gas and no longer worth performing.
  • Contract called with wrong arguments.
5
  • 4
    The question is phrased in a weird way that gives the impression that you already know what answer you're expecting (a.k.a. a rhetorical question). As it turns out, you're answering to it yourself. I get the idea that it doesn't matter who asks and who answers as long as the question and the answer are useful, but in this very case the question is not, which makes the answer not really useful either. I have an uncomfortable feeling that you're stretching the Q&A format maybe a bit too much here. Commented Sep 6, 2017 at 1:31
  • 2
    I always phrase my questions in a weird way :) But more seriously, I normally include a bit of context in all of my questions to show how much/little work I've done to answer my own question so that someone answering the question has an idea of what level to aim the answer at. Self-answering policy for stack exchange is here: stackoverflow.com/help/self-answer . As for the question not being useful, something like this pops up once or twice a week, but indirectly or as part of another question. Also, I set my answer as a wiki so that anyone can contribute. I get no rep!
    – lungj
    Commented Sep 6, 2017 at 2:00
  • Thanks for responding. It is perfectly clear that your motive is not gaining rep. About the "not useful" part, I meant that questions that are hard to understand because of the phrasing become less usefull. I didn't mean that the original problem is irrelevant. Commented Sep 6, 2017 at 2:18
  • Thanks for the constructive feedback! I tried to phrase the question to avoid any reference to tokens or ether specifically to make it as all-encompassing as possible, but I agree it could use some work to make it more likely to pop up as a search result (rather than just being linked to every time someone asks the question in a different way). I will attempt to make some changes.
    – lungj
    Commented Sep 6, 2017 at 2:20

1 Answer 1

17

Send the inverse transaction

If there exists an inverse to the transaction (e.g. Send 3 DAO tokens from account A to account B has the inverse of sending 3 tokens from B to A), one can execute the inverse transaction. Note that a contract may implement something or an account holder may do something that is not reversible (e.g., it may burn tokens). Also note that this results in two transactions (the original plus the inverse) which both are recorded permanently in the blockchain. This also means that the transaction fees are incurred for both transactions.

Use (directly or indirectly) the private key of the recipient account

If (and only if) Ethereum is not broken, the private key of the recipient is required to send a reversing transaction from an account. TODO: please add something about sending stuff as a contract (i.e., is there a private key, even if no one knows it, associated with contracts?). In situations where you do not have the private key (such as if you send ether to an exchange and you don't receive an appropriate account balance adjustment), then you must ask the recipient to perform the reversing transaction (and hope they have the private key). If the recipient is a company, you should contact their support staff. Stack exchange members (unless they happen to work at the company in question) cannot help you.

Race to replace the transaction

If the transaction has not yet been confirmed in the blockchain and is only in the transaction pool, you can replace the transaction. This is as close as you can get to cancelling a transaction. Note that this still results in a transaction occurring (and gas being paid for).

Repost transaction

One way of replacing an unconfirmed transaction is to repost a replacement transaction with the same nonce but a higher gas price; a possible replacement transaction is to post a 0-value balance transfer with yourself as the recipient. It might be a bad idea to set a very low gas limit in case such a transaction is filtered out by a miner. This method can only be used to replace a transaction you have sent. This method works to replace any kind of transaction -- including ones for interacting with contracts such as tokens.

Create a winning fork

Since the current state of the blockchain is based on the history of the blockchain, one way of reversing a transaction is to rewrite the blockchain history starting from at least the block containing the transaction to be reversed. Forking the blockchain intentionally like this may have negative consequences for the overall Ethereum network.

51% attack (Proof-of-work)

The accepted current state of the blockchain is the longest chain. One could build a longer chain than the current chain. One way of doing this is to append blocks to the chain faster than people mining the chain containing the transaction to be reversed (the "honest" network). In order to do this (with reasonable statistical success), you need to have more hash power than the honest network. If r is the hash rate of the honest miners, your hash rate is r + x, and t is the amount of time expected for the network to have taken to make the number of confirmations on the block with the transaction to be reversed (or, as a first approximation, the amount of time since the block containing the transaction to be reversed was mined), then the expected time to reverse the transaction is rt/x, so if you have 51% of the network and you want to reverse the most recent 120 blocks with an expected block time of 30 seconds (=1 hour of mining), it would take you just over a day to reverse the transaction (49 * 1 hour / 2). Possessing (or having access to) this kind of hashing power might shake confidence in transactions on the network.

Software fork

If you can convince people securing the network (currently, this is miners) to change their mining software, you can change the rules of the network so that the transaction is reversed. Forking the network in this manner may be contentious.

Use the legal system

If you performed a transaction with someone and are unhappy with the outcome, you can try using the legal system. The legal system may compel the offending party to make good; some countries also can crack the private keys for an Ethereum account. There is nothing in Ethereum itself that allows breaking the rules of Ethereum (obviously?). The closest you can get is to make an amendment to the rules of Ethereum or a one time pardon. This is accomplished via forking (see above).

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