I am testing a smart contract that requires a nonce for every single method I invoke. My idea was to use the Metasmask transaction nonce of the connected account, but I do not know how to extract the nonce of the next transaction from javascript... is there a built-in api method I can call that returns it?

1 Answer 1


A nonce is just a number of previous transactions you made with your account. Every new transaction requires nonce to prevent double-spending attacks. You can read more about it here.

There is a function in web3 API for retrieving nonce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.