Could you build a working blockchain yourself, one tested piece at a time?
Build a Blockchain 201 · about 13 minutes a level
Build a small blockchain in Python, step by step: hashing with canonical data, blocks and a validated chain, proof-of-work mining with difficulty that adjusts, transactions and balances, keys and digital signatures, Merkle trees, a simple peer network that settles on the valid chain with the most work, a wallet, and a test suite that attacks your own code. Everything runs on your own computer with toy coins that have no value; nothing touches a real network or real money.
Go deeper, level by level
- Blocks and hashes in Python: Hashing data in Python: bytes, JSON and SHA-256, A Block class, Linking blocks and validating the chain
- Proof-of-work mining: Difficulty: hashes that start with zeros, Mining: searching for a nonce, Adjusting difficulty to keep block times steady
- Transactions and balances: A Transaction class and its ID, A mempool, and building blocks from it, Balances, and refusing overspends, Rewarding miners: the coinbase transaction
- Keys and signatures: Key pairs with a trusted library, Signing transactions, Verifying signatures and rejecting forgeries, Stopping replays with account nonces
- Merkle trees: Computing a Merkle root, Merkle proofs for light clients
- A small peer network: A node with a small HTTP API, Sharing transactions and blocks with peers, Resolving conflicts: the chain with the most work wins, Simulating forks and reorganisations
- Wallets: Addresses from public keys, Keeping test keys safe on disk, A command-line wallet
- Testing, attacks and next steps: Unit tests with unittest, Testing attacks: tampering, double spends and forged signatures, From toy to real: what production blockchains add
Every lesson shows its sources and how sure we are, and is checked by Everwhy.