Blockchain Tutorial
Learn Blockchain step by step: 41 lessons in 8 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is a Blockchain? Understand what a blockchain is, the problem it solves, how blocks link into a chain, and what it is not. Includes a tiny live demo in Python.
- How a Blockchain Works End to End Follow one transaction through a blockchain network: signing, the mempool, block proposal, validation, confirmations and finality, with a clear diagram.
- History and Landscape: Bitcoin, Ethereum and Beyond A short history of blockchain from cypherpunks to Bitcoin and Ethereum, plus public, private and consortium chains, layer 2s and hype worth ignoring.
Cryptography Foundations
- Cryptographic Hash Functions Learn what a cryptographic hash function does, with SHA-256 in Python: determinism, the avalanche effect, preimage and collision resistance, bytes vs text.
- Hash Pointers and Tamper Evidence Link records by their hash to build tamper-evident logs. Detect edits, find where history was changed, and see why rewriting a long chain is costly.
- Merkle Trees and Proofs of Inclusion Build a Merkle tree in Python, handle odd leaf counts, compute the root and verify a proof of inclusion with only log n hashes. See how light clients use it.
- Public-Key Cryptography Basics Understand key pairs, signing versus encryption, why a key replaces an account on a blockchain, and why key size and randomness matter, with a toy RSA example.
- Digital Signatures with a Toy Scheme Build a Lamport one-time signature from SHA-256 in Python, see why signatures prove authorization, why a key must not sign twice, and how replay attacks work.
- Elliptic Curves in Plain Language Learn point addition and scalar multiplication on a tiny elliptic curve, how secp256k1 and ECDSA work, and why reusing a signing nonce leaks the private key.
- Keys, Addresses and Wallets Follow a blockchain identity from private key to public key to address, learn Base58Check checksums, seed phrases and HD wallets, and why custody matters.
Building a Toy Blockchain
- Designing a Block Design a blockchain block in Python: header versus body, index, timestamp, previous hash and nonce, with deterministic JSON serialization and dataclasses.
- Building and Validating the Chain Create a genesis block, append linked blocks, verify the whole chain and see exactly how tampering is detected, with a runnable Python toy blockchain.
- Proof of Work and Mining Learn how proof of work turns hashing into a cost: leading-zero difficulty, nonce search, the probability maths and the energy trade-off, with live Python.
- Difficulty Adjustment and Block Time See how a proof-of-work chain retargets difficulty so blocks keep a steady pace when hash power changes, with a seeded Python simulation and a plot.
- Transactions and the Mempool Build signed transactions, validate them against balances and nonces, hold them in a mempool and assemble a block by fee, with live Python.
- UTXO vs Account Model Compare Bitcoin-style UTXOs with Ethereum-style account balances and nonces, including change, double-spend checks and trade-offs, with two live Python ledgers.
Consensus and Networks
- The Double-Spend Problem and Byzantine Faults Why digital cash needs consensus: double spends, the Byzantine generals problem, Sybil attacks and trust assumptions, with small live Python demos.
- Longest Chain Rule, Forks and Reorgs See how proof-of-work chains settle disagreement: competing blocks, stale blocks, reorganizations, confirmations and 51 percent attack odds, simulated in Python.
- Peer-to-Peer Networking and Gossip See how blockchain nodes find peers, gossip blocks and transactions across the network, why latency causes forks, and how light nodes differ from full nodes.
- Proof of Stake Learn how proof of stake picks validators by locked-up stake, how slashing and finality work, what nothing-at-stake means, and run a live lottery simulation.
- BFT, Delegated and Other Consensus Mechanisms Compare PBFT-style voting, quorum math (3f+1), Raft, delegated and authority-based consensus and DAG ledgers, with a live quorum calculator in Python.
Smart Contracts
- What Are Smart Contracts? Understand smart contracts: programs stored on a blockchain, deterministic execution, contract state, gas as metering and the limits of on-chain code.
- Building a Toy Smart Contract Engine Build a tiny smart contract engine in Python: contract classes, metered storage, calls as transactions, gas counting, events and automatic reverts.
- Reading Solidity: A First Contract Learn to read a first Solidity contract: pragma, state variables, functions, events, msg.sender and require, with a counter and a token and Python equivalents.
- Tokens, ERC-20 and NFTs Learn fungible and non-fungible tokens: the ERC-20 interface, balances, allowances, mint and burn, and NFT metadata, with live Python models of each.
- Smart Contract Security Pitfalls See how reentrancy, integer overflow, missing access control, front-running and oracle manipulation break contracts, with live Python models and real incidents.
- dApps, Oracles and Wallet Integration How a decentralized app talks to a node over JSON-RPC, how wallets sign, why oracles are a trust problem, and how indexers and off-chain storage fit in.
Using Blockchains in Practice
- Bitcoin in Practice Bitcoin's fixed supply and halving schedule, block size and weight, how Script locks coins, how fees work, and how to read a real block header in Python.
- Ethereum in Practice How Ethereum works day to day: accounts and nonces, the EVM and gas metering, EIP-1559 fees, blocks and logs, and why rollups exist, with live Python models.
- Scaling: Layer 2, Rollups and Sharding Why blockchains process few transactions per second, the scalability trilemma, and how payment channels, rollups, sidechains and sharding help, with live models.
- Privacy and Zero-Knowledge Proofs Why public blockchains are pseudonymous, not anonymous: chain analysis, mixers, hash commitments and a toy zero-knowledge proof you can run in Python.
- DeFi, DAOs and Governance Understand decentralized finance: lending with collateral, automated market makers and the constant-product formula, DAO voting and the risks, with runnable code.
- Enterprise and Real-World Use Cases See where blockchains are used beyond crypto: supply chains, provenance, identity and CBDCs, and learn a checklist for deciding when you should not use one.
Projects
- Project: A Complete Mini Blockchain Combine blocks, proof of work, signed transactions, balances and full-chain validation into one Python class, then prove it works with assert tests and tampering.
- Project: A Wallet with Signed Transactions Build a wallet in Python on the secp256k1 curve: key generation, ECDSA signing, addresses, balance tracking and a ledger that rejects forged transactions.
- Project: Simulating a Multi-Node Network Simulate a blockchain network in Python: several nodes mine and gossip blocks, forks appear from latency, the longest chain wins, and a report shows convergence.
- Project: On-Chain Voting and a Token Build a governance token and snapshot-based voting with quorum on a toy blockchain in Python, then prove with tamper checks that edited history is caught.
- Project: Supply Chain Provenance Tracker Build a supply chain provenance tracker in Python: record product events on a hash-linked chain, prove one shipment with a Merkle proof and run audit queries.
Practice and Review
- Practice Exercises with Solutions Ten graded blockchain exercises in Python on hashing, Merkle roots and proofs, mining, chain validation, UTXO checks, AMM math and supply: with runnable solutions.
- Blockchain Interview Questions Forty blockchain interview questions with short answers: core concepts, cryptography, consensus, smart contract security and system design, with links to lessons.
- Blockchain Cheat Sheet A one-page blockchain cheat sheet: glossary, formulas for mining, quorum, halving and constant-product swaps, Python hashing patterns and a when-to-use checklist.