Network and blocks
What is a nonce?
The nonce is a 32-bit field in the block header that miners change to produce a new hash on each attempt.
- Size on Bitcoin
- 32 bits
- Values
- 4,294,967,296
- Place
- Last 4 bytes of the header
- Starts at
- Anywhere the miner likes
- Name from
- Number used once
What it means in practice
A miner hashes the header, checks whether the result is below the target, and if not changes the nonce and tries again. The 32-bit field offers about 4.29 billion values, which a modern machine runs through in microseconds. Miners then change other parts of the block, such as the coinbase field or timestamp, to keep searching.
More room than 32 bits
When the nonce is used up, something else in the header has to change. Machines have three sources. They roll some bits of the version field, 16 of which are set aside for that use. They move the timestamp forward second by second. And they change the extra nonce in the coinbase transaction, which gives a new Merkle root.
Example figures: 32 bits of nonce and 16 bits of version make 2^48 headers, about 2.81 × 10^14. A 200 TH/s machine uses them in 1.4 seconds. The time field then advances, and the extra nonce has billions of further values in reserve.
How chips split the range
Every chip on a board receives the same job and searches a different part of the space, set by its address in the chain. Nobody hashes the same header twice. Within a chip, each core takes its own slice.
It makes no difference in which order the values are tried. Counting up from zero, down from the top or at random finds blocks equally often, because the hash of one nonce says nothing about its neighbor’s.
Valid, invalid and lost
When a chip believes it has a good result, it sends the nonce to the control board, which hashes that one header again. If the answer matches, it is valid and may become a share. If not, the chip made a mistake and the dashboard counts a hardware error.
A handful of errors among thousands is routine. A chip that is too hot, too fast or short of voltage makes many. A tuner watches exactly this number when it picks a frequency.
Hashrate on the dashboard is worked out from valid nonces, so errors lower it at once.
The word in other places
Zcash uses a 32-byte nonce and Kaspa one of 8 bytes, so those chains do not need an extra counter in the same way. Litecoin and Dogecoin have 4 bytes like Bitcoin.
On account-based chains a nonce is something else: a counter that numbers the transactions of an address. In encrypted messages it is a value that makes each message unique. The common thread is a number that is used once.
In an explorer the winning nonce appears in the block details. It looks random because it is. No pattern in past values helps with the next block.
Worked example
2^32 = 4,294,967,296 nonce values; at 200 TH/s a machine tries them all in 4,294,967,296 / (2 × 10^14) ≈ 21.5 microseconds.
Example figures, not live data.
Common mistakes
- Believing that some nonces are luckier than others.
- Confusing the nonce with the hash it produces.
- Reading a mining nonce and a wallet’s transaction nonce as the same thing.
Common questions
Can two miners find the same nonce?
Yes, for different headers. Their other fields differ, so their hashes do too.
Why was 32 bits chosen?
It was ample for the processors of the time. The extra fields have filled the gap since.
What is a nonce error on a miner?
A result that failed the control board’s check. It is also shown as a hardware error.