provider.once vs just using transactionResponse.wait() #366
valentinfernandez1
started this conversation in
General
Replies: 1 comment
-
Great question! And the answer is... it's not. I just wanted to show you how to listen for events on the UI
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In section 8 - HTML / Javascript Fund Me (Full Stack / Front End) a functions is created called listenForTransactionMine() witch uses provider.once() to wait for the transaction to finish and then it gets returned as a promise.
function listenForTransactionMine(transactionResponse, provider) {
console.log("Mining ${transactionResponse.hash}...");
return new Promise((resolve, reject) => {
provider.once(transactionResponse.hash, (transactionReceipt) => {
console.log( "Completed with ${transactionReceipt.confirmations} confirmations" );
resolve();
});
});
}
Why is it better to use that instead of transactionResponse.wait()??
const transactionReceipt = await transactionResponse.wait(1) console.log(transactionReceipt)
Beta Was this translation helpful? Give feedback.
All reactions