Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is tx.wait(1) required?

I'm new to programming and currently following a brownie tutorial. While interacting with smart contracts, my tutor puts a tx.wait(1) after every transaction that requires a state change of the contract. I'm guessing tx.wait(1) means that we tell brownie to wait for at least one confirmation of the transaction before proceeding further. But

  1. tx.wait(1) is not required after deploying a contract. Why don't we wait for a confirmation after deployment?
  2. my tutor skips tx.wait(1) during testing. why does it still work?

It is clear that I don't fully understand what tx.wait(1) actually does. Can someone please explain it to me? Or atleast point me towards some documentation about it? I'd really appreciate the help. TIA.

like image 992
Navraj Sharma Avatar asked Oct 20 '25 02:10

Navraj Sharma


1 Answers

number of confirmations are required to finalize a transaction with high probability. Confirmations serve as an additional mechanism to ensure that there is probabilistically a very low chance for a transaction to be reverted, but otherwise, once a mined block is finalized and announced, the transactions within that block are final at that point. Bitcoin has 6 block confirmations. The key idea behind waiting for six confirmations is that the probability of double spending is virtually eliminated after six confirmations.

like image 188
Yilmaz Avatar answered Oct 21 '25 15:10

Yilmaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!