Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 41 ยท Getting Started

How a Blockchain Works End to End

Follow one transaction through a blockchain network: signing, the mempool, block proposal, validation, confirmations and finality, with a clear diagram.

Last lesson you saw that a blockchain is a chain of blocks, each pointing to the previous one by hash. That is the data structure. This lesson is about the process: what actually happens between "Alice presses send" and "Bob can safely treat the money as his". You will meet the main actors (wallets, nodes, miners or validators) and the stages every transaction passes through.

The details differ between networks, but the overall flow is remarkably similar in Bitcoin, Ethereum and most other public chains. Learning the flow once gives you a map for every later lesson.

The cast

  • Wallet. Software that holds your private key and signs transactions. It does not hold "coins"; the coins exist as entries on the chain, and the key proves you may spend them.
  • Node. A computer running the blockchain software. It keeps a copy of the chain, checks the rules and talks to other nodes. Anyone can usually run one.
  • Block producer. The node that gets to create the next block. In proof of work these are miners; in proof of stake they are validators (see Proof of Work and Mining and Proof of Stake).
  • Light client. A wallet or app that checks only block headers and asks full nodes for proofs about the rest (see Merkle Trees).

The life cycle of a transaction

flowchart TD
    A["1. Alice's wallet creates<br/>and signs a transaction"] --> B["2. Sent to a node"]
    B --> C{"3. Node checks rules:<br/>signature, balance, format"}
    C -- invalid --> X["Rejected and dropped"]
    C -- valid --> D["4. Added to the node's mempool<br/>and gossiped to peers"]
    D --> E["5. A block producer picks<br/>transactions, builds a block"]
    E --> F["6. Block broadcast<br/>to the network"]
    F --> G{"7. Every node validates<br/>the block independently"}
    G -- invalid --> Y["Block rejected"]
    G -- valid --> H["8. Block added to the chain<br/>(1 confirmation)"]
    H --> I["9. More blocks on top:<br/>2, 3, 4... confirmations"]
    I --> J["10. Final: practically<br/>irreversible"]

A transaction is checked at least three times by independent nodes before it becomes part of settled history.

Let's walk through the stages.

1. Create and sign

Alice's wallet builds a message such as "send 5 units to Bob's address, fee 1" and signs it with her private key. The signature proves she authorized exactly this message. Nobody can alter the amount afterwards without invalidating the signature. See Digital Signatures.

2. Broadcast and check

The wallet sends the transaction to a node, which immediately checks the rules. Is the format right? Is the signature valid? Does Alice actually have enough funds, and has she not already spent them? A transaction that fails is dropped on the spot, so bad data costs the network almost nothing.

3. The mempool

Valid but unconfirmed transactions wait in each node's mempool (memory pool). There is no single global mempool: each node has its own, and they overlap because nodes forward new transactions to their peers. This relaying is called gossip (Peer-to-Peer Networking).

Space in a block is limited, so block producers usually prefer transactions that pay higher fees. That is why fees rise when the network is busy.

4. Block proposal

The block producer selects pending transactions, checks them again, and assembles a block: a header (previous block hash, time, a summary hash of the transactions, and consensus-related fields) and a body (the transactions). In proof of work the producer must also find a number that makes the block's hash satisfy a difficulty rule. In proof of stake, a validator is chosen by a stake-weighted lottery and signs the block.

5. Propagation and validation

The new block is broadcast. Every receiving node validates it independently: are all transactions valid, does the header link to the current chain tip, is the proof of work or the validator's signature correct? Nodes never take anyone's word for it. A block that breaks any rule is discarded, no matter who sent it. This is how rules are enforced without a boss.

6. Confirmation

Once a node accepts the block, the transaction is confirmed once. When another valid block is built on top, it has two confirmations, and so on. Each new block makes the transaction harder to undo.

Why would a confirmed transaction ever be undone? Because two producers can create blocks at nearly the same moment, so the network can briefly disagree about the tip. That temporary split is a fork, and the network resolves it by following a rule such as "the chain with the most work wins" (see Longest Chain Rule, Forks and Reorgs). Blocks on the losing branch are dropped, and their transactions return to the mempool. A transaction with one confirmation could, rarely, be affected. With many confirmations it essentially never is.

7. Finality

Finality means a transaction can no longer be reversed. There are two flavors:

Type Idea Example
Probabilistic The chance of reversal shrinks exponentially with each block Bitcoin: people often wait around 6 confirmations for large payments
Deterministic ("economic") After a vote by enough validators, reversing it would require burning a huge amount of stake Ethereum's proof of stake finalizes blocks in epochs

How many confirmations are "enough" depends on the amount at stake. A coffee can be accepted with zero; a house deserves much more.

What nodes actually store

A full node downloads and verifies every block since the start and keeps the current state (who owns what). That is expensive, but it is what makes the system trustless: a full node trusts nobody. Many "nodes" in the network are therefore the real judges. A pruned node keeps only recent data after verifying everything, and a light client trusts block headers and asks for small proofs.

When people say "the blockchain decides", they really mean that thousands of nodes, each following the same published rules, reach the same answer independently.

A bird's-eye view in code

You can simulate the skeleton of this pipeline in a few lines. This stand-in has a mempool, a fee-ordered block builder and a chain, but no networking or consensus yet. Those arrive in later lessons.

Python Mempool to block

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The cheapest transaction, tx1, misses the block and keeps waiting. Real wallets let you raise the fee to jump the queue.

Now watch confirmations grow as blocks are added on top of the one containing a transaction:

Python Counting confirmations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The halving rule is a deliberately simple model: real probabilities depend on the attacker's share of the network, which you will compute in Longest Chain Rule, Forks and Reorgs. The shape is what matters: confidence grows quickly with depth.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where do valid but unconfirmed transactions wait?

    Every node keeps its own mempool of valid pending transactions and relays them to peers until a block includes them.
  2. 2. Why do nodes validate every received block themselves?

    Independent validation is how a network without a boss enforces its rules; a block that breaks them is simply rejected.
  3. 3. A transaction has 6 confirmations. What does this mean?

    A confirmation counts blocks from the one containing the transaction up to the chain tip. Each added block makes a reversal less likely.
  4. 4. When the network is busy, why do fees rise?

    Block space is scarce. Producers favor higher fees, so users bid against each other when demand exceeds capacity.

Summary

  • A transaction is created and signed in a wallet, checked by a node, relayed through gossip and waits in the mempool.
  • A block producer (miner or validator) assembles a block; every node validates it independently before accepting it.
  • Each block added on top gives the transaction another confirmation, making reversal less likely.
  • Temporary forks can occur when two blocks appear at once; the network follows a rule to pick one branch.
  • Finality is probabilistic in some chains and deterministic in others.

Next: History and Landscape: Bitcoin, Ethereum and Beyond, a short tour of how we got here and what kinds of chains exist.