Why we have to wait one block? #3716
-
Why we have to wait for one block for the transaction to happen? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
@Dashingbanda @Dashingbanda if you have no idea on how longest chain rule works may be this youtube video will be helpful to you |
Beta Was this translation helpful? Give feedback.
-
@Dashingbanda : In this line It's totally upto you, If you wanna wait or not! But its a good practice to wait for couple of blocks on transactions, Because number of confirmations are required to finalize a transaction with high probability, and to ensure that there is probabilistically a very low chance for a transaction to be reverted! |
Beta Was this translation helpful? Give feedback.
-
Blocks contain transactions. Blocks containing these transactions are mined by miners. What However, waiting one block is only sufficient for networks where the volume is not significant at all (e.g. a testing environment on your computer, where volume is negligible). This is why we wait for one block here. You would have noticed that we wait 6 blocks instead for testnets (such as Goerli); why? this is so because they have lots of transactions which are mined. Therefore, it follows that one block is not sufficient for your transaction to be included in the mined block. 6 blocks specifically guarantees the fact that our transaction will be included in the blockchain (i.e. the block containing our transaction is mined and included in the blockchain). Note: 6 blocks is so due to simple probability. Whilst blockchain forks and the longest chain rule (there are other rules specific to networks because they incorporate their own solutions) will be advanced for you currently, just think that 6 blocks basically guarantees of any failure of not being included in the blockchain. Additionally, if you dig deeper there is still a negligible chance of 6 blocks not being sufficient, and long-range attacks on networks not including checkpoints (or any similar concepts they incorporate to avoid the problem). Additionally, please feel free to ask questions regarding this; as I have omitted some blockchain-specific "concepts" for the ease in comprehension. |
Beta Was this translation helpful? Give feedback.
@Dashingbanda
Blocks contain transactions. Blocks containing these transactions are mined by miners. What
.wait()
here does is that it waits for the block to be mined. A blockchain is a "tree" of blocks, essentially transactions.However, waiting one block is only sufficient for networks where the volume is not significant at all (e.g. a testing environment on your computer, where volume is negligible). This is why we wait for one block here.
You would have noticed that we wait 6 blocks instead for testnets (such as Goerli); why? this is so because they have lots of transactions which are mined. Therefore, it follows that one block is not sufficient for your transaction to be included in …