Bitcoin

The blockchain

Here’s where every thread ties together. A blockchain is just a list of blocks, each stamped with the hash of the one before it — like BitTorrent’s pieces, but the shared file is an accounting ledger. Chaining them with hashes makes the whole history tamper-evident: change anything, anywhere, and it shows.

What’s in a block

Each block holds some data (transactions), a nonce (the number miners hunt for), the hash of the previous block, and its own hash — a SHA-256 fingerprint of everything above. Because a block’s hash includes the previous block’s hash, the blocks link into a chain reaching all the way back to the genesis block.

Try to cheat

Below is a live, four-block chain. Every block has been “mined” — its hash starts with 0000, which is valid (green). Now try to tamper: edit the data in any block. Its hash instantly changes, so it no longer starts with 0000 (it turns red), AND every block after it breaks too, because their “previous hash” no longer matches. To make your lie stick, you’d have to re-mine that block and every block after it. Press Mine to feel how much work that takes.

That red cascade is Bitcoin’s security in one picture. Now imagine the chain isn’t four blocks but nearly a million, each protected by more real-world energy than the last, while thousands of honest miners keep extending the true chain faster than you could ever re-mine your fake one. Tampering with old history isn’t just hard — it’s a race against the entire planet that you cannot win.

Why “blockchain”, not just “database”

A normal database can be edited silently by whoever controls it. A blockchain can’t: any change to the past breaks every hash that follows, and every participant is independently checking those hashes. Combine that tamper-evidence with proof-of-work (making new blocks costly) and a global peer-to-peer network (no server to seize), and you have a ledger that is transparent, auditable, and effectively unchangeable — held by everyone, owned by no one.

Now copy it across a network

One tamper-evident chain is powerful, but the real magic is that thousands of people each keep their own copy. Here are three peers — Ana, Ben and Cy — who all hold the same chain, so they’re in consensus. Try tampering with a block on just one peer. Its chain breaks (red), and it falls out of consensus while the other two carry on. Now Re-mine that peer: its chain becomes internally valid again — but it’s a different history, so it’s forked and the network still ignores it. The majority wins.

Want to rewrite history for real? You’d have to out-vote the honest majority — tamper AND re-mine a fake chain on more than half the peers at once (try changing the same block on two of the three, then re-mining both). This is the famous “51% attack”: not a hack, but the brute economic reality that you’d need to own most of the world’s mining power, burning astronomical energy every second, just to keep your lie ahead of everyone else’s honest work. That’s why consensus, not any single copy, is what the network trusts.

You’ve seen how blocks chain into an unchangeable ledger, and how a whole network agrees on it. But what actually sits inside a block? Next, we crack open a single transaction — inputs, outputs and the fee — and you can build one yourself.

Key takeaways

  • The blockchain is like BitTorrent, but the shared file is a tamper-evident ledger replicated across the whole network.
  • Each block’s hash is baked into the next, so altering old history breaks every block after it — the network notices instantly.

Check yourself

Why can’t someone quietly change an old transaction?

The blockchain is best compared to:

Spotted an error or have feedback on this lesson? Suggest a correction ↗

Comments

Powered by Nostr — reply from any Nostr client, and zap the lesson over Lightning.