Nonce
A nonce is a sequential number in a blockchain transaction that ensures transactions from the same account process in order and prevents replay attacks.
What Is a Nonce?
A nonce is a number meant to be used only once. In crypto the word names three different things; the one most wallet users meet is the transaction nonce on account-based chains such as Ethereum.
Every Ethereum account has a counter that starts at zero and rises by one with each transaction it sends. A transaction is valid only if its nonce is the next in line, which fixes the order and stops a signed transaction from being included twice. A pending transaction with a low fee therefore blocks all later ones from the same account, and it can be sped up or cancelled by sending a new transaction with the same nonce and a higher fee. Replay on another network is prevented separately, by the chain ID.
In proof-of-work mining, the nonce is the header field that miners keep changing to find a valid block hash. Bitcoin transactions have no account nonce, because Bitcoin tracks unspent outputs, not accounts.
The third meaning is the secret value used inside each digital signature. It must never repeat: two signatures made with the same nonce reveal the private key. Some hardware wallets, such as the BitBox02 and the Blockstream Jade models, add an anti-exfil (anti-klepto) protocol so the host app can check the device is not leaking key data through its nonces.
Real-World Examples
Example 1: Alice sends two Ethereum transactions in a row. The first, with nonce 7, pays a fee that is too low, so the second, with nonce 8, waits behind it even though its fee is high.
Example 2: To cancel a stuck transaction, a user sends 0 ETH to their own address with the same nonce and a higher fee, and confirms it on the hardware wallet. Once it is mined, the original can no longer be included.
Example 3: A mining machine runs through values of the block header nonce at high speed. The value that produces a hash below the target makes the block valid.
Frequently Asked Questions
Why is my new Ethereum transaction stuck behind an older one?
Because transactions from one account must use their nonces in order. If a pending transaction with a lower nonce pays too low a fee, every later transaction from that account waits behind it, even one with a high fee. Speeding up or cancelling the stuck transaction unblocks the ones after it.
How do I cancel a pending Ethereum transaction?
Send a new transaction with the same nonce and a higher fee, for example 0 ETH to your own address, and confirm it on the hardware wallet. Once it is mined, the original can no longer be included, because its nonce has been used. If the original is mined first, the replacement is the one that cannot be included.
Why must the nonce inside a signature never repeat?
Two signatures made with the same secret nonce reveal the private key. This nonce is a different thing from the Ethereum transaction counter and the mining nonce. Some hardware wallets add an anti-exfil (anti-klepto) protocol so that the host app can check the device is not leaking key data through its nonces.
Sources
Ready to Choose a Secure Wallet?
Use our tools to find the right hardware wallet for your needs.