Suppose gas prices spike or something and now your transaction is stuck "in the ether" (~>30 minutes confirmations). Is it possible to have a third parameter in the waitForTransaction(hash, confirmations, timeout)? Currently just wrapping waitForTransaction in a promise that rejects after n seconds.
Also I think the parameters names might be a little off? Could be wrong. For instance in abstract provider, the signature is transactionHash, timeout?, but in BaseProvider it is transactionHash, confirmations?
You re absolutely correct, that parameter is misnamed (in v3 it was timeout, but I changed to a confirmation count in v4) and in the code there is an @TODO to put a timeout back in.
That is something I will put back into v5 (public beta coming soon). In the meantime, removing the event listeners will cancel the wait, but there should certainly be an easier way to do that.
Hi @ricmoo - what is the current recommended way in v4 to set and manage timeouts when waiting for transactions to be mined?
I would like to wait 3 minutes for my transaction to be mined, and if it times out, I would like to resubmit the same tx using the same nonce with a much higher gas price.
Promise wrapping and setTimeout come to mind, but wondering whether you have a built in way that you can recommend?
@gitpusha Yes, that is probably the best way to handle it in v4, using a separate timer. This is however, not ideal, since the internal polling loop will continue.
I'll add this to v5 right now, but I probably won't make any changes to the API in v4...
I've added support in v5, if anyone would like to try it out. :)
This has been added to v5. If you have any problems, please feel free to re-open this ticket.
Thanks! :)
@ricmoo cool will try it out !