I wish you send nonce with every transaction so that I can store my nonce in DB and can override a specific transaction if it is pending for a while.

I know I can use eth.getTransactionCount("accountAddress"); to get the number of transactions sent from a specific address and this will be the nonce.

But, the transactionCount only returns the count of mined transactions and not exactly sent transactions.

For e.g., if I send a transaction with nonce 18, and it's not mined yet. And I try to send next transaction from the same account and I calculate transaction count for this address, the transaction count returns 18 (but I should send transaction with nonce 19, right?). So the question is simple:

How can I calculate the nonce for my next transaction keeping the case in mind where there may be pending transactions from the same address?

up vote 1 down vote accepted

Try eth.getTransactionCount("accountAddress", "pending");

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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