# ๐Ÿ“š Syllabus: Intro to Rust & Solana Smart Contracts with Anchor + AI Assistance ## Module 1 โ€“ Foundations of Rust (2 sessions) > Goal: Understand enough Rust to reason about Solana programs. ### Session 1: Getting Started with Rust - Why Rust for blockchain? (safety, performance, memory model) - Installing Rust (rustup, cargo) - Hello World & Cargo basics - Variables, mutability, data types - Ownership & borrowing (the heart of Rust) ### Session 2: Rust Essentials for Solana - Structs, enums, traits (how data is modeled) - Result & Option (error handling) - Modules & imports - Writing small CLI programs (practice with cargo run/test) - **AI Exercise:** Ask AI to write a simple CLI program and explain what each part does. --- ## Module 2 โ€“ Blockchain & Solana Basics (1 session) > Goal: Understand what Solana is and why Anchor helps. - Blockchain recap (accounts, state, programs vs. users) - Solana architecture: - Programs (smart contracts) - Accounts (data storage) - Instructions (transactions) - Why Anchor? (reduces boilerplate, enforces safety) - **AI Exercise:** Have AI explain the difference between Ethereum smart contracts and Solana programs. --- ## Module 3 โ€“ Intro to Anchor Framework (2 sessions) > Goal: Build first Solana program with Anchor. ### Session 3: Setting up Anchor - Installing Anchor CLI - Project structure (programs, tests, migrations) - Understanding `Cargo.toml` and `Anchor.toml` - Hello World program in Anchor - **AI Exercise:** Generate a HelloWorld program and explain each macro (`#[program]`, `#[derive(Accounts)]`). ### Session 4: Accounts & State Management - PDAs (Program Derived Addresses) basics - Defining account structs with Anchor - Initializing & updating account data - **AI Exercise:** Generate code for storing a user profile and walk through it manually. --- ## Module 4 โ€“ Building Smart Contracts (3 sessions) > Goal: Use Anchor to implement real-world logic. ### Session 5: Writing Instructions - Defining program entrypoints - Passing data into instructions - **AI Exercise:** Generate a โ€œcounterโ€ contract (increment/decrement). ### Session 6: Error Handling & Security - Custom error types in Anchor - Access control (constraints in `#[derive(Accounts)]`) - **AI Exercise:** Generate contract with restricted access and explain the constraints. ### Session 7: More Complex Example โ€“ Blog Program - Users can create, update, delete posts - Handling multiple accounts (posts, users) - Linking concepts from Rust (structs, enums) to Solana contracts --- ## Module 5 โ€“ Testing & Deployment (2 sessions) > Goal: Ship contracts safely. ### Session 8: Local Testing - Anchor test framework - Writing integration tests in Rust - Simulating transactions - **AI Exercise:** Generate tests for Blog program and explain whatโ€™s happening. ### Session 9: Deployment to Devnet - Solana CLI basics (keypairs, wallets, devnet) - Deploying contract with Anchor - Interacting with contract (Anchor CLI, JS/TS client) - **AI Exercise:** Generate client-side code to call Blog program. --- ## Capstone Project (Session 10) - Build a small **Solana dApp with AI + Anchor**, e.g.: - To-do list contract - Voting system - Osusu (group savings) contract (localized example) - Students: prompt AI to scaffold the contract, then refine and explain key concepts manually. --- ## Key AI Integration Points Throughout - Use AI to **generate starter code**, but always **manually review**: - Ownership & borrowing in Rust - Account validation & constraints in Anchor - Security considerations (donโ€™t trust blindly) - Encourage *โ€œAsk AI to explain X in plain Englishโ€* as a meta-learning tool.