Once Pelagus has broadcasted tx, initiate provider.waitForTransaction() and wait for it to be mined.
provider.waitForTransaction() should return a promise that resolves to the transaction receipt when it is mined (or if it has already been mined immediately resolve)
When doing this, provider.waitForTransaction is called/used prior to the transaction being mined. Tested about 20 different transactions, each time, the promise hung infinitely and never resolved to the transaction receipt. Verified each time that the function was called prior to the transaction being mined and that the transaction was indeed mined into a block.
The function is intended to act the exact same as provider.getTransactionReceipt if the transaction has been mined. I ran a separate script to test this method with a transaction that had already been mined which correctly returned the transaction receipt.
Also did a test that delayed the running of provider.waitForTransaction() for 3 seconds after the transaction had been broadcasted. This immediately solved my issue and correctly returned the transaction receipt.
These results seems to imply that something with the waiting for transaction to be mined logic is not functioning correctly and resulting in an hanging unresolved promise when the function is called prior to transaction confirmation.
Ethers Version
0.1.14
Search Terms
waitForTransaction, JsonRpcProvider
Describe the Problem
I have the flow:
provider.waitForTransaction()
should return a promise that resolves to the transaction receipt when it is mined (or if it has already been mined immediately resolve)When doing this, provider.waitForTransaction is called/used prior to the transaction being mined. Tested about 20 different transactions, each time, the promise hung infinitely and never resolved to the transaction receipt. Verified each time that the function was called prior to the transaction being mined and that the transaction was indeed mined into a block.
The function is intended to act the exact same as
provider.getTransactionReceipt
if the transaction has been mined. I ran a separate script to test this method with a transaction that had already been mined which correctly returned the transaction receipt.Also did a test that delayed the running of
provider.waitForTransaction()
for 3 seconds after the transaction had been broadcasted. This immediately solved my issue and correctly returned the transaction receipt.These results seems to imply that something with the waiting for transaction to be mined logic is not functioning correctly and resulting in an hanging unresolved promise when the function is called prior to transaction confirmation.
Code Snippet
Contract ABI
No response
Errors
Environment
node.js (v12 or newer)
Environment (Other)
Running a local go-quai instance, using quai-hardhat, Next.js frontend