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
Await on Transaction Submission Waits for Confirmation #4722
Comments
That is how Can you provide an example where you do not believe this is happening? |
I understand that
Observed Behavior:
|
What network are you on? Since ethers needs to lookup the tx from the mempool, this can happen on networks (or backends) which do not return transactions in the mempool. |
I've tested this on BNB Smart Chain and locally with Hardhat. Everything was working fine up until about a week ago, and I haven't made any changes to the relevant parts of my codebase since then. I suspect this may be an issue with Metamask, but I thought it would be good to ask here as well. |
Did you figure this out? I've now just noticed the same same thing on BNB & Arbitrum. |
Started to get the same issue after MetaMask browser extension was updated on chrome. Using ETH Sepolia network. Using Firefox with older MetaMask version works correctly (same as before promise is resolved when tx was submitted and not on tx confirmation). |
Can confirm that I have the same issues with Metamask since one of their last updates. Calling One workaround is to use export class UncheckedJsonRpcSigner extends JsonRpcSigner {
async sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse> {
return this.sendUncheckedTransaction(transaction).then((hash) => {
return <TransactionResponse>(<unknown>{
hash,
nonce: null,
gasLimit: null,
gasPrice: null,
data: null,
value: null,
chainId: null,
confirmations: 0,
from: null,
wait: (confirmations?: number) => {
return this.provider.waitForTransaction(hash, confirmations)
},
})
})
}
}
// How to use it:
const uncheckedJsonRpcSigner = new UncheckedJsonRpcSigner(signer.provider, await signer.getAddress())
const result = await uncheckedJsonRpcSigner.sendTransaction(...)
// will resolve immediately |
Just chiming in to say this is happening to me as well. Using ethers Code looks like
My app is sorta breaking cause it's expecting to get the txHash back immediately and redirect to an intermediate page while the transaction is waiting to be confirmed (it contains the |
Same problem |
I've contacted MetaMask to find out more about any recent changes. :) |
Ethers Version
6.11.1
Search Terms
transaction submission, await, transaction confirmation, tx.wait, transaction hash
Describe the Problem
Expected Behavior:
Using
await
on a transaction method (contract.function
) should resolve as soon as the transaction is sent to the network and a transaction hash is received, allowing subsequent code to run immediately after the transaction submission.Actual Behavior:
Instead,
await
oncontract.function
only resolves after the transaction has been confirmed. This behavior is identical to what happens when usingtx.wait()
, which should only occur at the transaction confirmation stage. Removingtx.wait()
from the workflow has no effect, as the initialawait
on the transaction already waits for confirmation, causing significant delays in UI updates that depend on the transaction submission.Code Snippet
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), Browser (Chrome, Safari, etc), Hardhat
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: