Skip to content

contract.on() to fire after a number of confirmations. How to do it? #1369

Answered by ricmoo
mudgen asked this question in Q&A
Discussion options

You must be logged in to vote

Specifying the number of confirmations to the EventEmitter API isn't possible, but I think you should be able to do:

// Depending on the number of arguments you have...
contract.on(filter, async (arg0, arg1, event) => {
  const receipt = await event.getTransactionReceipt();
  await contract.provider.waitForTransaction(receipt.transactionHash, 20);
  do_stuff_here();
});

In v6, it would make sense for me to add a .wait to the event object... I'll add it to my list. :)

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@xtrinch
Comment options

@ricmoo
Comment options

Answer selected by ricmoo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1340 on March 15, 2021 23:53.