-
-
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
Contract methods /w Metamask do not resolve Tx object until mined #372
Comments
This is, I think, an issue with MetaMask and a delay between submitting a transaction to the network and making it available for fetching, but it is something that would be nice to properly support. I will investigate and see if introducing a short delay (a fast-check) to the polling helps. It may make sense for there to be a MetaMaskProvider, with the little quirks ironed out too. |
Sometimes it resolves the tx object right away and sometimes it needs to be mined. |
@sudoryan I'm trying to reproduce this now. What percentage of the time are you seeing it not work? |
It's weird, when it works - it works. When it doesn't - it doesn't. Right now I can't get it working I've sent 10+ transactions and they don't return the hash. I tried restarting browser, relogging metamask, clearing cache unable to get it working. |
LOL! I have the opposite problem, I can't get it to fail... |
I had to reinstall Metamask! Sorry about that, thanks @ricmoo. |
Good to know though. I guess MetaMask can just get in a weird state, but now I know to recommend that in the future. Thanks! :) |
Hey @ricmoo , first thanks for a fantastic library! I am getting the same issue above consistently. I have tried re-installing MetaMask and have tested on other machines with other users. Any ideas on what could be causing this? I have not been able to get a transaction to resolve as soon as it is approved within MetaMask, it always resolves after 1 confirmation. |
Hmmm.. This may be new behaviour? What version are you using? Can you include the code you are using? Basically, the way ethers handles this (only for JSON-RPC API based providers), is once a transaction is sent, it gets back a transaction hash, which it then polls using getTransaction, which should return the pending transaction. Some backends do not return a transaction to getTransaction until it is mined, which will cause this issue. If you do not care about the contents of the transaction, you can see this solution for a way to get by faster. In v5 this is exposed by the built-in library for those using a JsonRpcSigner when they just want a fast result, and don't care what was actually sent. |
I have tried v4 via the CDN and I have also tried building from the repo.
I swear this worked a month or so ago, so I am not sure if it is a recent change with MM? |
I could be either a change in MetaMask, or possibly a change in INFURA. I will reach out to them this week if this persists. I'll put together a short sample too. I don't really use MetaMask very often, so I don't see these problems very often. :s |
Awesome, thanks mate. I will try running some older builds of MetaMask and see if I can find out if it was a change on their end. |
@ricmoo I did some digging on this. The transaction hash is getting returned correctly from the This log consistently logs the hash immediately after the transaction is approved within MetaMask. Should Currently it is returning the result of a call to |
@ricmoo I have a possibly naive solution (I am not super familiar with Typescript) for this that is working for me nicely. It is just a small change to the
|
I think you are trying to implement the UncheckedJsonRpcSigner? If so, here is the full implementation from v5: It cannot be put into the normal JsonRpcSigner though, since non-MetaMask JSON-RPC backends work fine with the normal JsonRpcSigner... |
Yes that would work nicely. Although the problem is that I am trying to find a solution that will be merged in to ethers.js in a future release so that a library I am working on can support ethers.js . Our library requires the |
Yes, it is already supported in v5 beta. :) There are 2 ways to get an UncheckedJsonRpcSigner. If you have a JsonRpcSigner already, then Of course, Keep in mind the Web3Provider is just the JsonRpcProvider extended to override |
Just wanted to jump in and say that this same issue (with MM + ethers) also hit me recently, and I'm 95% sure that nothing changed on my end, so I guess it's likely to be a MM/Infura issue. Going to look into the unchecked signer stuff. |
@ricmoo Thanks I will see if I can the unchecked signer working 👍 |
@ricmoo Do you have a rough estimate of when you are planning on releasing v5? |
The public beta is available now. Basically once I stop getting complaints and bug reports, it will get promoted from I’ll be making a less-soft, more public announcement for it soon, so I expect more bug reports to flow in after that. :) |
Awesome thanks mate! 👌 |
Adding my 2 cents. I'm having the same problem, where Seems like we now should expect that behavior for both UPD: can't UPD 2: This seems relevant. |
Hi everyone! We have now the same problem! |
Please help out by following this issue instead. :) |
Hi ricmoo, 4.0.31 is still not workin |
According to the docs, contract methods sends are supposed to resolve to a tx object when the transaction is sent. This isn't the case when using Metamask web3 provider where the contract method only resolves once mined.
The text was updated successfully, but these errors were encountered: