What is a nonce in crypto?

What is a nonce in crypto?

What is a nonce?

A nonce in crypto is short for “number used once”, a number that is only used once within crypto. This unique value ensures that the outcome of calculations or verifications changes every time. Nonces are used as a tool within blockchains to prevent fraud, secure transactions and enable consensus within a network.

In practice, a nonce has two main roles within crypto:

  • During mining in Proof-of-Work blockchains
  • In transactions and security mechanisms

Although these two applications are similar, the role of the nonce differs per context.


Key Takeaways

  • A nonce is a unique number (“number used once”) that is used to prevent repetition and manipulation within blockchains.
  • In Proof-of-Work networks, miners continuously adjust the nonce to find a valid hash.
  • In Bitcoin, the nonce is limited to 32 bits, which is why miners use additional variation such as an extra nonce and timestamps.
  • The nonce contributes to security by making it extremely expensive to modify or falsify blocks.
  • In Ethereum, the nonce functions as a transaction sequence number per account and is separate from consensus.

What is the nonce in Proof of Work (such as Bitcoin)?

In Proof-of-Work (PoW) blockchains, miners must demonstrate that they have performed computational work before they are allowed to add a new block. They provide this proof by finding a valid hash.

A hash is the output of a cryptographic hash function. This is a mathematical function that converts input data into a fixed string of characters. This hash function (often SHA-256) is one-way. This means you cannot reverse-engineer the original input from the hash. As a result, there is only one way to find a valid hash: performing a large number of calculations.

The nonce is the variable number that miners adjust to generate a different hash each time. It is stored in the block header. By changing the nonce, a miner can try a new hash every time. Miners continue adjusting the nonce until they find a valid hash. In addition, the hash must meet the network’s difficulty requirement, such as being below a certain threshold.

Why do miners keep changing the nonce?

The crypto network sets the difficulty so that it takes an average fixed block time to find a new block (for example, about 10 minutes for Bitcoin). Miners therefore constantly attempt to generate a different hash by adjusting the nonce. This process can involve millions to billions of attempts per second.

In Bitcoin’s early years, this was relatively easy and miners needed far fewer attempts. At that time, it was even possible to mine Bitcoin on a laptop, whereas today this is virtually impossible and specialized ASIC computers are primarily used.

Once a miner finds a hash that meets the difficulty requirement, the block is shared with the network. Other nodes then verify whether the block is valid and subsequently add it to the blockchain. The same process then begins again for the next block.

What is the nonce limit and extra variation in Bitcoin?

In Bitcoin, the nonce is limited to 32 bits, which results in just over 4 billion possible values. Modern miners can traverse this space very quickly and therefore use additional methods to keep changing the input. For example, they add an extra nonce in the coinbase transaction (an additional variable within the miner’s reward) and adjust the timestamp, the moment when the block is recorded. The goal remains the same: generating new hash outputs.

How does a nonce contribute to security?

The nonce makes Proof-of-Work practical and secure:

It makes falsifying blocks extremely expensive. To falsify a block, someone would need to find a valid hash again. This generally requires at least as much computational power as the rest of the network combined (a so-called 51% attack), making fraud practically unfeasible.

  • Anyone can easily verify whether a block is valid. Other nodes only need to check whether the block’s hash complies with the rules. This requires very little time or energy and is therefore highly efficient.
  • It ensures fair competition between miners. Because all miners follow the same rules and can only succeed by performing actual computational work, an open and transparent competition emerges.
  • The larger the blockchain becomes, the harder it is to manipulate old blocks. If someone wanted to modify an old block, they would need to re-mine that block and all subsequent blocks, which would require an enormous amount of time and energy.

How does a nonce work in Ethereum and other altcoins?

A nonce works differently in Ethereum and other altcoins than in Bitcoin mining. In Ethereum, which uses Proof-of-Stake (PoS), a nonce functions as an incremental sequence number per account. Each transaction receives a nonce, ensuring that transactions are always processed in the correct order and that the same transaction cannot be executed twice. In Ethereum, the nonce is a transaction mechanism and not a tool used to achieve consensus.

What are the disadvantages of nonces?

Nonces themselves are not a disadvantage, but the way they are used within Proof-of-Work networks does introduce drawbacks:

  • Continuously adjusting the nonce to find a valid hash requires intensive computational work and leads to high energy consumption.
  • As the network grows and more miners participate, the difficulty increases and more calculations are required.
  • The economies of scale of specialized hardware and cheap energy can provide an advantage to large mining pools.

These disadvantages play an important role in the trade-off between Proof of Work and Proof of Stake.

Final thoughts

A nonce is an essential technical tool within blockchain technology that ensures uniqueness, security and reliability. In Proof-of-Work networks, the nonce forms a crucial component of the mining process and blockchain security, while in blockchains such as Ethereum it is mainly used to correctly order transactions and prevent duplicate execution. Although nonces themselves have no disadvantages, their use within Proof-of-Work leads to high energy costs and economies of scale for large miners, which is an important reason why more and more networks are choosing alternative consensus mechanisms such as Proof of Stake.

About Finst

Finst is one of the leading cryptocurrency providers in The Netherlands and offers a best-in-class investment platform together with institutional-grade security standards and ultra-low trading fees. Finst is led by the ex-core team of DEGIRO and is authorized as a crypto-asset service provider by the Dutch Authority for the Financial Markets (AFM). Finst offers a full suite of crypto services including trading, custody, fiat on/off ramp, and staking for both retail and institutional investors.

The crypto platform you'll love

We are here to give you the tools, inspiration, and support you need to become a better investor.