1

As I read, getTransactionCount() returns the number of transactions sent from an address. Which of below items should I consider?

  1. Not to use returned nonce?
  2. Use the returned nonce number as a parameter in sendTransaction() to avoid duplicate transactions?
  3. Use the returned nonce number + 1 to avoid duplicate transactions?
Mohammad Saberi
  • 307
  • 5
  • 17

2 Answers2

1

In order to avoid the problem of double-spending, each transaction is sent with a nonce.

What is a nonce?

A nonce is an integer value that represents the number of transactions that have been performed from an account (ethereum adddress).

Which of the below items should I consider?

  1. Not to use returned nonce?

You should not use this, as some transaction with this nonce has already been submitted to the network.

  1. Use the returned nonce number as a parameter in sendTransaction() to avoid duplicate transactions?

No, the reason is same as that of point 1

  1. Use the returned nonce number + 1 to avoid duplicate transactions?

Yes

balajipachai
  • 937
  • 5
  • 12
  • This is wrong! Nonce start at zero. You have to use the value that getTransactionCount returns. – Ismael Apr 04 '20 at 17:33
0

Use the returned nonce number + 1 to avoid duplicate transactions

Mr_Mo
  • 81
  • 1
  • 8