Table of Contents
Table of Contents

Nonce: What It Means and How It's Used in Blockchain

What Is a Nonce?

"Nonce" is a portmanteau of "number used only once." It is a four-byte number added to a hashed—or encrypted—block in a blockchain that, when rehashed, meets the difficulty level restrictions. The nonce is the number that blockchain miners are solving for. When the solution is found, the blockchain miner that solves it is given the block reward.

Learn more about the nonce and why it is important to some blockchains.

Key Takeaways

  • Nonce, a "number only used once," refers to the number a blockchain miner needs to discover before solving for a block in the blockchain.
  • Once the miner solves the hash, they receive the block reward.
  • Miners open new blocks by generating a nonce that makes the hash they create less than the hash from the block they are validating.

Understanding the Nonce

A blockchain's security relies on its ability to create and validate long, encrypted numbers, sometimes called a "hash." The cryptographic function used to generate a hash is deterministic, meaning that it will produce the same result each time the same input is used.

It also means that the function can generate a hashed input efficiently. This makes determining the input difficult (leading to the blockchain's security), and small changes to the input result in a different hash. This complex system creates the security net of a blockchain.

To keep the blockchain secure, data from previous blocks are encrypted or “hashed” into a series of numbers that is the block header for the next block. The block header is one of the fields in a block on a blockchain.

Transactions on a blockchain are aggregated into blocks from a memory pool based on the age of the transaction or the amount of fees paid.

The header is metadata, which contains the blockchain version number, the previous block's hash, the Merkel Root, timestamp, the difficulty target, and the nonce. The nonce is the value that miners are trying to solve for.

How Is the Nonce Used?

The nonce is used to validate the information contained within a block. The mining program generates a random number, appends it to the hash of the current header, rehashes the value, and compares this to the target hash. If the resulting hash value meets the requirements, the miner has created a solution and is awarded the block. If the value doesn't match the target, the nonce is increased by one, and the process starts again. This continues until one miner meets the target.

Most blocks are opened by mining pools because the mining difficulty is so high a single miner is unlikely to have enough hashing power to keep up, measured in the number of hashes per second that a miner is capable of. A home computer with the latest equipment might have a hashrate of 100 mega hashes per second (6 zeros, or million), where a mining farm full of ASIC miners might hash around 30 exa hashes per second (18 zeros, or quintillion).

It is highly unlikely that the nonce will be guessed on the first try. Miners generally have to test a large number of nonce options before getting it right. The greater the difficulty—a measure of how hard it is to create a hash less than the target—the longer it is likely to take to generate a solution.

Block difficulty is kept the same across the entire network, meaning that all miners have the same chance of figuring out the correct hash. Cryptocurrency networks typically establish a target number of blocks they want to be processed during a specific period and occasionally adjust the difficulty to ensure that this target is met. If the number of blocks processed does not meet this target, the difficulty will be reduced, with the reduction in difficulty set to how much time the process was over the limit.

What Does Nonce Stand for?

In cryptocurrency, a nonce is an abbreviation for "number only used once," which is a number added to a hashed—or encrypted—block in a blockchain that, when rehashed, meets the difficulty level restrictions. The nonce is the number that blockchain miners are solving to receive the block reward.

What Is a Blockchain Nonce?

A blockchain nonce is a number added to a hashed—or encrypted—block in a blockchain.

How Are Nonces Used?

In cryptocurrency, nonces are used as the number that is used in a hash to verify the transactions and other data contained in a block.

Article Sources
Investopedia requires writers to use primary sources to support their work. These include white papers, government data, original reporting, and interviews with industry experts. We also reference original research from other reputable publishers where appropriate. You can learn more about the standards we follow in producing accurate, unbiased content in our editorial policy.
  1. O'Reilly. "Mastering Bitcoin."

Take the Next Step to Invest
The offers that appear in this table are from partnerships from which Investopedia receives compensation. This compensation may impact how and where listings appear. Investopedia does not include all offers available in the marketplace.