⚙ How Blockchain Works

Understanding the inner mechanics of blockchain technology—from blocks and hashes to consensus mechanisms and nodes.




📦 What is a Block?

A block is a container that holds a batch of verified transactions. Think of each block as a page in a ledger book. Once the page is full, it gets permanently added to the book.

What’s Inside a Block?

Every block contains several pieces of important data:

Anatomy of a Block
Component Description Example
Block Number The position of the block in the chain Block #782,451
Timestamp When the block was created 2025-01-15 14:23:07 UTC
Transaction Data List of transactions in this block Alice sends 0.5 BTC to Bob
Previous Hash Hash of the previous block (creates the chain!) 00000a3b7c8d...
Current Hash This block’s unique fingerprint 00000f9e2a1b...
Nonce A number miners adjust to find a valid hash 2,874,192
Merkle Root A hash summary of all transactions in the block 8a4c2e7f...

Diagram showing the internal components of a single blockchain block
Figure: The anatomy of a blockchain block
💡 What is a Merkle Root?

A Merkle Root (named after Ralph Merkle) is created by hashing pairs of transactions together repeatedly until only one hash remains. It’s like a summary fingerprint of all the transactions in a block. If even one transaction changes, the Merkle Root completely changes—making tampering immediately detectable.



🔏 Hashing Explained

A hash is a fixed-length string of characters generated by a hash function. It acts as a digital fingerprint for any piece of data.

Properties of a Good Hash Function

  1. Deterministic – Same input always produces the same output
  2. Fast to compute – Generating a hash is quick
  3. One-way – You can’t reverse-engineer the input from the hash
  4. Avalanche effect – A tiny change in input creates a completely different hash
  5. Collision resistant – Nearly impossible for two different inputs to produce the same hash

Hash Examples (SHA-256)

Bitcoin uses the SHA-256 hash function. Notice how a tiny change produces a completely different result:

SHA-256 Hash Demonstration
Input SHA-256 Hash Output
Hello 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
hello 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Hello! 334d016f755cd6dc58c53a86e183882f8ec14f52fb05345887c8a5edd42c87b7

Notice: Just changing H to h (or adding a !) produces a completely different 64-character hash! This is the avalanche effect.

🧪 Try It Yourself!

You can generate SHA-256 hashes online at sites like SHA-256 Online Tool (opens in a new tab). Try hashing your own name!



🔗 How Blocks Form a Chain

Each block stores the hash of the previous block. This creates a linked chain going all the way back to the Genesis Block (Block 0).

Three blocks linked together, each storing the previous block's hash
Figure: Blocks linked together via hash pointers

What Happens if Someone Tries to Tamper?

Let’s say a bad actor tries to change a transaction in Block #3:

  1. The data in Block #3 changes
  2. Block #3’s hash completely changes (avalanche effect!)
  3. Block #4 stores Block #3’s original hash—now there’s a mismatch
  4. Block #4 becomes invalid, and so does Block #5, #6, and every block after it
  5. The network rejects the tampered chain

"To alter a single block, you’d have to recalculate every block that comes after it—and do it faster than the entire rest of the network. That’s practically impossible."

This is what makes blockchain immutable—once data is recorded, it’s there permanently.



🖥 Nodes & The Network

A node is any computer that participates in the blockchain network. Nodes work together to maintain and validate the blockchain.

Types of Nodes

💻 Full Node
Stores a complete copy of the entire blockchain. Validates all transactions and blocks. Acts as the backbone of the network.
⚡ Light Node (SPV)
Stores only block headers, not full transaction data. Relies on full nodes for verification. Uses less storage and bandwidth.
⛏ Mining Node
Competes to create new blocks by solving mathematical puzzles. Receives block rewards (new coins) when successful.
📡 Archive Node
Stores everything a full node does, plus historical state data. Used by block explorers and analytics services.
Multiple nodes connected in a decentralized peer-to-peer network


🤝 Consensus Mechanisms

Since there’s no central authority, the network needs a way to agree on which transactions are valid. This is called a consensus mechanism.

Major Consensus Mechanisms

Consensus Mechanisms Compared
Mechanism How It Works Used By Energy Use Speed
Proof of Work (PoW) Miners solve complex math puzzles Bitcoin, Litecoin Very High ⚠ Slow (~10 min/block for Bitcoin)
Proof of Stake (PoS) Validators stake coins as collateral Ethereum, Cardano Very Low ✅ Fast (~12 sec/block for Ethereum)
Delegated Proof of Stake (DPoS) Token holders vote for delegates to validate EOS, Tron Low Very Fast
Proof of Authority (PoA) Pre-approved validators based on identity VeChain Very Low Very Fast

💡 PoW vs PoS: An Analogy

Proof of Work is like a race: thousands of miners compete to solve a puzzle first. Only the winner gets the reward. It requires enormous computing power.

Proof of Stake is like a lottery: validators are chosen randomly, but those with more coins staked have a higher chance. Much less energy is wasted.



🔄 The Life of a Transaction

Here’s what happens step-by-step when Alice sends 1 BTC to Bob:

  1. Alice initiates the transaction
    She uses her wallet to create a transaction: "Send 1 BTC to Bob’s address."

  2. Transaction is signed
    Alice’s private key digitally signs the transaction, proving she authorized it.

  3. Broadcast to the network
    The signed transaction is sent to the blockchain network and enters the mempool (a waiting area for unconfirmed transactions).

  4. Validation by nodes
    Nodes verify that Alice has enough BTC and that the signature is valid.

  5. Included in a block
    A miner (or validator) bundles the transaction with others into a new block.

  6. Consensus is reached
    The network agrees that the new block is valid.

  7. Block is added to the chain
    The new block becomes a permanent part of the blockchain.

  8. Bob receives the BTC
    Bob’s wallet reflects the new balance. The transaction is complete! ✅
Flowchart showing the 8 steps of a blockchain transaction
Figure: The lifecycle of a blockchain transaction


🛡 Why Blockchain is Secure

Blockchain achieves security through multiple layers:

Security Layers of Blockchain
Layer How It Protects
Cryptographic Hashing Any change to data changes the hash, making tampering immediately visible
Chain Linking Changing one block invalidates all subsequent blocks
Decentralization No single point of failure—thousands of copies exist worldwide
Consensus Mechanism Majority of the network must agree on changes
Digital Signatures Only the owner of a private key can authorize transactions

⚠ What is a 51% Attack?

A 51% attack occurs when a single entity gains control of more than 50% of the network’s computing power (or staked coins). They could theoretically reverse transactions or double-spend. However, for large networks like Bitcoin, this would require billions of dollars in hardware and electricity, making it practically impossible.



← Previous: History  |  Next: Cryptocurrencies →