Nonce

A nonce is a number used once in cryptography; in crypto it usually means the value miners change to find a valid block hash, or the counter that orders an account's transactions on networks like Ethereum.

Some crypto terms sound far more complicated than they are. "Nonce" is one of them. It is just a number, but it plays a surprisingly important role in keeping blockchains secure and making sure your transactions happen in the right order.

You will most often see the word in two places: in Bitcoin mining and in Ethereum transaction details. Let's look at what a nonce is in each case and why it matters to you.

What Does Nonce Mean?

Nonce is short for "number used once." In cryptography, a nonce is a value that is meant to be used a single time for a specific purpose, so the same message or action cannot be repeated or predicted. In crypto, the word has two common meanings: the number miners adjust while searching for a valid block, and the counter that tracks how many transactions an account has sent.

Think of the ticket number you pull at a busy deli counter. Each number is used once, it tells staff exactly who is next, and nobody can be served twice with the same ticket. A transaction nonce works much like that ticket. A mining nonce is more like spinning the dial on a combination lock, trying number after number until one opens it.

The Nonce in Mining

On proof-of-work blockchains like Bitcoin, the nonce is a field inside each block header. It is the main thing miners change while competing to add the next block.

How Miners Use It

To win a block, a miner must produce a hash of the block header that is lower than a target number set by the network. A hash is like a digital fingerprint: changing even one character in the input creates a completely different output. Miners cannot predict which input will produce a winning hash, so they keep changing the nonce and hashing again, billions or trillions of times.

When a miner finds a nonce that produces a valid hash, they broadcast the block. Other nodes can check the result with a single calculation, which is what makes the system efficient to verify but costly to cheat.

Why It Matters for Security

Finding the right nonce takes real computing work and electricity. To rewrite past blocks, an attacker would have to redo that work for every block they want to change, plus keep up with the honest network. This is a big part of what makes proof-of-work chains hard to tamper with.

The nonce field in a Bitcoin block header is fairly small, so modern mining machines can run through every possible value very quickly. When that happens, miners change other parts of the block, such as the timestamp or a special field in the reward transaction, and start cycling through nonces again. The idea stays the same: keep changing the input until the output hits the target.

The Nonce in Transactions

On account-based networks like Ethereum, every account has a transaction nonce. It starts at zero and goes up by one with each transaction the account sends.

  • Ordering: Transactions from the same account are processed strictly in nonce order, so the second one cannot confirm before the first.
  • Replay protection: Because each nonce can only be used once, nobody can copy a signed transaction and broadcast it again to spend your funds twice.
  • Uniqueness: Even if you send the exact same amount to the same address twice, the different nonces make each transaction distinct.

Bitcoin does not use account nonces in the same way. It tracks coins through the UTXO model instead, where each transaction spends specific unspent outputs.

Stuck Transactions and Nonces

The transaction nonce is the reason one low-fee transaction can hold up everything behind it. If you send a transaction with a gas fee that is too low, it may sit unconfirmed in the mempool. Every later transaction from that account waits in line, because the network will not process a higher nonce until the lower one is done.

Speeding Up or Canceling

Many wallets offer "speed up" or "cancel" buttons. Both work by sending a new transaction with the same nonce as the stuck one, but with a higher fee. If the new one confirms first, it takes that nonce's place. A cancel is simply a zero-value transaction to yourself that replaces the original.

Custom Nonces

Some wallets let advanced users set the nonce manually. This can help fix a stuck queue, but entering the wrong number can cause errors or unexpected replacements, so beginners are usually better off letting the wallet handle it.

Why Nonces Matter to You

You will rarely need to think about nonces day to day, but knowing what they do helps when something goes wrong. If a transaction is pending for a long time and newer ones are stuck too, a low-fee transaction earlier in the queue is often the cause. You can see each transaction's nonce on a blockchain explorer, which makes it easier to understand what is happening and fix it calmly instead of sending the same payment again.

Outside of mining and transactions, nonces also show up when you sign in to some apps with your wallet, where a one-time value stops old signatures from being reused.

FAQs about Nonce

Why is my Ethereum transaction stuck because of a nonce?

Ethereum processes each account's transactions in nonce order. If an earlier transaction has a fee that is too low, it can block every later one until it confirms or is replaced with a higher-fee transaction using the same nonce.

Can two transactions have the same nonce?

Two transactions from the same account can be broadcast with the same nonce, but only one of them can ever confirm. This is exactly how wallets speed up or cancel pending transactions.

Do I need to set a nonce myself?

Usually not. Your wallet tracks and sets the nonce automatically. Manual nonce settings are mainly for advanced users fixing stuck or out-of-order transactions.

Ready to start your crypto journey?

Join 3.000.000+ satisfied customers.

Buy crypto

Latest articles