Skip to content
CryptoAcademy logo CryptoAcademy
Menu
Lesson Beginner

Nodes and Consensus: How Strangers Agree on the Truth

Imagine a group of strangers who do not trust each other and have no boss. They all need to agree on one shared list of who owns what — and they need to agree even when some of them lie or cheat. That is the core problem blockchain solves. In this lesson we will look at the two ingredients that make this possible: nodes, the computers that keep copies of the ledger, and consensus mechanisms, the rules they follow to agree on the truth.

In this lesson

  • Explain what a node does and why many copies of the ledger matter
  • Describe the double-spend problem in simple terms
  • Compare proof of work and proof of stake at a high level
  • Recognize how strangers reach agreement without a central authority

The Agreement Problem

Think about a shared Google Doc. It works because one company, Google, controls the official version. If two people edit at the same time, Google decides what the final document looks like.

Now imagine there is no Google. Anyone can edit, anyone can lie, and no one is in charge. How do you decide which version is real?

This is the problem blockchain was invented to solve. Instead of one central authority, thousands of computers — called nodes — each keep a copy of the same ledger. They constantly talk to each other and follow a set of rules called a consensus mechanism to agree on which transactions are valid and in what order. When enough nodes agree, the ledger updates everywhere.

What Is a Node?

A node is a computer that runs blockchain software. Depending on the network, a node may do several jobs:

  • Store a copy of the blockchain (the full ledger).
  • Verify new transactions against the rules of the network.
  • Relay valid transactions and blocks to other nodes (gossip).
  • Vote or mine — in some networks, nodes also help create new blocks.

You do not need a supercomputer. A modest laptop can run a Bitcoin or Ethereum node. The important idea is that many independent copies exist. If one node goes offline, lies, or is hacked, the others keep the true ledger alive.

Example · Example: A Ledger With 10,000 Copies

Suppose Alice tries to bribe one node operator to change her balance from 1 BTC to 100 BTC. That node now shows a fake ledger. But the other 9,999 nodes still show 1 BTC. When the dishonest node broadcasts its fake block, the others check it against the rules (signatures, balances, proof of work or stake) and reject it. Alice's lie dies at the network edge.

This is why we say the blockchain is tamper-evident: changing history would require convincing the majority of independent nodes, not just one.

Nodes Holding the Same Chain
Blocks are linked by hashes; editing one block breaks every link after it Block n-1 hash 9c1a…f4 valid Block n hash 0007…b2 edited by an attacker Block n+1 hash 41de…09 valid Block n+2 hash 77b0…aa valid prev hash ✗ attacker edits a value → block hash changes The integrity cascade 1. Editing a transaction in block n changes its Merkle root → changes the header hash. 2. Block n+1 stores the old hash → the link is broken and the chain from n+1 on is invalid. 3. To stay valid the attacker must re-mine every later block — faster than the network grows them.
Each node keeps a copy of the same chain of blocks. New blocks are broadcast and independently verified by every node.

The Double-Spend Problem

Digital files are easy to copy. If money were just a file, Alice could send the same 1 BTC to Bob and to Carol at the same time. Both would think they were paid. That is the double-spend problem.

With physical cash this is impossible — you can only hand over the same coin once. With digital money, you need a way to make sure the same unit is spent only once. A central bank solves this by keeping a single official ledger. Blockchain solves it by having all nodes agree on the order of transactions.

If Alice sends 1 BTC to Bob at 10:00 and tries to send the same 1 BTC to Carol at 10:01, the consensus rules say: the first valid transaction that gets included in a block wins. The second is rejected because Alice no longer has that BTC. Everyone sees the same history, so everyone reaches the same conclusion.

Watch Out for 'Confirmed' vs 'Unconfirmed'

A transaction is not final the moment it is broadcast. It sits in a mempool (a waiting room) until a miner or validator includes it in a block. Until then, a sender could try to replace it. Most wallets and exchanges wait for several confirmations (blocks on top) before treating a payment as settled.

How Consensus Works: Two Big Families

There are many consensus algorithms, but most fall into two broad families: proof of work (PoW) and proof of stake (PoS). Both aim to make cheating expensive and honesty profitable. The key question each one answers is: Who gets to add the next block, and why should we trust them?

Proof of Work (PoW)
  • Miners compete to solve a hard math puzzle
  • Uses large amounts of electricity
  • Reward goes to the first miner to find a valid block
  • Cheating requires controlling >50% of computing power
  • Examples: Bitcoin, Litecoin
Proof of Stake (PoS)
  • Validators are chosen based on how much crypto they lock up (stake)
  • Uses very little energy
  • Reward goes to the chosen validator (and sometimes to attestors)
  • Cheating requires controlling >50% of staked value (and you lose your stake)
  • Examples: Ethereum (since 2022), Cardano, Solana

Miner's chance in proof of work

P(win) \approx \frac{h_i}{H}

A miner with hash rate \( h_i \) wins the next block with probability roughly equal to their share of the network's total hash rate \( H \). More computing power means a higher chance — but also a higher electricity bill.

Proof of Work in Plain English

In PoW, miners race to find a number called a nonce such that the hash of the block header starts with a certain number of zeros. There is no shortcut — you just try billions of guesses per second. The first miner to find a valid nonce broadcasts the block, and the other nodes verify it in milliseconds.

The cost of electricity is the point. To rewrite history, an attacker would need to redo all that work faster than the honest network. On Bitcoin, that would require more computing power than the entire honest network combined — practically impossible.

simple_pow.py python
import hashlib

def mine(block_data: str, difficulty: int) -> tuple[int, str]:
    """Find a nonce so that SHA-256(block_data + nonce) starts with 'difficulty' zeros."""
    target = '0' * difficulty
    nonce = 0
    while True:
        candidate = f"{block_data}{nonce}".encode()
        digest = hashlib.sha256(candidate).hexdigest()
        if digest.startswith(target):
            return nonce, digest
        nonce += 1

# Try it: increase difficulty and watch how much longer it takes.
nonce, digest = mine("Alice pays Bob 1 BTC", difficulty=4)
print(f"nonce={nonce}")
print(f"hash ={digest}")

Try Mining a Block Yourself

Change the difficulty and watch how many nonce attempts are needed to find a valid hash. Notice how a small increase in difficulty makes the search dramatically harder.

Try it yourself

Proof of Stake in Plain English

PoS replaces computing power with economic weight. Validators lock up (stake) coins as collateral. The protocol randomly selects a validator to propose the next block, weighted by how much they have staked. Other validators then attest that the block is valid.

If a validator tries to cheat — for example, by signing two conflicting blocks — they can be slashed: part of their stake is destroyed and they are kicked out. Honest validators earn rewards. The security argument is simple: attacking the network costs you your own money, and you have a lot of it on the line.

Validators Staking and Attesting
In Proof of Stake, validators are selected in proportion to their stake, attest to proposals and finalize blocks 1 — VALIDATORS STAKE CAPITAL V1 32 ETH V2 64 ETH proposer ★ V3 32 ETH V4 16 ETH V5 48 ETH Circle size = stake. Selection is weighted random per slot. 2 — PROPOSE, ATTEST, FINALIZE Propose Leader builds a block Attest Validators sign it 2/3 quorum Enough weight agrees Finalized Cannot be reverted No energy race — but skin in the game Validators caught lying get slashed: part of their stake is destroyed. Attacks cost capital instead of electricity.
In proof of stake, validators lock coins as collateral. The protocol picks one to propose a block, and others attest to its validity.

Why Multiple Nodes Matter

It is tempting to think 'one big powerful node would be simpler.' But the whole point is redundancy and independence:

  • Censorship resistance: no single node can block your transaction.
  • Fault tolerance: if some nodes crash, the network keeps running.
  • Verifiability: anyone can download the ledger and check the rules were followed.
  • No single point of failure: hacking one node changes nothing.

This is what people mean by decentralization. It is not magic — it is thousands of independent copies plus a shared rulebook.

Quick Vocabulary

  • Node: a computer running the blockchain software.
  • Consensus: the process by which nodes agree on the canonical chain.
  • Mempool: the waiting area for unconfirmed transactions.
  • Confirmation: a block added on top of a transaction's block.
  • Fork: when two valid blocks appear at the same height; the network eventually picks the heavier/longer chain.
Do I need to trust the miners or validators?

<p>No. You trust the rules and the fact that cheating is economically irrational. Anyone can run a node and verify every block themselves — that is the strongest form of trust: verification.</p>

Is proof of stake less secure than proof of work?

<p>They secure the network in different ways. PoW uses physical resources (electricity and hardware); PoS uses economic resources (locked capital that can be slashed). Both make a 51% attack extremely expensive, but the cost is measured in energy in one case and in capital at risk in the other.</p>

What happens if two miners find a block at the same time?

<p>The network temporarily has two competing chains. Nodes follow the rule 'the longest (or heaviest) valid chain wins.' Miners build on whichever they saw first, and within a few blocks one chain becomes dominant. The other block is discarded — this is called an orphan or stale block.</p>

How many confirmations are enough?

<p>It depends on the value at stake. For small purchases, 1–2 confirmations is usually fine. For large transfers, exchanges often wait for 6 confirmations on Bitcoin or 12+ on Ethereum. The more confirmations, the more expensive it becomes to rewrite history.</p>

Check your understanding

Practice · server-graded
  • Which statement best describes the difference between proof of work and proof of stake?

    1 pt

Share this page

Send this link to a friend, or scan the QR code to open it on your phone.