Skip to content
Learn · Beginner

Understanding transactions and nonces

How nonces enforce ordering, prevent replays, and why one stuck transaction can block your whole wallet.

Beginner
8 min read

What a nonce is

Each EOA maintains a counter starting at 0. A transaction is only valid if its nonce matches the account's next expected value. After inclusion, the nonce increments. This prevents replaying the same signed transaction twice and enforces FIFO ordering per account.

  • First tx from an address uses nonce 0, then 1, then 2, and so on.
  • Contracts do not have their own nonce for sending — they respond to incoming calls.
  • Chain ID (EIP-155) prevents cross-chain replay of the same signature.

Stuck and dropped transactions

If a low-fee transaction sits in the mempool, later transactions with higher nonces queue behind it — they cannot skip ahead. Fix: resubmit the same nonce with higher maxFeePerGas and maxPriorityFeePerGas (replacement). Wallets label this 'speed up' or 'cancel' (cancel sends 0 ETH to yourself with same nonce).

  • Same nonce + higher fee replaces the pending tx if validators prefer the new one.
  • Eventually mempools drop ancient pending txs — nonce may appear 'stuck' then suddenly jump.
  • Always check pending nonce vs latest nonce on Etherscan.

Contract address determinism

Standard CREATE deployment address = keccak256(rlp([sender, nonce]))[12:]. Your first contract from an EOA is predictable if you know the deployer address and nonce. CREATE2 makes addresses independent of nonce — depends on deployer, salt, and init code hash.

  • Factories often use CREATE2 for counterfactual wallets and known pool addresses.
  • Nonce gaps do not affect CREATE2 — only CREATE addresses.
  • Testnet and mainnet nonces are independent per chain.

Batching and account abstraction

EOAs send one transaction per signature. Smart contract wallets (ERC-4337) can batch multiple actions in one UserOperation executed via a bundler. Nonce logic moves to the EntryPoint per account — different rules, same conceptual need for replay protection.

  • ERC-4337 accounts use a keyed nonce sequence managed by the EntryPoint contract.
  • Batching reduces per-action overhead of 21k base gas.
  • Session keys can sign scoped actions without bumping the main EOA nonce.

Debugging nonce errors

Common errors: 'nonce too low' (you reused an old nonce), 'nonce too high' (gap — earlier tx still pending), 'replacement transaction underpriced' (fee bump insufficient). Wallets usually sync nonce from RPC — manual nonce editing is for advanced recovery only.

  • Hardware wallet + multiple software fronts can desync — refresh account in wallet.
  • Automated bots must track on-chain nonce after every send.
  • eth_getTransactionCount with 'pending' includes mempool txs.

Security angle

Nonces are not secret — they are public on-chain. Security comes from signature unforgeability, not nonce hiding. However, watching nonce increments on a multisig admin can tip off attackers that an upgrade tx is queued — combine with private submission for sensitive admin operations.

  • Timelock delays give community time to react to malicious proposals.
  • Never share signed unsigned-structure txs — some schemes leak partial signatures.
  • Chain ID in the signature domain separator prevents cross-chain replays.