[Ethereum] What happens if no nonce is provided for a transaction

noncetransactions

The nonce parameter seems to be optional for transactions. Its goal is to protect from replay attacks. In that case, why is it optional, and what happens if it's not provided? It leaves the particular transaction prone to replay attacks?

Best Answer

If not provided then the nonce will be read from account's state on the blockchain (it is part of the blockchain state).

However, it can sometimes be useful to specify it explicitly. It might be useful, for example, if you need to re-send a transaction with a higher gas price if the first one is not being mined. If you send it again with the same nonce it will (may) over-write the first one.

So, the nonce does appear in all transactions whether you specify it or not, and it does protect against replay.

Related Topic