Skip to content
Blockchain Explained — Complete Beginner's Guide

Blockchain Explained — Complete Beginner's Guide

DodaTech Updated Jun 6, 2026 12 min read

Blockchain is a decentralized digital ledger technology that records transactions across multiple computers so that no single party can alter the records without consensus from the network.

What You’ll Learn

By the end of this tutorial, you’ll understand how blocks connect to form a chain, why decentralization matters, the difference between proof-of-work and proof-of-stake, and you’ll build a simple blockchain in Python.

Why Blockchain Basics Matters

Blockchain powers cryptocurrencies like Bitcoin and Ethereum, but its applications go far beyond money — supply chain tracking, digital identity, voting systems, and secure document verification all use blockchain principles. At DodaTech, we explore blockchain for secure software update verification and decentralized logging.

Blockchain Learning Path

    flowchart LR
  A[Blockchain Basics] --> B[Bitcoin]
  B --> C[Ethereum]
  C --> D[Smart Contracts]
  A --> E{You Are Here}
  style E fill:#f90,color:#fff
  
Prerequisites: No prior blockchain knowledge needed. Basic Python programming helps for the demo. Familiarity with Cryptography concepts (hashing) is useful but not required.

What Is Blockchain? (The “Why” First)

Think of a blockchain like a public notebook that everyone in a village shares. Every time someone trades something, everyone writes it down in their notebook. If someone tries to change a past entry, everyone else’s notebooks would disagree — so the change is rejected.

Before blockchain, if Alice wanted to send money to Bob, she needed a trusted third party — a bank, PayPal, or Venmo — to verify the transaction. The bank keeps the ledger, and everyone trusts the bank.

Blockchain removes the middleman. Instead of one central ledger, everyone keeps a copy. When a transaction happens, the network verifies it collectively. This is decentralization.

Key Properties of Blockchain

  1. Decentralized: No single person or organization controls it
  2. Immutable: Once data is recorded, it cannot be changed
  3. Transparent: Anyone can view the entire transaction history
  4. Secure: Cryptography ensures data integrity and authenticity

How Blocks Work

A block is like a page in that public notebook. Each block contains:

Block #1
┌─────────────────────────┐
│ Block Header:           │
│   - Previous Hash: 0000 │
│   - Timestamp: 09:00    │
│   - Nonce: 28374        │
│   - Merkle Root: a1b2   │
├─────────────────────────┤
│ Transactions:           │
│   Alice → Bob: 10 BTC   │
│   Charlie → Dave: 5 BTC │
│   (hundreds more...)    │
├─────────────────────────┤
│ Block Hash: 7f3a...     │
└─────────────────────────┘

Each block contains:

  • Previous block’s hash: Links this block to the one before it
  • Timestamp: When the block was created
  • Transactions: The data being recorded
  • Nonce: A number used in mining (we’ll explain this)
  • Block hash: The block’s unique fingerprint

How Blocks Chain Together

Here’s the magic: each block contains the hash of the previous block. This creates an unbreakable chain.

    flowchart LR
  A[Block #0<br/>Hash: 0000<br/>Prev: None] --> B[Block #1<br/>Hash: 7f3a<br/>Prev: 0000]
  B --> C[Block #2<br/>Hash: b1c2<br/>Prev: 7f3a]
  C --> D[Block #3<br/>Hash: d4e5<br/>Prev: b1c2]
  

If an attacker tries to modify Block #1, its hash changes. But Block #2 still references the old hash — so the chain breaks. To fix it, the attacker would need to recompute Block #2, Block #3, and every subsequent block. On a large blockchain like Bitcoin, this would require more computing power than the rest of the network combined.

What Is a Hash and Why Does It Matter?

A hash is a fixed-length fingerprint of data. In Cryptography terms, it’s a one-way function:

import hashlib

def calculate_hash(data):
    return hashlib.sha256(data.encode()).hexdigest()

# Each block's data produces a unique hash
block1_data = "Block #1: Alice sends Bob 10 BTC"
block2_data = "Block #2: Charlie sends Dave 5 BTC"

print(f"Block 1 hash: {calculate_hash(block1_data)}")
print(f"Block 2 hash: {calculate_hash(block2_data)}")

Output:

Block 1 hash: a1b2c3d4e5f6...
Block 2 hash: 7f8a9b0c1d2e...

Even changing one character in the block data completely changes the hash. This is what makes the chain tamper-evident.

Decentralization — No Single Point of Failure

In a traditional database, a central server holds all the data. If that server is hacked or goes down, the entire system is compromised.

In a blockchain, every participant (node) has a complete copy of the ledger. If one node goes offline, thousands of others still have the data.

Node Types

Node TypeWhat It DoesExample
Full nodeStores the entire blockchain, validates all transactionsBitcoin Core
Light nodeStores only block headers, relies on full nodes for detailsMobile wallets
Mining nodeFull node + creates new blocks via consensusBitcoin miners

Consensus Mechanisms — How Everyone Agrees

Consensus is how blockchain participants agree on what’s true. Without a central authority, they need a voting system.

Proof of Work (PoW)

How it works: Miners compete to solve a complex math puzzle. The first to solve it gets to add the next block and earns a reward.

Think of it like a lottery where buying more tickets increases your odds. Miners with more computing power have a higher chance of winning.

# Simple Proof of Work simulation
import hashlib
import time

def proof_of_work(block_data, difficulty=4):
    """Find a nonce that produces a hash starting with 'difficulty' zeros."""
    nonce = 0
    prefix = "0" * difficulty
    start_time = time.time()

    while True:
        text = f"{block_data}{nonce}"
        hash_result = hashlib.sha256(text.encode()).hexdigest()
        if hash_result.startswith(prefix):
            elapsed = time.time() - start_time
            return nonce, hash_result, elapsed
        nonce += 1

# Try it with difficulty 4 (Bitcoin uses difficulty ~ 70+)
data = "Block #1: Transactions..."
nonce, hash_val, elapsed = proof_of_work(data, 4)
print(f"Nonce found: {nonce}")
print(f"Hash: {hash_val}")
print(f"Time: {elapsed:.2f} seconds")

Expected output:

Nonce found: 45862
Hash: 0000a1b2c3d4e5f6...
Time: 0.03 seconds

Why this matters for security: To alter a past block, an attacker would need to redo the proof of work for that block AND all subsequent blocks — faster than the rest of the network creates new ones. This is computationally infeasible on large blockchains.

Downside of PoW: It consumes enormous amounts of electricity. Bitcoin’s annual energy consumption rivals that of entire countries.

Proof of Stake (PoS)

How it works: Validators are chosen to create new blocks based on how many coins they “stake” (lock up as collateral). The more you stake, the more likely you are chosen.

Think of it like a raffle where you get tickets based on your deposit. You deposit 32 ETH, you get “tickets” proportional to your stake. If you validate honestly, you earn rewards. If you cheat, your stake is “slashed” (taken away).

Why PoS is better:

  • Uses 99.9% less energy than PoW
  • Faster block times
  • More accessible (no expensive mining hardware)
  • Economic security (attackers lose their stake)
AspectProof of WorkProof of Stake
Energy useVery highVery low
HardwareSpecialized ASICsRegular computer
Entry barrierHigh (expensive hardware)Lower (stake coins)
Security modelComputing powerEconomic stake
ExampleBitcoin, LitecoinEthereum 2.0, Cardano

Simple Python Blockchain Demo

Let’s build a minimal blockchain to see how everything fits together:

# simple_blockchain.py
import hashlib
import json
from datetime import datetime

class Block:
    def __init__(self, index, transactions, previous_hash, nonce=0):
        self.index = index
        self.timestamp = datetime.now().isoformat()
        self.transactions = transactions
        self.previous_hash = previous_hash
        self.nonce = nonce
        self.hash = self.calculate_hash()

    def calculate_hash(self):
        """Create SHA-256 hash of the block's contents."""
        data = json.dumps({
            "index": self.index,
            "timestamp": self.timestamp,
            "transactions": self.transactions,
            "previous_hash": self.previous_hash,
            "nonce": self.nonce
        }, sort_keys=True)
        return hashlib.sha256(data.encode()).hexdigest()

    def mine_block(self, difficulty):
        """Proof of work: find a hash with 'difficulty' leading zeros."""
        prefix = "0" * difficulty
        while not self.hash.startswith(prefix):
            self.nonce += 1
            self.hash = self.calculate_hash()
        print(f"Block #{self.index} mined! Nonce: {self.nonce}, Hash: {self.hash[:16]}...")

class Blockchain:
    def __init__(self, difficulty=4):
        self.chain = []
        self.difficulty = difficulty
        self.pending_transactions = []
        # Create the genesis block (first block)
        self.create_genesis_block()

    def create_genesis_block(self):
        genesis = Block(0, ["Genesis Block"], "0" * 64)
        genesis.mine_block(self.difficulty)
        self.chain.append(genesis)

    def get_latest_block(self):
        return self.chain[-1]

    def add_transaction(self, transaction):
        self.pending_transactions.append(transaction)

    def mine_pending_transactions(self):
        if not self.pending_transactions:
            print("No transactions to mine.")
            return
        new_block = Block(
            len(self.chain),
            self.pending_transactions[:],
            self.get_latest_block().hash
        )
        new_block.mine_block(self.difficulty)
        self.chain.append(new_block)
        self.pending_transactions = []

    def is_chain_valid(self):
        """Verify the entire blockchain integrity."""
        for i in range(1, len(self.chain)):
            current = self.chain[i]
            previous = self.chain[i - 1]

            # Check that current block's hash is correct
            if current.hash != current.calculate_hash():
                print(f"Block #{i}: Hash invalid!")
                return False

            # Check that current block points to correct previous hash
            if current.previous_hash != previous.hash:
                print(f"Block #{i}: Previous hash mismatch!")
                return False

        return True

    def print_chain(self):
        for block in self.chain:
            print(f"\nBlock #{block.index}")
            print(f"  Timestamp: {block.timestamp}")
            print(f"  Transactions: {block.transactions}")
            print(f"  Previous Hash: {block.previous_hash[:16]}...")
            print(f"  Hash: {block.hash[:16]}...")
            print(f"  Nonce: {block.nonce}")

# Run the blockchain
my_blockchain = Blockchain(difficulty=4)
my_blockchain.add_transaction("Alice sends 10 BTC to Bob")
my_blockchain.add_transaction("Charlie sends 5 BTC to Dave")
my_blockchain.mine_pending_transactions()

my_blockchain.add_transaction("Eve sends 2 BTC to Frank")
my_blockchain.mine_pending_transactions()

my_blockchain.print_chain()

# Verify integrity
print(f"\nChain valid: {my_blockchain.is_chain_valid()}")

# Try tampering (simulate an attack)
print("\n--- ATTACK: Modifying Block #1 ---")
my_blockchain.chain[1].transactions = ["Alice sends 1000 BTC to Eve"]
print(f"Chain valid after tampering: {my_blockchain.is_chain_valid()}")

Expected output:

Block #0 mined! Nonce: 34981, Hash: 0000a1b2...
Block #1 mined! Nonce: 52763, Hash: 0000c3d4...
Block #2 mined! Nonce: 19284, Hash: 0000e5f6...

Block #0
  Timestamp: 2026-06-06T10:00:00
  Transactions: ['Genesis Block']
  Previous Hash: 0000000000000000...
  Hash: 0000a1b2c3d4...
  Nonce: 34981

Block #1
  Timestamp: 2026-06-06T10:00:05
  Transactions: ['Alice sends 10 BTC to Bob', 'Charlie sends 5 BTC to Dave']
  Previous Hash: 0000a1b2c3d4...
  Hash: 0000c3d4e5f6...
  Nonce: 52763

Block #2
  Timestamp: 2026-06-06T10:00:10
  Transactions: ['Eve sends 2 BTC to Frank']
  Previous Hash: 0000c3d4e5f6...
  Hash: 0000e5f6a7b8...
  Nonce: 19284

Chain valid: True

--- ATTACK: Modifying Block #1 ---
Block #1: Hash invalid!
Chain valid after tampering: False

This demo illustrates the core blockchain concepts:

  1. Blocks contain data and link to the previous block via its hash
  2. Mining requires finding a nonce that produces a hash with leading zeros
  3. Tampering breaks the chain because the modified block’s hash changes but the next block still references the old hash
  4. Validation catches any attempt to alter past data

Common Blockchain Mistakes

1. Confusing Blockchain with Cryptocurrency

Blockchain is the technology; cryptocurrency is one application. Think of blockchain as the operating system and Bitcoin as an app running on it.

2. Thinking Blockchain Is 100% Anonymous

Most blockchains are pseudonymous, not anonymous. All transactions are public and traceable. Sophisticated analysis can often link addresses to real identities.

3. Believing Blockchain Can’t Be Hacked

The blockchain itself is secure, but applications built on top (exchanges, wallets, smart contracts) can be hacked. Most crypto thefts target exchanges, not the blockchain.

4. Not Understanding Private Keys

Your private key is your blockchain identity. Lose it, and you lose access to your assets forever. There’s no “reset password” on a blockchain.

5. Assuming All Blockchains Are the Same

Bitcoin is a simple ledger. Ethereum adds smart contracts. Other blockchains prioritize speed, privacy, or specific use cases. Each has different trade-offs.

6. Ignoring Scalability Issues

Bitcoin processes ~7 transactions per second. Visa processes ~24,000. Scalability is an active area of research with solutions like the Lightning Network and sharding.

7. Forgetting About Governance

Blockchains still need human decisions — protocol upgrades, bug fixes, dispute resolution. Different blockchains have different governance models (on-chain voting, developer consensus, foundation control).

Common Mistakes Beginners Make

1. Skipping the Fundamentals

Many beginners jump straight to advanced topics without mastering the basics. Take time to understand the core concepts before moving on.

2. Not Practicing Enough

Reading tutorials without writing code leads to shallow understanding. Code along with every example and experiment on your own.

3. Ignoring Error Messages

Error messages tell you exactly what went wrong. Read them carefully — they usually point to the line and type of issue.

4. Copy-Pasting Without Understanding

It’s tempting to copy code from tutorials, but typing it yourself and understanding each line builds real skill.

5. Giving Up Too Early

Every developer hits frustrating bugs. Take breaks, ask for help, and remember that struggling is part of learning.

Practice Questions

1. What makes a blockchain tamper-evident?

Each block contains the hash of the previous block. Changing any block changes its hash, which breaks the chain. The network would immediately detect the inconsistency.

2. What’s the difference between proof-of-work and proof-of-stake?

PoW requires miners to solve computational puzzles using energy. PoS selects validators based on the amount of cryptocurrency they stake as collateral. PoS is much more energy-efficient.

3. What is a genesis block?

The first block in a blockchain. It has no previous block (previous hash is typically all zeros). Every blockchain starts with a genesis block.

4. Why is decentralization important?

No single point of failure or control. No central authority can censor transactions, freeze accounts, or change the rules unilaterally. The network continues functioning even if many nodes go offline.

5. Challenge: Modify the Python blockchain to use proof-of-stake instead of proof-of-work.

Instead of mining with computational work, implement a system where validators are chosen based on their stake. Track validator balances and select the next block creator proportionally.

Real-World Task: Verify a Bitcoin Transaction

Use a blockchain explorer to understand how real transactions work:

  1. Go to a block explorer (like blockchain.info or mempool.space)
  2. Search for a recent Bitcoin transaction
  3. Identify: transaction hash, inputs (where coins came from), outputs (where coins went), fees paid, and confirmation count
  4. Check which block contains this transaction
  5. Verify the chain of block hashes back to the genesis block

This is how Doda Browser could implement transaction verification — by connecting to blockchain nodes and validating the proof-of-work chain.

FAQ

Is blockchain the same as Bitcoin?
No. Bitcoin is a cryptocurrency that uses blockchain technology. Blockchain is the underlying technology — a decentralized ledger — that can be used for many purposes beyond cryptocurrencies.
Can blockchain data be modified?
Technically yes, but practically no. To modify a block, you’d need to redo the proof of work for it AND all subsequent blocks faster than the network. This requires >51% of the network’s computing power, which is prohibitively expensive on large blockchains.
What is a 51% attack?
If a single entity controls more than 50% of the network’s mining power (PoW) or staked coins (PoS), they can prevent new transactions from confirming, reverse recent transactions, and double-spend coins. This is why decentralization matters.
How long does it take to add a block?
Bitcoin targets 10 minutes per block (difficulty adjusts every 2,016 blocks). Ethereum targets ~12 seconds. Speed depends on the consensus mechanism and network parameters.
What happens if I lose my private key?
You permanently lose access to your cryptocurrency. There’s no recovery mechanism, no customer support, no password reset. This is why wallet backups and seed phrases are critical.

Try It Yourself

Run the blockchain demo above in your Python environment. Then try these modifications:

  1. Increase the difficulty to 5 and see how much longer mining takes
  2. Add more transactions and observe the chain growing
  3. Try tampering with a block and verify the chain becomes invalid
  4. Add a “balance” feature that tracks each address’s total coins

The code above runs a complete, working blockchain in under 100 lines. While it’s not production-ready (no P2P networking, simplified consensus), it demonstrates the core concepts that power systems like Bitcoin and Ethereum.

What’s Next

What’s Next

Congratulations on completing this Blockchain Basics tutorial! Here’s where to go from here:

  • Practice daily — Consistency is more important than long study sessions
  • Build a project — Apply what you learned by building something real
  • Explore related topics — Check out other tutorials in the same category
  • Join the community — Discuss with other learners and share your progress

Remember: every expert was once a beginner. Keep coding!

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro