What Is Nonce?

A nonce is an abbreviation for "number only used once," which, in the context of cryptocurrency mining, 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 for. When the solution is found, the blockchain miners are offered cryptocurrency in exchange.

Key Takeaways

  • Nonce, or a "number only used once," refers to the first number a blockchain miner needs to discover before solving for a block in the blockchain.
  • Once the mathematical computations are solved by the miner, they are gifted cryptocurrency for their time and skill.
  • Nonces are difficult to find and are considered a way to weed out the less talented crypto miners.
  • The world of crypto mining is challenging, and one often needs excellent computational power to even begin to try and solve the nonce.
  • Nonces are used for a range of computer networking applications, including authentication for purchases, two-factor authentication, or other kinds of account recovery and identification.

Understanding Nonces

The blockchain is the cornerstone of cryptocurrency. In order to keep the blockchain secure, data from previous blocks are encrypted or “hashed” into a series of numbers and letters. This is done by processing the block input through a function, which produces an output of a fixed length.

The function used to generate the 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, makes determining the input difficult (leading to the blockchain's security), and makes small changes to the input result in a very different hash. This complex system creates the privacy net of blockchain.

Special Considerations

Adding transactions to the blockchain requires substantial computer processing power. The individuals and companies who process blocks are called miners. Miners are compensated only if they are the first to create a hash that meets a certain set of requirements, called the target hash.

The process of guessing the hash starts in the block header. It contains the block version number, a timestamp, the hash used in the previous block, the hash of the Merkle Root, the nonce, and the target hash.

If the hash meets the requirements set forth in the target, then the block is added to the blockchain. Cycling through solutions in order to guess the nonce is referred to as proof of work, and the miner who is able to find the value is awarded the block and paid in cryptocurrency.

A golden nonce results in a hash value that is lower than the target difficulty, meaning it satisfies the requirement of the next block.

How to Find the Nonce

Determining which string to use as the nonce requires a significant amount of trial-and-error, as it is a random string. A miner must guess a nonce, append it to the hash of the current header, rehash the value, and compare this to the target hash. If the resulting hash value meets the requirements, the miner has created a solution and is awarded the block.

It is highly unlikely that a miner will successfully guess the nonce on the first try, meaning that the miner may potentially 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 that is 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 time period, and periodically adjust the difficulty in order to ensure that this target is met. If the number of blocks processed does not meet this target then the difficulty will be reduced, with the reduction in difficulty set to the amount of time over the limit the processing time was. 

Uses for Nonce

Nonces are used for a range of computer networking applications, including authentication for purchases, two-factor authentication or other kinds of account recovery and identity applications, electronic signatures, data encryption, and more.

Nonce FAQs

What Is Nonce 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 for, in order to receive cryptocurrency.

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?

Nonces are used for a range of computer networking applications, including authentication for purchases, two-factor authentication or other kinds of account recovery and identity applications, electronic signatures, data encryption, and more.

What Is a Golden Nonce?

A golden nonce results in a hash value that is lower than the target difficulty, meaning it satisfies the requirement of the next block.