What Is a Nonce in Crypto? Understanding Transaction Nonces

July 13, 2026 3 min read

Key Takeaways

  • A nonce is a number used once, and it appears in two very different places: Bitcoin mining and Ethereum account transactions.
  • In proof-of-work mining, miners loop through the nonce range to find a hash below the network target, and the winning nonce makes the block valid.
  • On Ethereum, the account nonce is a sequential counter starting at zero that prevents replay attacks and keeps transactions in order.
  • A stuck transaction with a pending nonce blocks later ones from the same account, so you must speed it up, cancel it, or override the nonce.

A nonce is a number used once in cryptocurrency transactions to prevent double-spending and replay attacks.

What a Nonce Does

FunctionHow It Works
Unique identifierEach transaction has a unique nonce
Replay preventionSame transaction can’t be submitted twice
OrderingTransactions are processed in nonce order
Mining (PoW)Miners increment nonce to find a valid hash

Nonce in Bitcoin Mining

ElementValue
Nonce range0 to 4,294,967,295
PurposeFind a hash below the target
How miners use itIncrement nonce → re-hash → check
Extra nonceCoinbase transaction changes for more range

Nonce in Ethereum Accounts

ElementValue
Account nonceStarts at 0, increments by 1 per transaction
PurposePrevent replay and ensure order
GapsIf nonce 2 is pending, nonce 3 won’t process
Stuck transactionsCan’t send new txs until pending nonce clears

Why Nonces Matter for Users

ScenarioProblem
Stuck transactionNonce 5 is pending, can’t send nonce 6
Replace transactionSend same nonce with higher gas to override
Duplicate transactionSame nonce prevents duplicate execution
Metamask nonce managementCustom nonce overrides default

Managing Stuck Transactions

SolutionHow
Speed upResend with higher gas price (same nonce)
CancelSend 0 ETH to yourself with higher gas (same nonce)
Custom nonceManually set nonce to skip a stuck one

Nonce in Ethereum Account Abstraction

With ERC-4337 (account abstraction), nonce management changes:

Old (EOA)New (ERC-4337)
Sequential nonce per accountNonce can be custom
Stuck if nonce gapNonce gap doesn’t block
Hard to manageEasier UX

Developer View

TaskHow Nonce Is Used
Send transactionInclude nonce + 1
Get pending nonceeth_getTransactionCount
Build transactionSign with correct nonce
Handle failuresTrack nonce on chain

Bottom Line

A nonce is a counter that prevents replay attacks and ensures transaction ordering. In Bitcoin, miners use it for proof-of-work. In Ethereum, each account has a sequential nonce starting at 0. If a transaction gets stuck (nonce pending), you need to clear it before sending more transactions from that account. Use speed-up or cancel with higher gas.

Why the same word means two different things

The confusion around nonces comes from the fact that the crypto world uses one term for two unrelated mechanisms. In Bitcoin mining, the nonce is a field inside a block header that miners change on every attempt while hunting for a hash below the difficulty target. Because the target is so small, most random values fail, so the miner keeps incrementing the nonce through its full range, then changes the extra nonce in the coinbase transaction and starts over. When a miner finally finds a nonce that makes the block hash valid, the block is broadcast and every other node can instantly verify the work with a single hash. In this context the nonce is purely a proof-of-work tool; it has nothing to do with ordering your transactions.

On Ethereum, by contrast, the nonce is an account-level counter that protects users rather than securing the chain’s difficulty. Every account tracks how many transactions it has sent, starting at zero and incrementing by one each time. Because the nonce is included and verified, a transaction cannot be replayed: once the network has processed a transaction with a given nonce, any attempt to resubmit it fails because that nonce has already been used. The counter also defines the order in which transactions from the same account are processed, so the network can never execute transaction number 6 before transaction number 5. That ordering is what makes speed-up and cancel work — you resend a transaction with the same nonce but a higher gas price, and nodes replace the pending one.

What it means in practice for your wallet

Most users never think about nonces because wallets manage them automatically. The exception is when a transaction gets stuck. If you send a transaction and it sits pending for hours, every subsequent transaction you send from that account is also blocked, because they carry higher nonces that cannot be processed while the earlier one is outstanding. The standard fixes are to resend the stuck transaction with a higher gas price so a miner prioritises it, or to broadcast a 0 ETH transaction to yourself with higher gas that uses the same nonce, which effectively cancels the stuck one. Advanced users can also set a custom nonce in MetaMask to skip a stuck transaction entirely, though that is riskier because you can accidentally skip an intermediate transaction that should exist.

With account abstraction (ERC-4337), some of this friction is being removed: nonces become more flexible and controllable, and a gap no longer blocks the whole account the way it does with a classic externally owned account. But for anyone using standard wallets today, the practical lesson is simple. If your transaction seems stuck, the fix is almost always to adjust the gas — the nonce is doing its job and simply waiting for a confirmation. Understanding that the nonce is a security and ordering mechanism, not a fault, is the difference between calmly fixing a pending transaction and being confused by the whole process.

Common questions

Q: Can I set my Ethereum nonce to any number? A: Typically no for normal sending — wallets assign the next sequential nonce automatically. Advanced interfaces like MetaMask allow a custom nonce override, which is mainly for developers or for skipping a stuck transaction, but assigning an out-of-sequence nonce yourself can cause transactions to queue up unexpectedly.

Q: Why does my transaction sometimes fail even with the right nonce? A: A transaction can fail for reasons unrelated to the nonce, such as insufficient gas, an under-priced gas limit, or a contract revert. When it fails, the nonce is generally still consumed on Ethereum. With a failed nonce, the account moves on; the transaction is recorded as failed but no longer blocks subsequent sends.

Q: What happens if two people replay my Ethereum transaction? A: They cannot. The nonce is tied to your account and increments with each transaction, so a captured transaction cannot be replayed to double-spend or be resubmitted elsewhere. This is the replay-protection role the nonce plays across the account’s transaction history.

Q: How do I find my current nonce? A: You can query an Ethereum node using the eth_getTransactionCount RPC method, specifying the pending or latest block. Wallets do this automatically behind the scenes, so you only need it if you are building transactions manually or debugging a stuck one.

Frequently Asked Questions

What does nonce stand for in computing?

It is short for 'number used once'. A nonce is a value used only a single time. In crypto it appears as the miner's proof-of-work nonce in Bitcoin and as a sequential counter in Ethereum accounts, each serving to prevent reuse and replay.

Why is a transaction stuck and how do I fix it?

On Ethereum, if a transaction is sent with a nonce and it goes pending without confirming, every later transaction with a higher nonce is blocked from the same account. You can speed it up by resending with a higher gas price using the same nonce, cancel it by sending 0 ETH to yourself with higher gas, or manually set a custom nonce.

How does a nonce prevent replay attacks?

Each Ethereum account has a nonce that increments by one with every transaction. A transaction that was already executed has consumed its nonce, so replaying it on another chain or by another party fails because the nonce is no longer current for that account.

Is the mining nonce the same as the account nonce?

No, they are unrelated mechanisms that share a name. The mining nonce in Bitcoin is a number miners increment to try to find a valid hash, ranging from 0 to about 4.29 billion. The account nonce in Ethereum is an ordering counter that starts at zero and increments per transaction.

PP
PaisayehPaisa Editorial Team
Financial education in plain language. Our team reviews every article for accuracy and clarity.
← Back to Crypto Answers Search all articles
This content is for educational purposes only. Not financial advice. Do your own research before investing.