Comments (11)
Started to get the same issue after MetaMask browser extension was updated on chrome. Using ETH Sepolia network.
MetaMask Version
11.14.5
Using Firefox with older MetaMask version works correctly (same as before promise is resolved when tx was submitted and not on tx confirmation).
MetaMask Version
11.12.4
from ethers.js.
Can confirm that I have the same issues with Metamask since one of their last updates. Calling signer.sendTransaction
or contract.connect(signer).<any method>
gets stuck until the transaction is executed.
One workaround is to use sendUncheckedTransaction
. I think it doesn't officially exist in v6 anymore but we copied it from v5:
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
from ethers.js.
Just chiming in to say this is happening to me as well. Using ethers 6.10.0
and MetaMask on Sepolia or my local node
Code looks like
const tx = await contract.function(<function args>)
const txHash = tx.hash
...
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 await tx.wait()
). Now it skips the intermediate page.
from ethers.js.
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.
from ethers.js.
Same problem
from ethers.js.
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.
from ethers.js.
I've contacted MetaMask to find out more about any recent changes. :)
from ethers.js.
That is how tx = await contract.func()
works; returning once the transaction is in the mempool. Calling await tx.wait()
will then wait for it to be mined, resolving to the receipt. But the initial call certainly doesn't wait for the tx to be mined.
Can you provide an example where you do not believe this is happening?
from ethers.js.
I understand that await contract.func()
is expected to resolve as soon as the transaction reaches the mempool, with await tx.wait()
then waiting for the transaction's confirmation. However, I am experiencing behavior that suggests the initial await
on the transaction function is waiting until the transaction is confirmed before resolving.
- Environment: I am running this within a React application, interacting with the network via MetaMask and ethers.
- Code Snippet:
const amountToApprove = ethers.parseEther(tokenAmount); console.log("Approving Tokens"); const approve = await paymentTokenContract.approve(tokenSaleAddress, amountToApprove); console.log("Tokens Approved, Awaiting Confirmation"); await approve.wait(); console.log("Approval Confirmed, Initiating Purchase"); const tx = await tokenSaleContract.buyTokens(paymentTokenAddress, amountToApprove); console.log("Purchase Transaction Submitted, Awaiting Confirmation"); await tx.wait(); console.log("Purchase Confirmed");
Observed Behavior:
- The logs "Tokens Approved, Awaiting Confirmation" and "Purchase Transaction Submitted, Awaiting Confirmation" are expected to print immediately after the respective transactions (
approve
andbuyTokens
) are sent to the network. - However, these logs only appear after each transaction has been confirmed on the blockchain. This indicates that the
await
on bothapprove
andbuyTokens
does not resolve upon submission to the mempool but rather waits until the transaction is confirmed.
from ethers.js.
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.
from ethers.js.
Hello guys. If anyone have same issue with contract.METHOD() and tx.wait
- @gmxer nice solution!
- https://github.com/gmx-io/gmx-interface/blob/8e0eb420aa71e63720ba78f17f0117c1ce555810/src/lib/rpc/UncheckedJsonRpcSigner.ts
from ethers.js.
Related Issues (20)
- Computing L1 + L2 fees on Base and Manta HOT 4
- JsonRpcProvider: `pollingInterval` option overriden by constructor HOT 1
- WebSocket re-connect HOT 1
- Missing r argument after submit transaction in metamask HOT 2
- deployTransaction property is undefined after contract deployment HOT 1
- estimateGas does not support eip-4844. HOT 4
- Tuple return values from contract calls cannot be used as parameters in subsequent calls. HOT 1
- ProviderError: the method has been deprecated: eth_accounts
- mnemonic.computeSeed is not a function (hdwallet.js:318:48) HOT 3
- Error: invalid value for value.data HOT 1
- Unsigned ethers v6 type 2 transaction HOT 4
- Incorrect EIP712 hashed data with array type
- unknown fragment HOT 1
- Expose encodeFunctionData and decodeFunctionResult as properties on the contract method HOT 1
- Property 'utils' does not exist on type 'typeof
- After the network is switched, the latest provider cannot be obtained HOT 2
- returns code BAD_DATA instead of INSUFFICIENT_FUNDS HOT 1
- Should return code TIMEOUT instead of UNKNOWN_ERROR HOT 1
- 'contract runner does not support calling' error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethers.js.