2

When I was trying to send multiple transactions, I received an error saying that "replacement transaction underpriced".

Searched around and it says that I was trying to replace an existing transaction, so I need to pay a higher price. But that was not my intention.

Searched further and it says that I need to increase the nonce or use a different nounce.

The question now is, can I use a random number? (just assume this random number will not repeat in the next one day)

3

I think you mean "nonce".

The nonce for a transaction must match the account. The first transaction from an account has nonce 0, the second has nonce 1, etc. You can't just choose a random number, because the transaction will not be mined unless it hast he correct nonce.

  • Thanks for the info and corrected my mistakes. I found it in another article. It says that I might need to track the nonce myself. Is that mean the nonce getting from the chain might not be accurate? – s k Aug 28 '18 at 1:20
  • 1
    Getting the nonce from the blockchain is accurate, but it doesn't take into account transactions that haven't yet made it into a block. For example, if you check the number of transactions sent by your account and it's 5, your next nonce should be 5. But if milliseconds after you broadcast a transaction with nonce 5 you check the transaction count again, it will still be 5. (The new transaction hasn't been mined yet.) But if you sent out another transaction with the nonce 5, one or the other transaction would fail. – user19510 Aug 28 '18 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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