What Is A Nonce: The “Wild Card” That Secures Blockchains

  • Facebook
  • Twitter
  • LinkedIn
  • Telegram


  • A nonce stands for “number used once” in cryptographic communications.
  • It is randomly generated and cannot be calculated, only guessed.
  • Its purpose is to make it prohibitively difficult for an attacker to tamper with transactions in a blockchain, since they would need to redo the hashing for all subsequent blocks in order to maintain the blockchain’s integrity.

nonce in blockchain

What is a nonce?

A nonce is an arbitrary number used only once in a cryptographic communication. It is a “number used once” because it helps to ensure that old communications cannot be reused and that messages are not tampered with. It is sometimes called the “salt.”

Nonces are often randomly generated numbers used to ensure the one-time use of a function or value. For example, a nonce can be used as a message authentication code (MAC) or as part of a digital signature algorithm.

What is a nonce in blockchain?

In blockchain technology, a nonce is part of the data that is hashed with the miner’s public key and a timestamp to produce a unique identifier for the block, in the mining process.

The purpose of the nonce is to make it difficult for an attacker to tamper with the block or its transactions, since they would need to redo the hashing for all subsequent blocks in order to maintain the blockchain’s integrity.

It is important to note that nonces are not required to be secret. In fact, they are often publicly visible as they are part of the data that is hashed to produce a block’s hash. However, they should not be predictable as this would make it easy for an attacker to tamper with the blockchain.

What is a nonce in Bitcoin?

A Bitcoin nonce is a 32-bit field that miners change as they work on new blocks in the blockchain. It is a random number that miners use to ensure that each block has a unique hash, or cryptographic fingerprint.

By changing the nonce, miners can change the hash of the block, which allows them to explore different possible solutions to the underlying math problem and find one that results in a valid block.

In Bitcoin crypto mining, the hash algorithm inputs such as the Merkle root are all predictable; the only unpredictable part is the nonce. Guessing it is akin to winning the lottery in which the miner who guesses it rightly wins and receives the Bitcoin block rewards which are awarded every 10 minutes.

Because each nonce is essentially a random number, it’s unlikely that two miners will ever produce the same hash for a given block. This means that if one miner finds a solution, the others can quickly verify it and add the block to the chain.

The nonce is also used to help prevent what’s known as a “51% attack.” This is when a group of miners controls more than half of the total mining power on the network and can theoretically manipulate the blockchain to their own benefit.

This is the genius of Satoshi Nakamoto–he programmed the Bitcoin mining algorithm, SHA-256, to increase in difficulty every four years, making the Bitcoin nonce increasingly harder to predict even as overall computing power in the network increased. The higher the difficulty needed to create a block, the stronger the Bitcoin blockchain’s security becomes since attackers would need enormous computing power to take control.

This is how Bitcoin solves the stubborn problem of “double spend” which is at the heart of Bitcoin’s success as the world’s first functioning cryptocurrency. The double spend problem had plagued the Cypherpunks for years before Bitcoin came about.

Earn 8.5% apy on Crypto Interest account

Bitcoin nonce example

A Bitcoin blockchain nonce is a string that starts with a set of zeroes, and when hashed, produces a shorter number. This number can be anything from “82” to “91240”. The numbers vary based on the requirements of the network at the time, and this varies based on the amount of nodes mining and the difficulty.

In the illustration below, Bitcoin nodes (computers) who participate in the Proof-of-Work consensus calculate the correct nonce which meets the target hash requirements:


SHA-256 algorithm responsible for nonce selection. (Image Source: NewDayCrypto)

A hashed nonce produces a number that may or may not be valid. In this case, the valid nonce is a short four-digit number “2307”. The first miner who successfully calculates the nonce receives the block rewards.

get free crypto by just watching videos

Nonce vs hash

A nonce is a 32-bit field that miners change as they work on new blocks in the blockchain, in order to help ensure that each block has a unique hash, which in turn helps prevent 51% attacks.

A hash is a mathematical function that converts an input of any size into an output of fixed size. The output of a hash function is commonly referred to as a “hash value,” “hashcode,” or simply “hash.” Hash functions have been in use in many different applications prior to Bitcoin, such as digital signatures, file integrity verification, and password storage.

In other words, the nonce and the hash function go hand-in-hand; the nonce acts as a second input (hence the term “salt”), used with the original input to make it more difficult to reverse the hash function and compute the original input from the hash value.

For any inquiries contact us at support@phemex.zendesk.com
Follow our official Twitter | Join our community on Telegram
Trade crypto on the go: Download for iOS | Download for Android
Phemex | Break Through, Break Free