Market Cap: $2.8588T -5.21%
Volume(24h): $157.21B 50.24%
Fear & Greed Index:

38 - Fear

  • Market Cap: $2.8588T -5.21%
  • Volume(24h): $157.21B 50.24%
  • Fear & Greed Index:
  • Market Cap: $2.8588T -5.21%
Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos
Top Cryptospedia

Select Language

Select Language

Select Currency

Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos

What is a nonce in a transaction?

A nonce is a unique, incremental counter in Ethereum transactions that prevents replay attacks and enforces strict ordering—each transaction must use the next expected nonce.

Dec 25, 2025 at 05:20 pm

Definition and Role of Nonce

1. A nonce is a numeric value included in every Ethereum transaction that ensures each transaction is processed only once.

2. It acts as a counter, starting from zero for the first transaction sent from a given address and incrementing by one with each subsequent transaction.

3. The node validating the transaction checks whether the submitted nonce matches the expected value based on prior confirmed transactions from that sender.

4. If the nonce is too low, the transaction is rejected as a duplicate; if it is too high, the transaction remains pending until all prior nonces are filled.

5. This mechanism prevents replay attacks and enforces strict ordering of operations originating from the same account.

Nonce and Transaction Ordering

1. Transactions are not executed in the order they arrive at the network but according to their nonce values.

2. A transaction with nonce 5 cannot be confirmed before nonce 4, even if it was broadcast earlier or carries a higher gas fee.

3. Miners include transactions in blocks based on both gas price and correct nonce sequencing—only validly sequenced transactions qualify for inclusion.

4. When users submit multiple transactions rapidly, gaps in the nonce sequence cause later ones to stall indefinitely unless intermediate nonces are submitted and confirmed.

5. Wallets and transaction builders must track and manage the local nonce state carefully to avoid freezing funds in pending states.

Types of Nonces

1. Account nonce: Also called transaction nonce, it reflects the number of transactions sent from an Externally Owned Account (EOA).

2. Contract creation nonce: Used during smart contract deployment; it increments the account’s internal counter and determines the address of the newly created contract.

3. Block nonce: A completely separate concept used in Proof-of-Work consensus—this is a random value miners adjust to find a valid block hash and has no relation to transaction execution.

4. While block nonce appears in block headers, it plays no role in EVM transaction validation or account state transitions.

5. Confusing these distinct nonce types leads to misdiagnosed failures in transaction broadcasting and contract interaction.

Common Nonce-Related Errors

1. Nonce too low: Occurs when a transaction uses a nonce already associated with a confirmed or dropped transaction.

2. Nonce too high: Happens when a transaction specifies a nonce greater than the next expected value, causing indefinite queuing.

3. Replacement transaction failure: Attempting to replace a pending transaction with a new one using the same nonce but different parameters may fail if the original remains unconfirmed and the network does not accept the replacement.

4. Wallet synchronization lag: Some wallets display stale nonce values after rapid successive submissions, leading users to unknowingly reuse or skip nonces.

5. Manual nonce setting without checking current state is a frequent cause of stuck transactions across decentralized exchanges and NFT minting platforms.

Frequently Asked Questions

Q: Can I change the nonce of a pending transaction?A: No. The nonce is immutable once signed. To modify a pending transaction, you must submit a new one with the same nonce but higher gas price—a technique known as “speeding up” in many wallet interfaces.

Q: Does resetting my wallet clear the nonce count?A: No. Nonce is derived from on-chain state, not local storage. Restoring a wallet from seed phrase retrieves the latest confirmed nonce from the blockchain.

Q: What happens if two transactions with the same nonce are broadcast simultaneously?A: Only one will be accepted—the first to be included in a block. The other becomes invalid and is dropped from the mempool.

Q: Do smart contracts have nonces?A: Contracts themselves do not maintain nonces for sending transactions. However, when a contract creates another contract via CREATE or CREATE2, the deployer’s account nonce increases, and the new contract’s address depends on that nonce in CREATE scenarios.

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Related knowledge

See all articles

User not found or password invalid

Your input is correct