Loading prices...

Nonce

TechnologyUpdated 09.10.20263 min

A number used once. In Proof-of-Work mining it is the field a miner changes over and over until the block hash falls below the target, and finding it is the work the network pays for. In Ethereum the same word means something else: a counter on an account that stops a transaction being replayed.

How it works

A nonce is a number picked so that the result of a computation satisfies a given condition. The word comes from “number used once”.

In mining it is the only part of a block a miner may freely change. They insert a number, compute the block's hash and check whether the result came out below a target value. If not, they add one and compute again.

This brute-force search is the work in proof of work. A valid number can only be found by blind search, while verifying someone else's find takes a single operation. The network's entire security rests on that asymmetry.

The scale of the search

Bitcoin's nonce field is 32 bits wide. Here is how far that goes on modern hardware.

Total values in the fieldabout 4.3 billion
Speed of one machineup to 200 trillion hashes per second
Time to exhaust the fielda fraction of a second
Target block interval10 minutes

The field has long been too small: a machine exhausts all four billion values in under a second. So miners also vary other parts of the block — the timestamp and a service transaction — to obtain a fresh set of values to search.

Where else the word appears

  • The transaction counter in EthereumHere nonce means something else entirely: the sequence number of an operation from a given address. It prevents the same transfer being sent twice.
  • A stuck transactionIf an operation with a lower number is unconfirmed, every later one waits for it. Hence the trick of replacing a transaction with the same number and a higher fee.
  • One-time values in cryptographyIn encryption such a value guarantees that two identical messages produce different output.

Where the two meanings are written down

  • Proof of Work: the Bitcoin whitepaper, 2008Section 4 of the original paper by Satoshi Nakamoto describes the search plainly: increment a nonce in the block until the hash carries the required number of leading zero bits. Everything miners do today is that sentence at industrial scale.
  • Cryptography: the NIST definitionOutside mining the word is older. NIST defines a nonce as a value used once within a given context, often to bind a message to a point in time. That is the sense behind one-time values in encryption and in signing.
  • Account counter: the Ethereum docsEthereum reuses the word for something unrelated to mining. The transaction documentation states that every transaction carries the sender's nonce, and the network accepts them strictly in order. Nothing is being searched for here: the number is simply counted up.