Foundry Workshop: Testing & Deploy EduLoan
Tentang Workshop Iniโ
Level Up: Dari Remix ke Foundry!
Setelah berhasil membuat EduLoan di Remix, saatnya naik level! Workshop ini akan mengajarkan cara professional developers membangun, testing, dan deploy smart contract menggunakan Foundry.
๐ฏ Tujuan Pembelajaranโ
Setelah menyelesaikan workshop ini, Anda akan mampu:
- Setup Foundry - Install dan konfigurasi Foundry di Windows/Mac
- Project Structure - Memahami struktur project Foundry
- Unit Testing - Menulis comprehensive tests dalam Solidity (bukan JavaScript!)
- Fuzz Testing - Menemukan edge cases dengan random inputs
- Gas Optimization - Teknik optimasi gas dengan measurement akurat
- Deployment - Deploy EduLoan ke Mantle Sepolia dengan script
๐ก Kenapa Foundry?โ
Analogi: Remix vs Foundryโ
Remix IDE (Yang Sudah Anda Pakai):
๐จ Seperti menggambar dengan pensil dan kertas
- Mudah untuk belajar
- Bagus untuk eksperimen cepat
- Terbatas untuk project besar
- Testing manual satu per satu
Foundry (Professional Tool):
๐ญ Seperti pabrik dengan mesin otomatis
- Testing otomatis ratusan kali per detik
- Gas report akurat
- Deployment script reusable
- Industry standard untuk DeFi protocols
Perbandingan Langsungโ
| Fitur | Remix | Foundry |
|---|---|---|
| Testing | Manual klik satu-satu | Otomatis 256+ test cases |
| Gas Report | Lihat per transaksi | Report lengkap semua fungsi |
| Fuzz Testing | โ Tidak ada | โ Built-in |
| Deployment | Manual via UI | Script otomatis |
| Speed | Tergantung browser | โก Super cepat (native Rust) |
| Professional | Learning tool | Production-grade |
Real World Usageโ
Protocol yang pakai Foundry:
- Uniswap V4
- Aave V3
- Compound
- OpenSea Seaport
- Lido
- ...dan ratusan protocol DeFi lainnya!
Takeaway: Belajar Foundry = Skill yang dicari industry! ๐ฏ
๐ Prerequisitesโ
Yang Harus Sudah Dipahami:โ
โ Dari Mantle Co-Learning Camp:
- Solidity basics (tipe data, struct, mapping, enum)
- Smart contract structure
- Events dan modifiers
- Payable functions
- EduLoan contract (sudah dibuat di challenge sebelumnya)
โ Command Line Basics:
- Familiar dengan terminal/command prompt
- Navigasi folder (
cd,ls) - Basic git commands
Tools yang Dibutuhkan:โ
โ Development:
- VS Code atau code editor pilihan
- Git untuk version control
- Terminal (built-in di OS)
โ Blockchain:
- MetaMask wallet
- Mantle Sepolia MNT dari faucet
๐ก TIDAK PERLU Node.js! Foundry berbasis Rust, tidak butuh npm!
๐ Struktur Workshopโ
Workshop dibagi menjadi 4 bagian yang fokus pada EduLoan smart contract:
๐ Part 1: Instalasi Foundryโ
- Apa itu Foundry? Foundry Suite (forge, cast, anvil, chisel)
- Instalasi di Windows (Git Bash / WSL)
- Instalasi di Mac (Homebrew)
- Setup project pertama
- Basic commands
๐ Part 2: Setup EduLoan Projectโ
- Membuat Foundry project untuk EduLoan
- Memahami EduLoan contract
- Compile dan inspect contract
- Testing manual dengan Chisel
๐ Part 3: Testing EduLoanโ
- Filosofi testing smart contract
- Unit tests untuk semua fungsi EduLoan
- Fuzz testing untuk edge cases
- Test coverage measurement
- Testing best practices
๐ Part 4: Gas Optimization & Deploymentโ
- Gas optimization techniques
- Membandingkan before/after
- Deploy ke Mantle Sepolia
- Verifikasi contract
- Production checklist
๐ ๏ธ Tech Stackโ
Foundry Suite:โ
| Tool | Fungsi |
|---|---|
| forge | Build, test, deploy smart contracts |
| cast | Interact dengan contracts & blockchain |
| anvil | Local Ethereum node untuk testing |
| chisel | Solidity REPL untuk eksperimen cepat |
Development:โ
- Solidity ^0.8.30 - Smart contract language
- VS Code - Code editor dengan Solidity extension
- Git - Version control
Network:โ
- Mantle Sepolia Testnet - Untuk deployment
- Chain ID: 5003
- RPC: https://rpc.sepolia.mantle.xyz
- Explorer: https://sepolia.mantlescan.xyz
๐ฎ Project Yang Akan Dibangunโ
EduLoan Contract - Sistem pinjaman pendidikan dengan fitur lengkap:
Core Features:โ
- ๐ Apply Loan - Mahasiswa mengajukan pinjaman
- โ Approve/Reject - Admin review pengajuan
- ๐ฐ Disburse - Pencairan dana ke borrower
- ๐ณ Make Payment - Pembayaran cicilan
- โฐ Check Default - Cek status gagal bayar
Testing Coverage:โ
- โ Happy path untuk semua fungsi
- โ Revert cases (error handling)
- โ Edge cases dengan fuzz testing
- โ Access control testing
- โ Time-based logic testing
Gas Optimization:โ
- โ Before/after comparison
- โ Optimization techniques applied
- โ Gas snapshot tracking
๐ Alur Pembelajaranโ
Part 1: Setup Foundation
โ
Install Foundry
Setup VS Code
Create first project
โ
Part 2: Understand EduLoan
โ
Setup EduLoan project
Compile & inspect
Manual testing dengan Chisel
โ
Part 3: Write Tests
โ
Unit tests semua fungsi
Fuzz testing
Coverage 100%
โ
Part 4: Optimize & Deploy
โ
Gas optimization
Deploy ke Mantle Sepolia
Verify contract
โ
๐ Production Ready!
๐ก Tips Belajarโ
- Ikuti urutan Part 1 โ 4 - Jangan skip, setiap part membangun dari sebelumnya
- Ketik sendiri, jangan copy-paste - Muscle memory penting untuk coding
- Baca error messages - Foundry memberikan error yang informatif
- Eksperimen dengan Chisel - Coba variasi untuk memahami lebih dalam
- Commit setiap milestone - Version control adalah best practice
๐ Resourcesโ
Mantle Network:โ
๐ง Mantle Sepolia Testnet:
Network Details:
- Network Name: Mantle Sepolia Testnet
- Chain ID: 5003
- RPC URL: https://rpc.sepolia.mantle.xyz
- Currency: MNT
- Explorer: https://sepolia.mantlescan.xyz
Faucets:
๐ฐ Mantle Faucet
Documentation:โ
- Foundry Book - Official Foundry documentation
- Mantle Docs - Mantle Network documentation
- Solidity Docs - Solidity language reference
Community:โ
- Discord ETHJKT - Ethereum Jakarta community
- Foundry Telegram - Foundry community support
๐ Ready to Start?โ
Mari tingkatkan skill Solidity Anda ke level professional!
๐ Part 1: Instalasi Foundry โ
#BuildWithFoundry | #MantleNetwork | #EthereumJakarta