-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
How does MyCrypto calculate the correct transaction nonce? #2221
Comments
We don't actually. You can refresh the nonce, which pulls straight from the node you are connected to and may or may not take into account pending txs, depending on the node you are pulling from (e.g. geth vs parity) We've discussed manually incrementing the nonce on the client side but it hasn't been implemented and I'm not sure if we ever will as (at least for now) less risky to have a user have a transaction dropped from the pool than accidentally send 2 of the same transaction unintentionally. |
Thanks @tayvano . So this means that a transaction can be dropped if I post it using MetaMask for instance, then switch to MyCrypto and post another transaction while the previous one is still pending? |
In theory, yes, if you do so very quickly and from different nodes. If there is another transaction pending, you will receive an error message. Basically you would have to broadcast the second transaction before the first transaction enters the txpool of the node you are using. With the network being pretty stable these days (unlike cryptokitties days), you would have to be awfully quick about it. |
Actually the reason I am saying it will be dropped is because both transactions will have the same nonce. Consider the following: a. My wallet has If the new MyCrypto transaction has a higher gas price, it should replace the MetaMask one, no? |
Sorry, yes you are correct. It wouldn't show an error and you could inadvertently send a second tx to the queue that replaces the first transaction if the gas priced used for the second transaction is |
Do you think it would be better a different way? Any proposals? |
I actually have this exact problem in an app of mine. Ideally I was considering searching the TX pool myself for pending transactions involving my wallet's address, but I couldn't find enough documentation on that anywhere. I guessed you guys might doing that, which is why I asked here 🙂 I'll definitely update you here if I am able to figure this out. ps: I also asked MetaMask how they did it, but it turns out that they only keep track of the transactions you post using MetaMask itself. |
So back.when we were still MEW we had huge issues losing transactions, especially during cryptokitties times and threw together this not perfect but effective script. It no longer applies really since there are so many node providers via MyCrypto but a similar thing could be used for your app if you are only using one node. You could use this to create a simple db that You could easily and scalably read from to get the correct nonce |
Awesome, will check it out! Thank you so much 🙏🙏 |
How does MyCrypto calculate the correct transaction nonce when multiple transactions are being issued?
It's well known that eth_getTransactionCount does not return the correct number of pending transactions, so I was wondering how you guys do it. Could be really beneficial for the community to learn from.
The text was updated successfully, but these errors were encountered: