Suppose there is a user A which transfers some ethers to user B through a proper transaction.
So is it possible to alter the transaction. Something like going back to the block which contains the transaction and creating another chain with a new transaction in which ethers are not sent to User B. So, will the second transaction override the first one.

In short, I want to know what will happen to both of the transaction and how the blockchain will discard one and will keep the other?


It is possible to rewrite blockchain history and replace a transaction by another one. To do so you have to replace already mined blocks by new ones and this new "fork" has to have a larger proof of work.

Your need to have more computation power than the honest miners. This attack is called a 51% attack.

  • Ok I understand that I need to have more computation power than the honest miners. But what if I don't have this much power. So will the second transaction be considered successful? And also how to know if a transaction is on the main chain or on a fork one?
    – krritik
    Sep 19 '20 at 13:52
  • 1
    Unless you bribe miners with something else most of them will follow the fork with more proof of work and ignore others. To validate a transaction you start walking down the chain from the most block with largest proof of work, and examine each block for transactions.
    – Ismael
    Sep 19 '20 at 15:16
  • Ok I got it. So the second transaction is still there in blockchain in a fork which is different from chain with most block. Also, isn't it time consuming to walk down the chain checking each block because if the transaction is not in the chain with most block, we will examine the whole blockchain till the first block.
    – krritik
    Sep 19 '20 at 16:43
  • Clients like geth optimize for common operations, for example indexing transactions and blocks.
    – Ismael
    Sep 19 '20 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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