Lesson 6: Hardhat Simple Storage #4966
-
Hi everyone, I got a doubt about the following word:
What is wait means? Why we need to wait? Please explain me in detail. Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module. |
Beta Was this translation helpful? Give feedback.
-
I will do my best to explain it to you in plain English - wait() lets you mint a block that will record the transaction you are calling before calling a wait() function. for example, await simpleStorage.deployTransaction.wait(6) - in the case, you will wait for 6 blocks to be mined before carrying on the rest of the code. This allows you to proceed when a certain tx is complete. I hope that makes sense!! |
Beta Was this translation helpful? Give feedback.
I will do my best to explain it to you in plain English - wait() lets you mint a block that will record the transaction you are calling before calling a wait() function. for example, await simpleStorage.deployTransaction.wait(6) - in the case, you will wait for 6 blocks to be mined before carrying on the rest of the code. This allows you to proceed when a certain tx is complete.
I hope that makes sense!!