What Is the Nonce?
Nonce, a portmanteau of “number used only once,” is a number that the Bitcoin mining program uses. It is included in the block header, then that information is hashed. If the resulting hexadecimal number adds up to a value of less than or equal to the network’s difficulty target, the miner’s block is added to the blockchain. Another is opened, and the process begins again.
Key Takeaways
- A nonce is a numerical value used in a trial-and-error process to have a block added to the blockchain.
- The nonce is increased by a value of one for every attempt made.
- Finding the right combination of nonce and other values in the block consumes significant computational power.
- The nonce is one of a few values that can be altered to generate hashes for the competitive mining process.
Understanding the Nonce
A Bitcoin nonce is a 32-bit (or 4-byte) number that miners use to attempt to generate a valid hash to produce a new block in the Bitcoin blockchain. The nonce is one of the fields included in the block header, which also includes:
- The software version
- The previous block’s hash
- A timestamp
- The difficulty target
- The Merkle root
On the Bitcoin network, participants called miners compete to generate a hash that is less than or equal to the network target hash by repeatedly changing the nonce after each unsuccessful attempt.
Hashing refers to the process of applying a cryptographic hash function to information. The cryptographic hash function is a mathematical operation that takes block data and encrypts it by transforming it into a unique value, a fixed-length output of hexadecimal characters.
This hash value serves as a cryptographic fingerprint of the block, ensuring that the block’s contents remain unaltered. The nonce is the only variable in the block header that a miner can modify. By changing the nonce, a miner can change the hash of the block and calculate different possible solutions.
For example, this is the previous paragraph sent through an SHA-256 hashing algorithm:
acd691b23cc47b03addf7329b0467c6190e758ee763d7d648af75b5c5ae73e3a
By adding a value of zero (the nonce) at the end of the paragraph, you get a different hexadecimal value:
f4be24818264fdb8d120f7fe04b8b8f8d4359bc7b1a112412fa968aab7acb782
If you change that zero to a one, you’d get this:
9e3f30005b29927043ecfcec9edf815493326fe2060015fd56ed3213564c7200
This is how the nonce is used by the Bitcoin mining programming. The nonce value is increased by one with every attempt until a certain value is reached.
The first miner to find a valid hash under the network’s difficulty target is awarded the block reward. Their block is broadcast to the network, added to the blockchain, and the process begins again.
The target difficulty is a measure of how difficult it is to find a valid nonce. It is adjusted periodically to maintain a consistent block generation rate.
Extra Nonce and Time Stamp
You’ll find in a block explorer that nonces generally only go up into the billions. For example, the nonce for block 841,948 was 1,614,498,317. Block 841,949 had a nonce of 4,218,083,700. A modern mining rig can generate many more hashes than this in less than one second.
Additionally, the nonce is limited to 32 bits (4 bytes), so it can only go up to a little more than 4.29 billion. It has to roll over to be useful because hashing is so fast. So, an additional method was created after Bitcoin ASIC miners began ripping through the blockchain. Another number, called the extra nonce, is randomly generated and used in the coinbase data field. This value is added to the coinbase transaction space, which changes the Merkle root.
The Merkle root is part of the block header, so the block header hash changes. The extra nonce and the nonce are both manipulated to try to find the solution. If a solution cannot be found using either of these, the mining program allows the miners to adjust the timestamp. The combination of these three values allows the blockchain to keep its target of mining one block about every 10 minutes.
What Is the Meaning of the Phrase for the Nonce?
“Nonce” combines the phrase “number used once.” It is used by the Bitcoin blockchain to help generate a hashed value when mining a block.
What Is the Concept of a Nonce?
A nonce, in blockchain terms, is a number used once. Regarding its use on a blockchain, it is a number that increases sequentially in every attempt to generate a hash that meets the network’s difficulty criteria.
What Is an Example of a Nonce?
The best example of a nonce is a nonce used to mine a block. The nonce used in block 841,954 was 3,983,795,221. This doesn’t mean it only took the miner 3.98 trillion attempts—it likely rolled over several thousand times and was used in combination with the variable extra nonce and timestamp entries. As a 32-bit number, the nonce can only increase to slightly more than 4.29 billion.
The Bottom Line
In Bitcoin mining, miners compete to find a nonce that meets the network’s difficulty criteria. The information in a block header is sent through a hashing algorithm, resulting in a value that must be less than or equal to the network difficulty target.
In every attempt to meet the target, the nonce is increased by one. If it exceeds the 32-bit limit, it is rolled over, and the extra nonce and timestamp are used in combination with it until a miner is successful.
The comments, opinions, and analyses expressed on Investopedia are for informational purposes online. Read our warranty and liability disclaimer for more info.