I'm building a game on ethereum and one thing that really makes my life hard is understanding the removed mined transaction flow. what happens to other transactions that counted on that transaction, for example, let's say some 1 sent me 1 ether, and then I use this ether to send it to someone else. after 5 confirmations the first transaction got removed, what happened to the 2nd transaction that used that ether?
-
What do you mean by "remove transaction" ? I don't think you can remove a confirmed transaction, after it's mined and present in a block. The only situation where this can occur is when the whole block is somehow removed (I think we are talking of a split chain event in this scenario, so quite a big event due to some critical circumstances like a network attack)– StormssonCommented Aug 31, 2021 at 15:20
-
@Stormsson I read that it is safer to wait for 12 confirmations to make sure the transaction doesn't get removed. I also see in web3 that you can get removed in the events subscription– Amit WagnerCommented Aug 31, 2021 at 16:22
-
12 seems a bit much to me; for my knowledge it is usually 6 for the most "secure" applications.– StormssonCommented Aug 31, 2021 at 17:56
2 Answers
The issue you raise is the problem of finality in blockchain consensus. While highly unlikely, it is possible for a transaction to be dropped even after 5 confirmations. This would only happen if there is a temporary fork in the blockchain and the chain with your transaction gets dropped in favour of an alternate, "longer" chain. If that happens then any other transaction that relied on your first transaction will not exist because it could have never been part of the alternate chain that replaced the chain with your transaction.
Because of this risk, exchanges and services typically require 12 or more confirmations before they consider your transaction finalised (statistical finality) since at this point is extremely unlikely that the current chain will get replaced by another chain not containing your transaction.
-
Unfortunately there isn't a strong dependency between transactions in Ethereum. For example A sends 1 ether to B, and B forwards 1 ether to C, if the first transaction is removed the second might work if B has enough funds.– Ismael ♦Commented Sep 2, 2021 at 4:00
-
I don't think this would be possible since every transaction requires a nonce that +1 higher than your address's previous transaction. If try to you submit transaction with nonce 10, another transaction with nonce 11 and somehow your first transaction gets dropped, then your nonce 11 transaction would not be executed as nodes will be expecting your nonce 10 transaction that no longer exist. Commented Sep 2, 2021 at 9:11
-
Nonce is per account so A's nonce doesn't affect B's nonce.– Ismael ♦Commented Sep 2, 2021 at 14:14
A transaction cannot be removed from the blockchain: once it is saved in a block it is there forever(*).
A transaction could be rejected, should this happen it will not be present in a block.
(*) A whole block could be rejected AFTER the first confirmations , but this is a sort of catastrophic event that means a lot of bad things happened; ALL the following blocks are considered invalid
The more confirmations a block has, the lower the probability is that it is "unconfirmed" (each node from the network validates the block, so if a part of the network says that the block is valid and a part doesnt... well, it's bad).
In BTC most commercial applications consider a block valid just after 1 validation, but 6 is the common number I read online to be safe (I believe this number is justified by statistical analysis, but I cannot provide a source).
edit: in ETH 12 confirmations is a common amount considered safe.