Are they not Same ??? #2525
-
In lesson 8 why did we create a whole function to listen for the transaction mined ?? I mean Can we not just type try {
const transactionResponse = await contract.Fund({
value: ethers.utils.parseEther(ethAmount),
});
// await listenForTransactionMined(transactionResponse, provider);
const transactionReceipt = await transactionResponse.wait(1);
console.log(transactionResponse.hash);
console.log(transactionReceipt.confirmations);
console.log("Done!");
} catch (error) {
console.log(error);
} We are getting the transaction hash as well and transactionReceipt confirmations. Im getting the same output when I run with listner function(The following image is the with Listner function enabled) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You certainly can omit the try-catch, but it is important to note that we do so as it adds an extra layer of precaution--and also makes it easier to debug in a large codebase--to catch any errors whatsoever in evaluating the statements inside the try block. Thus, the reasons above are what makes the former different from the one you specified; the functionality is identical. |
Beta Was this translation helpful? Give feedback.
You certainly can omit the try-catch, but it is important to note that we do so as it adds an extra layer of precaution--and also makes it easier to debug in a large codebase--to catch any errors whatsoever in evaluating the statements inside the try block.
Thus, the reasons above are what makes the former different from the one you specified; the functionality is identical.