Skip to content
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 MetaMask calculate the correct transaction nonce? #5476

Closed
tarekskr opened this issue Oct 10, 2018 · 4 comments
Closed

How does MetaMask calculate the correct transaction nonce? #5476

tarekskr opened this issue Oct 10, 2018 · 4 comments

Comments

@tarekskr
Copy link

How does MetaMask 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.

@frankiebee
Copy link
Contributor

frankiebee commented Oct 10, 2018

Put simply: we take the "highest" known confirmed nonce and add the pending transaction count from your local tx history (the transactions you've sent from within metamask). Given that sometimes infura may not know the most update nonce (asking a node a block behind etc.) We do to calculations for confirmed nonces: Derived from local confirmed and eth_getTransactionCount and choose the highest of the two.

you can reference all this code here: nonce-tracker

@tarekskr
Copy link
Author

Excellent, thank you so much for the link @frankiebee !

@kaibakker
Copy link

kaibakker commented Oct 13, 2018

Is it possible to suggest a nonce to the metamask extension to be able to cancel a pending transaction or update the gas price?

@bdresser
Copy link
Contributor

@kaibakker we support speeding up tx already, check out #4022 re: cancelling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants