A nonce ("number used once") is a value that is used only once in a cryptographic context. In blockchain, nonces serve different purposes depending on the context โ mining and transaction ordering.
Mining Nonce
In proof-of-work mining, the nonce is a variable that miners change repeatedly to produce different block hashes. Miners increment or randomize the nonce, hash the block header, and check if the result meets the difficulty target. Finding the right nonce is essentially the "puzzle" that miners solve.
Transaction Nonce
On Ethereum, each account has a transaction nonce that starts at 0 and increments by 1 with each transaction sent. This prevents transaction replay attacks and ensures transactions are processed in the correct order. If you send transactions with nonces 0, 1, and 2, they will be processed in that order even if they arrive at different times.
Why Nonces Matter
The mining nonce is fundamental to proof-of-work security. The transaction nonce prevents double-spending and ensures deterministic transaction ordering, which is essential for smart contract execution.