>> Module 03 / Day 28 / Lecture
Keys, addresses, and moving value
Our blockchain has blocks and chains. But blocks are empty. Today we add transactions — and understand the key pair that authorises every move of value.
>> Today's Roadmap
>> 01 / 04 · Wallets
Your bank balance is a number in the bank's database. Crypto is different: coins exist as entries on the blockchain. Your "wallet" is really just a program that stores your private key and shows you your balance by reading the blockchain.
HOT WALLET
Connected to the internet. Convenient for frequent use. MetaMask, Polkadot.js extension, Trust Wallet.
COLD WALLET
Offline device (Ledger, Trezor). Safer for large amounts. Private key never touches the internet.
>> 02 / 04 · Key pairs
Every wallet has exactly two keys. They are mathematically linked — but knowing the public key tells you nothing about the private key.
PUBLIC KEY / ADDRESS
Your address on the blockchain. Share it freely — this is how people send you tokens. Like your bank account number.
5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
PRIVATE KEY — NEVER SHARE
Your master password. Anyone with this can spend all your tokens. Never store it online. Never share it. If lost — tokens are gone forever.
0x5e0be...NEVER REVEAL THIS
>> 03 / 04 · Transactions
"Alice sends 10 DOT to Bob." But how does the network know it's really Alice? She signs the transaction with her private key. Anyone can verify the signature using her public key.
# A transaction in our simplified model
transaction = {
"from": "Alice_address",
"to": "Bob_address",
"amount": 10,
"signature": "signed_with_alice_private_key",
}
# In our toy blockchain, we skip real cryptography.
# We just trust the 'from' field.
# Real blockchains verify the signature before accepting.>> 04 / 04 · Packing the block
def make_block(index, transactions, previous_hash):
block = {
"index": index,
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
"transactions": transactions, # list of dicts
"previous_hash": previous_hash,
"hash": "",
}
block["hash"] = hash_block(block)
return block
# Create two transactions
txns = [
{"from": "Alice", "to": "Bob", "amount": 10},
{"from": "Carol", "to": "Dave", "amount": 5},
]
block = make_block(1, txns, "0" * 64)
print(f"Block 1 contains {len(block['transactions'])} transactions")>> Real world
WHAT WE CALL IT
transaction = {from, to, amount}
Simple movement of value between addresses.
POLKADOT'S TERM
"Extrinsic" = any external message sent to the chain. Transfer DOT, vote in governance, stake tokens, call a smart contract — all are extrinsics.
Go to Subscan → click any block → look at the "Extrinsics" tab. You'll see a list of operations exactly like our transaction dicts. Each one has a sender, an action, and arguments.
>> 11:00 – 12:00 · Lab
CORE
Transaction builder
Create 5 transactions (using dicts). Update make_block() to accept a list of transactions. Build a 3-block chain where each block has 2 transactions. Print each block's transactions.
★ STRETCH
Balance tracker
After building the chain, scan all transactions and calculate the final balance for each address. Print a leaderboard of who has the most.
>> End of Day 28
A wallet is a key pair: public (your address) and private (your password — never share it).
A transaction is a dict: {from, to, amount, signature} — the signed instruction to move value.
A block's data is now a list of transactions, each changing the state of who owns what.