Web3.js docs state that a confirmation event will be fired:
- 12 times when calling
web3.eth.sendTransaction
(see here) - 24 times when calling
myContract.methods.myMethod.send
(see here)
Why is the difference in the number of times that the event is fired in each case?
More importantly, what exactly should I use these events for?
At present, I simply await
for the function to complete, and then use the returned value, which is a resolved Promise
containing the transaction receipt (unless we're dealing with a contract deployment, in which case it will contain the new contract's instance).
To my understanding, this receipt can also be obtained using:
myContract.methods.myMethod().send().on('receipt', function(receipt){...});
I assume that this additional way of obtaining the receipt is for when you also want to handle other things, such as those confirmation events, which from what I've observed, do not necessarily occur before the receipt is available.
Do I need to count up 12 (or 24) events in order to be sure that the information receipt reflects the block-chain?
Thank you!