Blockchain Fundamentals: How Distributed Ledgers Work
Blockchain is not just a buzzword — it's a carefully engineered data structure that solves a millennia-old problem: how do two parties that don't trust each other agree on a shared truth?
The Double-Spend Problem
Before Bitcoin, digital cash suffered from a fundamental flaw: a digital file can be copied infinitely. If I send you a digital dollar, what stops me from sending the same dollar to someone else? Banks solve this by being a trusted middleman. Blockchain solves it through mathematics and game theory.
The Data Structure: Blocks and Chains
A block is a container holding:
- A list of transactions (the payload)
- A timestamp
- A reference to the previous block (the chain link)
- A nonce (a number used once, for Proof of Work)
- The Merkle root of all transactions
Block #101
├── Previous Hash: 0x000000a3f7...
├── Timestamp: 2026-03-15T09:41:00Z
├── Nonce: 2,483,921
├── Merkle Root: 0xb94f6f12...
└── Transactions:
├── Alice → Bob: 0.5 BTC
├── Carol → Dave: 1.2 BTC
└── Eve → Frank: 0.1 BTC
The chain forms when each block includes the hash of the previous block. Change one transaction in block #50, and the hash of block #50 changes — which invalidates block #51, which invalidates block #52... all the way to the tip. This is what makes it immutable.
Hash Functions: The Cryptographic Glue
A cryptographic hash function (like SHA-256) maps any input to a fixed-size output:
SHA-256("Hello, World!")
→ dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986d
SHA-256("Hello, World?")
→ 5765b9a0f4b737c561bdb40cfaa51151ca5f4bc1a0a6f6c0b400e9de6bcdad93
Key properties:
- Deterministic: same input always gives same output
- One-way: you can't reverse it to find the input
- Avalanche effect: one bit change completely changes the output
- Collision-resistant: practically impossible to find two inputs with the same hash
Merkle Trees: Efficient Verification
Instead of hashing all transactions sequentially, blockchains use a Merkle tree — a binary tree where:
- Leaf nodes = hashes of individual transactions
- Parent nodes = hash of their two children
- Root = single fingerprint of ALL transactions
Merkle Root
/ \
H(AB) H(CD)
/ \ / \
H(A) H(B) H(C) H(D)
| | | |
TxA TxB TxC TxD
Why this matters: To prove that TxC is in the block, you only need to share H(D), H(AB), and the root — not all transactions. This is the foundation of SPV (Simplified Payment Verification) in light clients.
Consensus: How the Network Agrees
Thousands of nodes hold copies of the ledger. When new transactions arrive, how do they all agree on which block to add next?
Proof of Work (PoW)
Miners compete to find a nonce such that SHA-256(block_header + nonce) < target_difficulty. This requires astronomical computation — and adjusts every 2016 blocks to maintain ~10 min block times.
Why it works: Cheating requires 51% of global hash power. Economically irrational — the cost of attack exceeds the potential gain.
Proof of Stake (PoS)
Validators lock up (stake) capital. The protocol randomly selects validators weighted by stake to propose and attest blocks. Misbehavior results in slashing (losing staked funds).
Ethereum's move to PoS in the 2022 Merge reduced energy consumption by ~99.95%.
The Network Layer: P2P Propagation
When you broadcast a transaction:
- Your node sends it to 8–12 peers
- Each peer validates and forwards to their peers
- The transaction floods the network in ~2–4 seconds globally
- Miners/validators include it in the next block
This gossip protocol ensures every node converges on the same state without any central coordinator.
Finality: When Is a Transaction "Done"?
| Protocol | Finality Type | Time |
|---|---|---|
| Bitcoin | Probabilistic (6 confirmations ≈ 99.99%) | ~60 min |
| Ethereum PoS | Economic finality via checkpoints | ~12 min |
| Solana | Optimistic + Tower BFT | ~400ms |
Further Reading
- Bitcoin Whitepaper — Satoshi Nakamoto (2008)
- Ethereum Yellow Paper — Gavin Wood (2014)
- Mastering Bitcoin — Andreas Antonopoulos
Key Takeaway: Blockchain replaces institutional trust with mathematical proof. Every property — immutability, transparency, censorship-resistance — flows directly from the cryptographic primitives described above.