CS190: Blockchain Programming and Applications
Lecture 1: Course Introduction & Blockchain Foundations
Instructor
Yu Feng, Computer Science Department, UCSB
Quarter
Fall 2025
Welcome to the comprehensive study of blockchain technology, where we'll explore how decentralized systems are reshaping the digital landscape. This course combines theoretical foundations with practical programming skills, preparing you to build the next generation of blockchain applications.
Why This Course Matters
Beyond the Hype
Blockchains have evolved from experimental technology to critical infrastructure powering billions in digital assets and decentralized applications.
Programmable Money
Smart contracts enable self-executing agreements, creating new possibilities for financial systems, governance, and digital ownership.
Decentralized Systems
Remove single points of failure and intermediary control through distributed consensus mechanisms and cryptographic proofs.
3.9T
Global Crypto Market Cap
Reflecting massive investor interest and digital asset growth across diverse platforms.
2.2T
Bitcoin Market Cap
Nearing the value of silver, solidifying its status as digital gold with significant institutional backing.
170B
Daily Trading Volume
Indicating high liquidity and active participation across various cryptocurrencies and decentralized exchanges.
This growth is further underscored by significant institutional adoption and regulatory recognition, exemplified by President Trump signing the GENIUS Act into law, a clear signal of blockchain's integration into mainstream financial and technological frameworks.
Course Goal: Master both the theoretical foundations of how blockchains work and the practical skills to build sophisticated applications on these platforms.
By the end of this course, you'll understand the cryptographic primitives, consensus mechanisms, and programming paradigms that power the decentralized economy.
Meet Your Instruction Team
Instructor: Yu Feng
Office Hours: Mon 3:30-4:30 PM
Location: HFH-2157
TA: Hanzhi Liu
Discussion: Fri 1pm-1:50pm, SH-1430
Office Hours: Fri 12pm-1pm, SH-1430

Syllabus Overview
1
Part I: Foundations
Weeks 1-4
Bitcoin mechanics, UTXO model, cryptographic primitives, Ethereum basics, and Solidity programming fundamentals
2
Part II: DeFi Systems
Weeks 5-8
Automated Market Makers, lending protocols, stablecoins, perpetual contracts, and Decentralized Autonomous Organizations
3
Part III: Advanced Topics
Weeks 9-10
Layer 2 scaling solutions, cross-chain bridges, security best practices, and emerging blockchain technologies
Each part builds systematically on the previous, starting with core blockchain concepts, progressing through decentralized finance applications, and concluding with advanced scalability and security considerations that define the current state of the field.
Examination Schedule: Midterm 1 covers Part I material (Week 4). Midterm 2 focuses on Part II content (Week 8). Part III material appears in final homework assignments.
Course Structure & Format
Interactive Lectures
Theory meets practice through live coding demonstrations and real-world case studies. Each lecture builds foundational concepts while connecting to current blockchain developments.
Programming Assignments
Hands-on coding assignments where you'll implement blockchain concepts, write smart contracts, and deploy to test networks. Reinforce lecture material through practical application.
Assessment Structure
Two midterm examinations testing conceptual understanding of blockchain components.
This course emphasizes learning-by-doing. No final exam or capstone project – instead, continuous assessment through practical assignments and focused midterm evaluations.
Grading Breakdown
60%
Homework Assignments
5 coding assignments
20%
Midterm 1
Part I material
20%
Midterm 2
Part II material
Homework builds a portfolio combining theory and practical skills.

Late policy: 10 late days. No makeup exams.
Learning Outcomes
Trust Without Intermediaries
Understand how cryptographic protocols and consensus mechanisms eliminate the need for trusted third parties in digital transactions and agreements.
Smart Contract Development
Master Solidity programming, deployment strategies, and best practices for building secure, efficient decentralized applications on Ethereum.
DeFi System Architecture
Analyze and implement core DeFi primitives including AMMs, lending protocols, and synthetic assets that power the decentralized economy.
Technology Trajectory
Evaluate emerging trends in blockchain scaling, interoperability, and next-generation consensus mechanisms shaping the industry's future.
The Decentralization Imperative
Traditional Centralized Systems
Expensive intermediaries, single points of failure, and gatekeeping create inefficiencies and vulnerabilities in financial and digital systems.
Bitcoin's Innovation
Embedded trust directly in protocol mechanics through cryptographic proof and economic incentives, eliminating reliance on institutional trust.
Evolution of Decentralization
From DigiCash's centralized e-cash to Bitcoin's peer-to-peer currency to Ethereum's programmable blockchain to today's sophisticated DeFi ecosystem.
Decentralization represents a fundamental shift in how we architect digital systems. Rather than trusting institutions, we trust mathematics, cryptography, and economic game theory to ensure system integrity and user protection.
2008 Financial Crisis & Lehman Brothers. This paradigm shift has profound implications for finance, governance, identity, and digital ownership.
Blockchain Structure Visualization
This chain diagram visualizes how blocks are cryptographically linked together. Each block references the previous block's hash, creating an immutable chain where changing any historical data would break all subsequent links.
Cryptographic Building Blocks
Hash Functions
Properties: Deterministic, fixed output size, avalanche effect, collision resistance
Applications: Data integrity verification, digital commitments, Proof-of-Work puzzles, Merkle tree construction
Bitcoin Use: SHA-256 for block hashing and transaction verification
Digital Signatures
Core Concept: Identity = public key ownership, unforgeable mathematical proofs of authorization
ECDSA Algorithm: Elliptic curve signatures providing strong security with small key sizes
Bitcoin Integration: Controls spending authority for UTXOs
Merkle Trees
Structure: Binary tree of hashes enabling efficient inclusion proofs
Scalability: Verify transaction inclusion without downloading entire block
SPV Clients: Lightweight verification for mobile and constrained devices
These cryptographic primitives form the mathematical foundation of all blockchain systems. Understanding their properties and applications is crucial for both using and building blockchain applications securely.
Bitcoin's UTXO Model
The UTXO model treats each transaction output as an indivisible unit, similar to physical coins. To spend a UTXO, you must consume it entirely – if you need to send less than the full amount, you create a change output back to yourself.
Key Insight: The Bitcoin ledger is simply the complete set of all unspent transaction outputs (UTXOs). There are no account balances – only discrete, unspent outputs that can be consumed in future transactions.
This design provides excellent parallelization properties and clear transaction semantics, though it differs significantly from traditional account-based systems.
Bitcoin Script Programming
Script Characteristics & Security
Bitcoin Script is designed for security and predictability:
  • Stack-based: Operations manipulate a data stack.
  • Simple instruction set: Focused on signature verification and basic logic.
  • Non-Turing complete: No loops, preventing infinite execution and denial-of-service attacks.
  • Deterministic: Same script always produces the same result, ensuring predictable resource consumption and minimizing attack surface.
Common Script Patterns
Pay-to-Public-Key-Hash (P2PKH)
Standard single-signature spending requiring a private key.
Multi-signature (Multisig)
Requires M-of-N signatures for shared custody/governance.
Pay-to-Script-Hash (P2SH)
Allows complex conditions by referencing a script hash, keeping transactions small.
P2PKH Script Example
Unlocking (scriptSig) and locking (scriptPubKey) scripts combine, evaluating to TRUE for a valid transaction.
Locking Script (scriptPubKey): Secures funds to a Bitcoin address.
OP_DUP OP_HASH160 [Public Key Hash] OP_EQUALVERIFY OP_CHECKSIG
Unlocking Script (scriptSig): Provides data to unlock funds.
[Signature] [Public Key]
The Transparency-Privacy Trade-off
Bitcoin's Pseudonymous Model
Bitcoin operates on pseudonymity rather than anonymity. Public keys serve as pseudonyms, and all transactions are recorded on a public ledger visible to anyone.
This design enables global verification and audit ability – anyone can verify the complete transaction history and current system state. However, sophisticated analysis can often link pseudonyms to real-world identities.
The Fundamental Trade-off
  • Transparency: Enables trustless verification and systemic integrity
  • Privacy Loss: Transaction patterns can reveal sensitive information
  • Regulatory Implications: Public ledgers aid compliance but complicate privacy
Modern Privacy Solutions
Zero-knowledge proofs represent the cutting edge of blockchain privacy, enabling verification of statements without revealing the underlying data.

ZK-SNARKs and ZK-STARKs allow users to prove transaction validity while keeping amounts, addresses, and other sensitive data private.
This technology enables "privacy in public" – maintaining blockchain transparency while protecting individual privacy rights.
The Distributed Consensus Challenge
Network Latency
Messages between nodes experience unpredictable delays, making it difficult to establish consistent global ordering of events and transactions.
Node Failures
Individual nodes may crash, lose network connectivity, or become temporarily unavailable, requiring the system to remain functional despite partial failures.
Byzantine Adversaries
Malicious nodes may send arbitrary or contradictory messages, attempting to disrupt consensus or double-spend funds for personal gain.
No Trusted Coordinator
Unlike traditional distributed systems, blockchains cannot rely on a trusted central authority to resolve conflicts or establish canonical transaction ordering.
The Core Problem: How do thousands of independent nodes, spread across the globe and connected by an unreliable network, agree on a single, consistent view of transaction history without any trusted intermediary?
This is fundamentally what makes blockchain technology so revolutionary – and so complex to implement correctly.
Proof-of-Work Consensus Mechanism
Hash Puzzle Construction
Miners must find a nonce value that, when combined with block data and hashed, produces a result with a specific number of leading zeros
Probabilistic Lottery System
Success probability is proportional to computational power – more hash rate means higher chance of finding valid blocks
Longest Chain Rule
Network accepts the chain with the most accumulated proof-of-work as the canonical transaction history
Easy Verification
While finding solutions requires massive computation, verifying block validity requires only a single hash operation
Proof-of-Work transforms the consensus problem into a computational race. The key insight: it's much harder to fake computational work than to verify it, creating an asymmetric security guarantee that protects the network.

Economic Security: Attacking the network requires spending more on electricity and hardware than the potential gain from the attack, making honest mining more profitable than cheating.
Mining Economics & Incentive Structure
Bitcoin's security model relies on a carefully designed economic incentive system. Block rewards create initial mining incentives and distribute new bitcoins, while transaction fees provide long-term sustainability as rewards diminish through scheduled halvings.
The halving mechanism serves multiple purposes: it creates scarcity (capped at 21 million BTC), provides predictable monetary policy, and gradually transitions network security from inflationary rewards to transaction fee revenue. This transition is critical for long-term network sustainability.
Bitcoin's Difficulty Adjustment Algorithm
1
Measurement Period
Every 2016 blocks (approximately 2 weeks at 10-minute intervals)
2
Time Calculation
Compare actual time for 2016 blocks against target time of 20,160 minutes
3
Difficulty Adjustment
If blocks came faster: increase difficulty. If slower: decrease difficulty. Maximum 4x change per adjustment
4
Target Maintenance
New difficulty ensures next 2016 blocks target ~10 minutes each, regardless of network hash rate
Adaptive Security: As more miners join (increasing hash rate), difficulty automatically increases to maintain consistent block times. If miners leave, difficulty decreases to keep the network functional.
This self-regulating mechanism ensures Bitcoin remains functional whether secured by a few miners or thousands, adapting to changing economic conditions and technological improvements in mining hardware.
Today's Key Takeaways
Decentralization Paradigm
Blockchain technology eliminates trusted intermediaries through cryptographic proof and economic incentives, fundamentally changing how digital systems can be architected.
Cryptographic Foundations
Hash functions, digital signatures, and Merkle trees provide the mathematical security guarantees that make trustless systems possible and practical.
Bitcoin's Innovation
The UTXO model and Bitcoin Script create a simple but powerful framework for programmable digital money with clear ownership semantics.
Consensus Achievement
Proof-of-Work solves the distributed consensus problem through computational competition, creating economic incentives that align individual profit with network security.
These foundational concepts form the basis for understanding all blockchain systems. Every subsequent innovation in the space builds upon these core ideas of decentralized consensus, cryptographic security, and economic incentive alignment.
Next Lecture Preview
Account Model vs UTXO
Explore Ethereum's account-based ledger system and compare its advantages and trade-offs against Bitcoin's UTXO model
Smart Contract Fundamentals
Introduction to programmable contracts, state machines, and the composability that makes DeFi applications possible
Solidity Development Setup
Hands-on preparation for writing, testing, and deploying your first smart contracts on Ethereum testnets

Preparation for Next Class: Review the Ethereum whitepaper introduction and ensure you have a development environment set up. We'll dive straight into coding examples.
We'll transition from Bitcoin's relatively simple scripting system to Ethereum's Turing-complete virtual machine, opening up possibilities for complex decentralized applications while introducing new security considerations and design patterns.