How to get the new nonce of from address using web3? There shouldn't be any transaction associated with this. Is there any way to get this.
1 Answer
You can get the transaction count (nonce) of any address using web3.eth.getTransactionCount('address')
as explained in web3 documentation
Hope this helps
-
But this method won't give the correct transaction count, there may be possible that some transactions are already initiated but not gets complete. So, in this case, the count values would not be updated.– ShubhamCommented Jun 6, 2018 at 11:53
-
I do not understand what are you expecting to get, the function will give you the transaction count of the address at the current block. Other than that will be to predict the future.– JaimeCommented Jun 6, 2018 at 11:57
-
1@Shubham Most functions in web3 accept an extra argument with the target block. You can use 'pending' like this
web3.eth.getTransactionCount(address, 'pending')
it will return the count including those pending transactions.– Ismael ♦Commented Jun 6, 2018 at 15:33