Qaynaq LABS · TOOLS

CRYPTO GLOSSARY

Nonce (in EVM)

A unique, single-use number in Ethereum’s EVM that ensures each transaction is processed exactly once and prevents replay attacks.

Technical definition

In the Ethereum Virtual Machine (EVM), a nonce is a 64-bit unsigned integer associated with each externally owned account (EOA) or contract address. For EOAs, the nonce represents the number of transactions sent from that address and must increment sequentially with each new transaction. For contracts, the nonce tracks the number of contract creations originating from the address. The EVM enforces strict nonce ordering to prevent transaction replay (where the same transaction could be processed multiple times) and to ensure deterministic execution. Miners or validators verify that a transaction’s nonce matches the expected value for the sender’s address before including it in a block.

An analogy

Think of a nonce like a serial number on a paper checkbook. Each check has a unique number in sequence, and the bank only accepts checks in the correct order. If someone tries to reuse an old check number, the bank rejects it. Similarly, the EVM ensures transactions are processed in the exact order of their nonce, preventing duplicates or out-of-sequence submissions.

Why it matters

The nonce system guarantees that transactions are processed exactly once and in the intended order, which is critical for security and consistency in Ethereum. Without it, attackers could replay old transactions or manipulate transaction sequences.

Where it came from

The nonce concept was introduced with Ethereum’s launch in 2015 as part of its account-based model, inspired by Bitcoin’s transaction counter but adapted for smart contract functionality. It has been a core feature of the EVM since inception.

Example in practice

Alice sends 1 ETH to Bob. Her wallet sets the nonce to 5 (her 5th transaction). The transaction is included in a block, and the nonce for her address is incremented to 6. If she tries to resend the same transaction with nonce 5 later, the network rejects it because the nonce no longer matches her account’s state.

Common misconceptions

  • Nonce is just a random number → Correction: A nonce is strictly sequential and deterministic, not random.
  • Nonce is only for transactions → Correction: Nonces also track contract creations and internal calls in the EVM.

Risks & limitations

  • Transaction delays: If a user’s nonce is out of sync (e.g., due to a stuck transaction), subsequent transactions may fail until the nonce is corrected.
  • Front-running: Miners can prioritize transactions with higher nonce values if they detect a sequence, potentially manipulating execution order.
  • Account compromise: If a private key is stolen, the attacker can increment the nonce indefinitely, locking the victim out of their account.

Related terms

About "Nonce (in EVM)" in crypto

Cryptocurrency vocabulary moves faster than any other technical field. New terms appear weekly, old terms quietly change meaning, and most "definitions" online were written by someone trying to sell you something. Qaynaq Labs' crypto glossary aims for the opposite: neutral, accurate, skeptical explainers that include the downside.

This entry covers the technical mechanics, a real-world analogy, where the concept came from, and what could go wrong. Pair it with the related terms to build a working mental model of how the pieces fit together.

Frequently asked

Can I reuse a nonce if a transaction fails?

No. A failed transaction still increments the nonce for the sender’s address. Subsequent transactions must use the next nonce in sequence, regardless of prior failures.

What happens if I send two transactions with the same nonce?

The network will only process the first transaction received with that nonce. The second will be rejected as invalid, even if it has higher gas fees.

Does a contract address have a nonce?

Yes. Contract addresses also have nonces, which track the number of contract creations originating from that address. This is used in the CREATE opcode.

Can I manually set a nonce when sending a transaction?

Yes, most wallets and tools allow you to specify a nonce. However, setting it incorrectly (e.g., too low) can cause transactions to fail or become stuck.