0Pricing
Web3 & DApp Development Fundamentals · Lektion

Nonces und Reihenfolge

Transaktionssequenzierung

Nonces und Reihenfolge ist eine kostenlose Web3 & DApp Development Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web3 & DApp Development Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Order Matters

Imagine sending two transactions: first deposit, then withdraw. If they execute out of order, the withdrawal could fail.

The nonce guarantees your transactions run in the exact order you intend.

What Is an Account Nonce?

An account nonce is a counter tracking how many transactions an account has sent. It starts at 0 and increases by 1 with each confirmed transaction.

Note: this is different from the mining nonce in Proof of Work.

Account history:
  tx with nonce 0  (1st tx)
  tx with nonce 1  (2nd tx)
  tx with nonce 2  (3rd tx)
  next expected nonce: 3

Enforcing Sequence

The network only executes a transaction whose nonce matches the account's next expected value.

A transaction with nonce 5 will not run until nonces 0 through 4 have been processed.

Preventing Replay Attacks

Because each nonce is used once, an attacker cannot replay (resubmit) an old signed transaction.

The network already processed that nonce, so the duplicate is rejected automatically.

Stuck Transactions

If a transaction with a given nonce gets stuck (too low a fee), all later nonces are blocked behind it.

Nothing can proceed until that gap is filled, because nonces must be sequential.

pending:
  nonce 4  (stuck, low fee)
  nonce 5  (waiting...)
  nonce 6  (waiting...)
-> nonce 4 must clear first

Replacing a Transaction

To unstick things, you can replace a pending transaction by resubmitting it with the same nonce and a higher fee.

This is often called speed-up or cancel — validators take the higher-paying version.

Gaps in Nonces

A nonce gap happens when you submit nonce 7 while nonce 6 is missing.

The transaction sits unprocessed until the gap is filled, since the network requires a continuous sequence.

Ordering Within a Block

The nonce orders transactions from one account, but ordering between different accounts within a block is decided by the validator.

Validators typically order by fee, which is why ordering can be exploited (see MEV).

MEV and Ordering

Because validators choose transaction order, they can profit by reordering, inserting, or censoring transactions. This is called Maximal Extractable Value (MEV).

It shows that ordering is economically valuable, not just technical bookkeeping.

Checking the Next Nonce

Wallets query the network for the next nonce using eth_getTransactionCount.

This returns the count of confirmed transactions, which equals the next nonce to use.

count = eth_getTransactionCount(
    myAddress, "pending")
// count is the next nonce to use

Putting It Together

The account nonce sequences your transactions, prevents replays, and must be continuous.

Validators decide cross-account ordering, which introduces fee-based prioritization and MEV.

Quick Check

Test your nonce knowledge.

Recap: Nonces and Ordering

You learned that:

  • The nonce counts an account's transactions and enforces order
  • It prevents replay attacks
  • A stuck low nonce blocks later ones until replaced
  • Validators decide cross-account ordering, enabling MEV

Next course: EVM fundamentals.

Häufig gestellte Fragen

Ist die Lektion „Nonces und Reihenfolge“ kostenlos?

Ja — der vollständige Text von „Nonces und Reihenfolge“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web3 & DApp Development Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Nonces und Reihenfolge“?

Transaktionssequenzierung Du übst Web3 & DApp Development Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Web3 & DApp Development Fundamentals zu starten?

Keine Vorkenntnisse erforderlich. Web3 & DApp Development Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Nonces und Reihenfolge“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Web3 & DApp Development Fundamentals-Lektion Code schreiben und ausführen?

Ja. Jede Web3 & DApp Development Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Was ist Gas?
  2. Transaktionslebenszyklus
  3. Gas-Limits und Gebühren
  4. Nonces und Reihenfolge
← Zurück zu Web3 & DApp Development Fundamentals