-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TX.wait() never resolves even though the transaction has already been completed. #4224
Comments
I noticed a similar issue the context is using ethers v6 in hardhat test where in most case hardhat auto-mining is enabled and where once you get a tx hash you know you can get the receipt straigthaway with ethers v6 unfortunately it seems that the receipt cannot be fetched directly I can workaround by changing this line: ethers.js/src.ts/providers/provider.ts Line 1466 in 1dd5427
to always return if |
I can actually make it work by using |
I change my code to look like this but I still have the same problem.
I also tried it like this
Am I doing something wrong? |
There should definitely not be any case where you have -1 confirmations. And I have to look more into this. Can you include how you create the provider and signer? |
const provider = new ethers.WebSocketProvider("ws://127.0.0.1:8545/"); const wallet = new hre.ethers.Wallet("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"); The Private key is the first wallet created by Hardhat. |
@ricmoo The condition happens when the transaction is committed after the call to If this happens and there is no new block mined after this, then the wait will be stuck forever, as the You can likely reproduce this condition more reliably by adding a sleep for example here to allow the block to be mined with the transaction https://github.com/ethers-io/ethers.js/blob/main/src.ts/providers/provider.ts#L1608 |
can somebody fix this please? |
Ethers Version
6.6.2
Search Terms
No response
Describe the Problem
TX.wait() never resolves even though the transaction has already been completed. I am using ethers.js 6.2 and hardhat to test my code. This is my code.
When I run this code, the hardhat shows the transaction has already been completed. And in the wallet, I can see the swap has happed correctly.
I have already tried increasing gas and tried getting the receipt through the provider like... But I am still unable to get the receipt
let reciept = await provider.waitForTransaction(swapTx.hash, 1)
I don't really know what else to do so any help would be much appreciated.
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), Hardhat
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: