Nonce
Nonce stands for “number used once.” In Bitcoin mining, it is a 32-bit field in the block header that miners change repeatedly, trying different values until the resulting hash meets the network’s difficulty target.
Understanding the Nonce
Section titled “Understanding the Nonce”When a miner constructs a candidate block, the block header contains several fields: the previous block hash, a Merkle root, a timestamp, the difficulty target, a version number, and the nonce. The miner feeds this header through the SHA-256 hash function twice. If the output is not below the required target, the miner increments the nonce and tries again.
Imagine you are trying to roll a specific combination on a die. Each roll is a new attempt with a new nonce value. You keep rolling until you get the number you need. The nonce is simply the value of your current roll.
Since the nonce is a 32-bit number, it has approximately 4.3 billion possible values (0 to 2^32 - 1). At the hashrates of modern ASIC miners, this entire space can be exhausted in under a second. That is why miners also rely on the extranonce to expand the search space — by changing the extranonce, the Merkle root changes, effectively giving the miner a fresh set of 4.3 billion nonce values to try.
Practical Example
Section titled “Practical Example”A miner receives a new job from the pool. The block header is assembled, and the miner starts with nonce = 0, hashes the header, checks the result against the target, and if it fails, tries nonce = 1, then nonce = 2, and so on. Each nonce change produces a completely different hash output due to the avalanche effect of SHA-256.