What is a Nonce?
A nonce, short for “number used once,” has two jobs in crypto: it is the value Bitcoin miners change while searching for a valid block hash, and the counter that orders an Ethereum account's transactions.
On this page 5
A nonce, short for “number used once,” is a value in cryptography that is meant to be used only a single time. In crypto it shows up in two different roles: the number Bitcoin miners change while hunting for a valid block hash, and the sequence number attached to every transaction sent from an Ethereum account. Knowing which one you’re dealing with makes pending transactions in your wallet much easier to understand.
What does the nonce do in Bitcoin mining?
Every Bitcoin block header contains a 32-bit nonce field. During proof of work, a miner writes a different number into that field and hashes the header again, looking for a result below the network’s target. Because each new nonce produces a completely different hash, there is no way to predict which number will work. The only strategy is to keep guessing.
A 32-bit field allows about 4.3 billion values, and modern mining machines run through all of them in a tiny fraction of a second. Miners therefore also change an “extranonce” inside the coinbase transaction and adjust the timestamp. Each change alters the Merkle root and opens up a fresh range of guesses. Once a valid hash is found, the winning nonce stays in the header so anyone can verify the block.
In other words, the mining nonce is not a secret winning code; it is simply the counter in a massive trial-and-error process. How hard that process is depends on the current mining difficulty.
What is the transaction nonce on Ethereum?
Every Ethereum user account has a nonce. The first transaction an account sends has nonce 0, the next has nonce 1, and so on. This counter does two jobs:
- Ordering: transactions from the same account are processed strictly in nonce order. Nonce 6 cannot be included until nonce 5 is confirmed.
- Replay protection: if a signed transaction is broadcast a second time, it is ignored because its nonce has already been used.
For smart contract accounts, the nonce means something different: it counts how many contracts that contract has created.
Wallets normally set the nonce automatically, and some let you override it in advanced settings. Using the same account in two wallet apps at once can lead both to assign the same nonce, so one of the transactions ends up being dropped.
How do you fix a stuck transaction using the nonce?
If a low-fee transaction gets stuck in the mempool, every later transaction from the same account queues up behind it. Wallet “speed up” and “cancel” buttons work by reusing the nonce:
- Speed up: the wallet sends the same transaction again with the same nonce and a higher fee. Validators generally pick the better-paying version.
- Cancel: the wallet sends a 0 ETH transaction to your own address with the same nonce and a higher fee. If it confirms first, the original transaction becomes invalid.
Neither is guaranteed; the original transaction may already have been included by the time the replacement arrives. Before setting a nonce manually, check your account’s latest confirmed nonce on a block explorer. Sending a second transfer to the same address does not cancel the first one and can leave you paying twice.
Frequently asked questions
Do Bitcoin transactions have a nonce?
No. Bitcoin uses the UTXO model rather than accounts, so its transactions have no sequence counter; stuck payments are bumped with methods such as RBF or CPFP instead. On Bitcoin, the nonce lives only in the block header.
What is a nonce gap?
If you send nonce 8 before nonce 7 has ever been broadcast, nonce 8 will wait indefinitely. Nothing after the gap can confirm until the missing number is filled.