CPSC 3640 / CPSC 5400

Decentralized Payments, Contracts, and Finance for Humans and AI

Announcements

Course Information

Time/location

  • MW, 11:35am-12:50pm
  • 17 Hillhouse Avenue 113

Platforms

Instructor

Prof. Fan Zhang

Prof. Fan Zhang

Office hours: Thursday, 4:00pm in AWK 503

Teaching Assistant

Longfei Qiu

Office hours: Tuesday, 4:00pm in AKW 313

๐Ÿ“– Course Description

Blockchains provide a platform for humans to coordinate economic activity without relying on centralized intermediaries. Emerging standards such as EIP-8004 aim to extend these capabilities to autonomous agents, enabling AI systems to transact and coordinate through shared protocols. This introductory course explores such decentralized applications, including tokens, exchanges, lending protocols, stablecoins, oracles, decentralized governance, and emerging standards for AI coordination and interoperability. Students will learn system architecture, security intuition, and how to build and debug decentralized applications.

Course Units (click for details)

This course is organized into three units that build progressively from foundational concepts to the frontier where AI and blockchain intersect.

Unit 1 โ€” Foundation covers why decentralized systems are needed by tracing the path from digital money to the world computer. The unit introduces Bitcoin fundamentals, Bitcoin payment methods, contracts on Bitcoin, and Ethereum’s smart contract platform with programming in Solidity. It concludes with a unified view of blockchains through State Machine Replication, virtual machines, and modular designs.

Unit 2 โ€” DeFi as the new fintech frontier covers the major building blocks of the decentralized finance ecosystem and the opportunities and risks that come with them. Students learn how tokens, stablecoins, decentralized exchanges (DEXes), automated market makers (AMMs), oracles, and lending and borrowing protocols work under the hood, along with opportunities such as auditability and interoperability. The unit then turns to risk: smart contract bugs, miner/maximal extractable value (MEV), privacy, key management, and performance challenges.

Unit 3 โ€” Crypto for AI <> AI for Crypto explores the two-way relationship between blockchains and AI. In one direction, students examine how decentralized infrastructure can serve autonomous AI agents: payment protocols such as x402, confidential AI using trusted execution environments (TEEs), securing the plumbing of AI, and identity, reputation, and coordination through emerging standards such as EIP-8004. In the other direction, the unit examines how AI systems participate in crypto markets, including trading algorithms and their privacy problems.

Prerequisites

Required: CPSC 201 and 202 (or equivalent), and a basic understanding of computer systems and networks.

Grading

Click to open
Assessment Weight Details
Class Participation 10% Ongoing throughout the semester; includes in-class discussion and engagement
Homework & Labs 40% 4 problem sets and 2 take-home labs
Group Presentation 30% Students form a team to investigate a technical or societal topic related to the course and present to the class (~20 minutes), scheduled during the final weeks of the semester
Final Exam 20% In-class final exam on fundamental concepts across all three units

Late submission policy

  • Definition: One late day equals a 24-hour extension.
  • Each student gets one free late day.
  • Each non-free late day incurs a 10% grade reduction.
  • Extensions granted by deans or accommodation offices will be honored.

Lecture Schedule

The schedule for Sections II and III may be updated.

Section I: Foundation: Bitcoin and Ethereum

Lecture 1: Course introduction: from digital money to the world computer

Why digital money needs more than a trusted intermediary: preventing counterfeiting and double spending while addressing privacy, censorship, and distributed consensus.

Lecture 2: Bitcoin fundamentals

The cryptographic and economic foundations of Bitcoin, including digital signatures, hash functions, and proof of work.

Lecture 3: Bitcoin Ledger

How are Bitcoin blocks created and secured by Proof of Work and the longest chain rule.

Section II: DeFi as the new fintech frontier

Lecture 8: DeFi primitive: tokens and tokenization

How blockchains represent fungible and non-fungible assets, and how tokenization connects ownership and programmability.

Hands-on component: Everyone gets a Handsome Dan
New assignment: Problem set 1 released

Lecture 10: DeFi advantage: privacy-preserving asset transfers

Techniques for private on-chain transfers, from zero-knowledge proofs to systems such as Tornado Cash, Zerocoin, Zerocash, and Zcash.

Hands-on component: Playing with Privacy Pools

Lecture 11: DeFi primitive: decentralized exchanges (DEX)

How decentralized exchanges enable on-chain trading, with a focus on automated market makers and liquidity pools.

Deadline Problem set 1 due at 11:59 PM

Lecture 13: No class

Lecture 14: DeFi risk: order manipulation and MEV

How transaction ordering creates extractable value, including different forms of MEV, proposer-builder separation, builder centralization, and a related legal case study.

Deadline Problem set 2 due at 11:59 PM ET

๐Ÿ‚ October recess, October 20โ€“25

Lecture 15: DeFi primitive: oracles, real-world assets, and prediction markets

How smart contracts obtain external data, with applications in insurance and prediction markets and risks such as oracle manipulation.

Hands-on component: Playing with prediction markets

Lecture 16: DeFi advantage: bridges and interoperability

How assets and messages move across blockchain networks, along with the trust assumptions and security challenges of interoperability.

New assignment: Lab 2: Multisig wallet (take-home) released

Lecture 17: DeFi risk: human-factor attacks

How key-management choices such as zkLogin shape user security and how attackers exploit behavior and interface conventions through address poisoning and related social-engineering attacks.

Lecture 18: DeFi risk: bugs in smart contracts and in blockchains

How bugs arise in smart contracts and blockchain protocols, how governance and DAOs can mitigate them, and how mechanisms such as vote buying create additional risk.

Hands-on component: Hacking some smart contracts

Lecture 19: DeFi primitive: (re-)staking

How proof-of-stake security, slashing, and restaking use economic commitments to secure blockchain protocols and additional services.

Lecture 20: DeFi advantage: censorship resistance

Who can censor DeFi transactions, why they may do so, and how protocol designs can prevent censorship or increase its cost.

Lecture 21: Infra: confidential smart contracts

How trusted execution environments and confidential blockchain designs protect smart-contract data and computation.

New assignment: Problem set 4 released
This class will be taught remotely.

Section III: Crypto for AI <> AI for Crypto

Lecture 22: Payment protocols for agents (x402)

How autonomous agents can discover, authorize, and settle payments over the web using emerging protocols such as x402.

๐Ÿ‚ November recess, November 20โ€“29

Lecture 23: Identity, reputation & coordination (EIP-8004)

How decentralized identity and reputation can help autonomous agents discover one another, establish trust, and coordinate.

Hands-on component: TBD

Lecture 24: Securing the plumbing of AI (Props)

How confidential computing, including trusted execution environments, can protect AI infrastructure, data, and computation.

Lecture 25: Presentations

Final exam (in class)

Lecture 26: In-class final

An in-class assessment covering foundational concepts across the course's three units.