Skip to content
LearnBitcoin

LearnGlossary

Nonce

A 32-bit field in the block header that miners vary to find a hash below the network's difficulty target.

The nonce is a 32-bit field in the block header that miners change while searching for a valid block. "Nonce" is short for "number used once."

Mining at the lowest level looks like this:

loop:
  set nonce to next value
  hash = SHA-256(SHA-256(header))
  if hash < target: broadcast block
  else: try again

That's it. There's no shortcut, no algebra, no clever derivation. You just compute hashes until one happens to fall below the target. One mining machine released in 2024, packed with many ASIC chips, is rated at 234 trillion hashes per second.

The 32-bit nonce only has 2^32 = ~4.3 billion possible values, which a serious mining operation burns through in a fraction of a second. When it runs out, the miner changes another part of the block (typically the extranonce inside the coinbase transaction), which changes the Merkle root in the header, which gives them a fresh 4.3-billion-value nonce space to search. Repeat until something works.

The nonce is the most boring 4 bytes in Bitcoin and also the entire mechanism by which proof-of-work happens. See Hash for what's being computed, and the Mining rabbit hole for why finding a good one matters.

Mine a toy block

Miners change one number in the block header, the nonce, and hash the header again, until the hash comes out below a target. This toy does the same in your browser, with a target easy enough to hit.

about 65,536 tries on average

Nonce
0
Hashes tried
0
Hashes per second
-
Hash
42fbd43f9b74362e6464fcdfe7685880a780be22614c8c9a7230555d1f36343c

The toy hashes the data and a 4-byte nonce with SHA-256 twice, as Bitcoin does with its 80-byte header, and shows the hash in the byte order block explorers use. Each extra zero makes the search 16 times longer on average. Bitcoin difficulty works the same way in finer steps: it moves the target itself.

Key takeaways

  • Central to the proof-of-work process in block hashing
  • Only 4 bytes, so miners also tweak extranonce/other fields
  • Finding a valid nonce verifies the block meets difficulty

On the mailing list

The topic timeline: Signatures and cryptography (158 threads).

Corrected

  • Was: The entry said modern mining ASICs compute about 100 trillion hashes per second per chip.

    Now: Speeds like that belong to a whole mining machine, which is built from many ASIC chips. One machine released in 2024 is rated at 234 trillion hashes per second. Details

Sources (1)

External references (3)

Related terms (6)

Published . Revised . One correction logged for this page.

Edit this page on GitHub