The definition of web3.eth.Contract.transactionconfirmationblocks is here. But I don't quite understand the meaning. The default value is 24, does it mean a transaction will not be confirmed (i.e. the Promise returned by sendTransaction() is resolved) until 24 more blocks are mined after the transaction are mined?
Asked
Active
Viewed 505 times
1
Troublor
- 159
- 2
- 11
1 Answers
0
The transaction is confirmed right away on the node you are connected to. It may be possible that somewhere else, another group of nodes has generated a chain that is different than the node you are connected to. This other chain, when synced with your node, may be considered as the correct chain (likely because it has a higher block number).
So, in order to fully determine if your transaction is correct (meaning: it is considered part of the "true" chain), "we" wait x blocks (24 in your case) to be mined in order to say: "hey, this transaction is valid, and I'm sure at 99.99999%".
If it happens that your transaction is not part of the "true chain", I believe it is in an "uncle block". You can find quite a good definition here
Itération 122442
- 2,052
- 1
- 12
- 33
-
Thanks for your answer. If it turns out my transaction is not part of the canonical chain, what will happen to my transaction? Will it be put back to the transaction pool and included again in future blocks? – Troublor Nov 28 '19 at 11:32
-
@Aaron I do not know. It goes beyond my knowloedge. – Itération 122442 Nov 28 '19 at 12:18
-
@Aaron can you share with the answer to your question? – Vanja Dev Apr 22 '22 at 20:08
-
@VanjaDev When a node receives a new canonical chain and orphans some blocks, transactions in the orphaned blocks will be discarded by this node internally. But those transactions are not necessarily lost. Some other nodes (those that don't know about these orphaned blocks) may still have these transactions in their pool and will later on sync these transactions to this node. Claim: this is based on my own experience and an unsound examination in the source code of Go-Ethereum. – Troublor Apr 24 '22 at 08:43
-
@VanjaDev In general, downstream Apps should not assume the transaction will eventually be confirmed since even if there are no reorgs, transactions can still be discarded. My colleagues and I have done research on this: https://doi.org/10.1145/3468264.3468546 – Troublor Apr 24 '22 at 08:49