DAY 30 / 40
>> Module 03 / Day 30 / Friday

Quiz & Tiny Blockchain

Mini-Quiz 3, then build and ship your chain

End of Module 3. A 15-minute quiz to lock in blockchain concepts — then the most ambitious lab yet: your own complete blockchain in one file.

Quiz / 15 min · 09:00–09:15
Lab / 60 min · Complete Tiny Blockchain
Module / M3 · Blockchain Basics
>> Today's schedule

Agenda

  1. Mini-Quiz 3 — 15 minutes (blockchain concepts + Python)
  2. Quick recap of Module 3 (D21–D29)
  3. Mini-project brief — what to build
  4. Required functions and features
  5. Lab — build it, test it, PR it
>> 09:00 – 09:15 · Mini-Quiz 3

15 minutes · blockchain + Python

No computers. Covers the blockchain concepts and Python code from Days 21–29.

WHAT'S ON IT
  • • Write hashlib.sha256() — what does each step do?
  • • What are the two checks in is_valid_chain()?
  • • Explain Proof of Work in one sentence
  • • What is the nonce and why do we change it?
SAMPLE QUESTION
quiz_sample.py
chain[2]["data"] = "tampered!" # Question: After this line, # what does is_valid_chain(chain) return # and WHY?
>> The week in one glance · D21–D29

Everything you built in Module 3

D21–22 FOUNDATIONS
Blockchain concept + hashlib.sha256()
The trust problem and its cryptographic solution.
D23–24 STRUCTURE
make_block(), add_block()
A block is a dict; a chain is a list.
D25–26 SECURITY
is_valid_chain(), mine_block()
Detecting and preventing tampering.
D27–28 CONSENSUS + VALUE
weighted_choice() for NPoS simulation
Transactions packed into blocks.
>> 11:00 – 12:00 · Mini-project

Build your Tiny Blockchain

One Python file. All the functions. Working end to end.

hash_block(block)
SHA-256 fingerprint of all block fields
make_block(index, transactions, previous_hash, nonce)
Creates a valid block dict
mine_block(index, transactions, previous_hash, difficulty)
Finds valid PoW nonce
is_valid_chain(chain)
Returns True/False + error message
>> Required output

Your program must produce this output

demo.py
# When run, your file should: chain = [make_block(0, [], "0" * 64)] # genesis add_block(chain, [{"from":"Alice","to":"Bob","amount":10}]) add_block(chain, [{"from":"Bob","to":"Carol","amount":4}]) add_block(chain, [{"from":"Alice","to":"Dave","amount":2}]) for b in chain: print(f"Block {b['index']:2d} | nonce={b['nonce']:6d} " f"| hash={b['hash'][:16]}...") result, msg = is_valid_chain(chain) print(f"\nChain valid: {result} — {msg}")
>> Going further

Optional stretch goals

★ STRETCH 1
CLI Menu
Wrap your blockchain in a while True menu: (1) Add block, (2) View chain, (3) Validate, (4) Quit. Use input() for menu choices.
★ STRETCH 2
JSON Persistence
Save the chain to chain.json after every block. Load it at startup if the file exists. Your chain survives program restarts.
>> End of Module 3 · Day 30

You built a blockchain

  • ✓ You understand hashing, blocks, chains, validation, PoW, PoS, and transactions.
  • ✓ You have a working tiny blockchain in Python — your portfolio piece.
  • ✓ You're ready to understand how Polkadot works — because it's the same ideas, production scale.
01 / 8
←/→ navigate   F fullscreen