foundry-full-course-f23
foundry-full-course-f23 copied to clipboard
Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course | Foundry Edition 2023
Welcome to the repository for the Blockchain Developer, Smart Contract, & Solidity Course | Powered By AI | Beginner to Expert Course | Foundry Edition 2023
Lessons 0 - 6 | Lessons 7 - 11 | Lessons 12 - 15 |
---|---|---|
![]() |
![]() |
![]() |
Table of Contents
Resources
- Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course | Foundry Edition 2023
- Table of Contents
- Recommended Tools
- Testnet Faucets
- Resources For This Course
- Bonus NFTs
- Important Notes for Arbitrum
- Bridging to Arbitrum
Lesson 0: The Edge of the Rabbit Hole
- Welcome to the course!
- Best Practices
Lesson 1: Blockchain Basics
- What is a Blockchain? What does a blockchain do?
- The Purpose Of Smart Contracts
- Other Blockchain Benefits
- What have Smart Contracts done so far?
- Making Your First Transaction
- Gas I: Introduction to Gas
- How Do Blockchains Work?
- Signing Transactions
- Gas II
- Gas II Summary
- High-Level Blockchain Fundamentals
Lesson 2: Welcome to Remix - Remix Simple Storage
- Introduction
- Setting Up Your First Contract
- Basic Solidity: Types
- Basic Solidity: Functions
- Basic Solidity: Arrays & Structs
- Basic Solidity: Compiler Errors and Warnings
- Memory, Storage, Calldata (Intro)
- Mappings
- Deploying your First Contract
- The EVM & A Recap of Lesson 2
Lesson 3: Remix Storage Factory
- Introduction
- Basic Solidity: Importing Contracts into other Contracts
- Basic Solidity: Interacting with other Contracts
- Basic Solidity: Inheritance & Overrides
- Lesson 3 Recap
Lesson 4: Remix Fund Me
- Introduction
- Setup
- Sending ETH through a function
- Reverts
- Getting real world price data (Chainlink)
- Quick recap I
- Interfaces
- AI Help III
- Importing from NPM / GitHub
- Getting Prices from Chainlink
- More solidity math
- msg.sender
- Quick recap II
- Library
- SafeMath
- For Loop
- Resetting an array
- Transfer, Send, and Call
- Constructor
- Modifiers
- Testnet Demo
- Advanced Solidity
- Immutable & Constant
- Custom Errors
- Receive & Fallback Functions
Lesson 5: AI Prompting, Asking Questions, and Getting Help
- Intro
- 7 Tips for this Course
- Setting up GitHub
- Formatting a question
- SpeedRunEthereum
Lesson 6: Foundry Simple Storage
- Introduction
- Installation & Setup (MacOS & Linux)
- Windows Setup
- Gitpod
- Local Development Introduction
- Foundry Install
- VSCode Setup II
- Foundry Setup
- Formatting Solidity in VSCode
- Compiling in Foundry
- Deploying to a local chain I (Anvil or Ganache)
- Adding another network to metamask
- Deploying to a local chain II (Forge Create)
- Private Key Rant I
- Deploying to a local chain III (Forge Script)
- What is a transaction (But actually)
- Private Key R ant II
- Can you Encrypt a Private Key -> a keystore in foundry yet??
- ThirdWeb Deploy
- Private Key Rant Summary:
- Cast Send
- Deploying to a testnet or a mainnet
- Verifying a contract the manual way
- Cleaning up the project
- Alchemy
- Summary
Lesson 7: Foundry Fund Me
- Introduction
- Setup
- Testing Introduction
- Setup Continued
- Tests
- Debugging Tests I
- Advanced Deploy Scripts I
- Forked Tests
- Refactoring I: Testing Deploy Scripts
- Refactoring II: Helper Config
- Refactoring III: Mocking (continued)
- Magic Numbers
- Break time!
- More Cheatcodes
- More Coverage
- Chisel
- Gas: Cheaper Withdraw
- Storage
- Gas: Cheaper Withdraw (continued)
- Interactions.s.sol
- Makefile
- Pushing to GitHub
- 🐸🐦 Tweet Me (add your repo in)!
- Recap
Lesson 8: Html/Js Fund Me (Quick Fullstack / Front End Tutorial)
- Introduction
- Setup
- How metamask works with your browser
- Introduction to function selectors
- Recap
Lesson 9: Foundry Smart Contract Lottery
- Introduction
- Raffle.sol Setup
- Solidity Contract Layout
- Custom Errors
- Events
- block.timestamp
- Chainlink VRF
- Sub-Lesson: Chainlink VRF
- Implementing Chainlink VRF - Introduction
- Implementing Chainlink VRF - The Request
- Implementing Chainlink VRF - The FulFill
- Chainlink VRF Recap
- Modulo
- Enum
- Resetting an array
- Note on building
- CEI
- Introduction to Chainlink Automation
- Implementing Chainlink Keepers - checkUpkeep
- Enums
- Implementing Chainlink Keepers - checkUpkeep continued
- Implementing Chainlink Keepers - performUpkeep
- Mid-Lesson Recap
- Tests & Deploy Script Setup
- Mock Chainlink VRF Coordinator
- Tests & Deploy Script Continued
- Lots of Tests
- Testing Events in Foundry
- vm.roll & vm.warp
- Create Subscription Script
- Create Subscription from the UI
- Fund Subscription Script
- Add Consumer Script
- More Tests
- PerformUpkeep Tests
- Getting Event Data into Foundry Scripts
- Intro to Fuzz tests
- One Big Test
- Passing the private key to vm.startBroadcast
- Integrations Test
- Testnet Demo - Makefile setup
- Testnet Demo - The Demo
- Console.log Debugging
- forge test --debug
- Recap
- Recommended LINK amounts for Sepolia Staging Test:
Lesson 10: Foundry ERC20s
- What is an ERC? What is an EIP?
- What is an ERC20?
- Manually Creating an ERC20 Token
- ERC20 Token - Openzeppelin
- Deploy Script
- AI Tests
- Lesson 10 Recap
Lesson 11: Foundry NFTs | MoodNFT
- Introduction
- What is an NFT?
- Foundry Setup
- IPFS
- Using IPFS
- Basic NFT: Deploy Script
- Basic NFT: Tests
- Basic NFT: Interactions
- Basic NFT: Testnet Demo
- The issue with IPFS & HTTPS TokenURI NFTs
- What is an SVG?
- SVG NFT: Introduction
- SVG NFT: Encoding the NFT
- SVG NFT: Flipping the mood
- SVG NFT: Deploy Script
- SVG NFT: Debugging practice & some notes
- SVG NFT: Anvil Demo
- Advanced: EVM Opcodes, Encoding, and Calling
- abi.encode & abi.encodePacked
- Introduction to Encoding Function Calls Directly
- Introduction to Encoding Function Calls Recap
- Encoding Function Calls Directly
- Verifying Metamask Transactions
- Filecoin & Arweave
- Lesson 11 Recap
Lesson 12: Foundry DeFi | Stablecoin (The PINNACLE PROJECT!! GET HERE!)
- What is DeFi?
- Code Walkthrough
- What is a stablecoin (But actually)
- DecentralizedStableCoin.sol
- DSCEngine.sol Setup
- Deposit Collateral
- Mint DSC
- Getting the value of our collateral
- Health Factor
- Minting the DSC
- Testing while developing
- Deploy Script
- Tests
- depositCollateralAndMintDsc
- redeemCollateral
- Liquidate
- Setup
- Refactoring
- Leveling up your testing skillz
- Challenge: Code coverage above 80% for DSCEngine.sol
- Fuzz (Invariant) Testing
- Open-based Fuzz tests
- Handler-based Fuzz tests
- revert_on_fail = true
- Redeeming Collateral
- Minting DSC
- Debuggin Fuzz Tests
- Challenge: Find out why `mintDsc` is never being called on our Handler.sol
- Price Feed Handling
- OracleLib
- Note on audit preparedness
- Recap
- Lens Protocol
- More DeFi Learnings:
Lesson 13: Foundry Upgrades
- Upgradable Smart Contracts Overview
- Types of Upgrades
- Delegatecall
- Small Proxy Example
- Universal Upgradable Smart Contract
- Setup
- Initializer
- Deploy
- UpgradeBox
- Test / Demo
- Testnet Demo
Lesson 14: Foundry DAO / Governance
- Introduction
- What is a DAO?
- How to build a DAO
- Setup
- Governance Token
- Governor
- Tests
- Wrap up
- Bonus: Gas optimization tips
Lesson 15: Smart Contract Security & Auditing (For developers)
- Introduction
- What is a smart contract audit?
- What does the process of manual review look like?
- Tools
- Manual Review
- Static Analysis
- Dynamic Analysis
- Formal Verification
- Symbolic Execution
- Fuzzing
- Formal Verification (& Symbolic Execution)
- Other security stuff
- Closing Thoughts
Congratulations
- Where do I go now?
- Learning More
- Community
- Hackathons
Disclosures
Thank you
Recommended Tools
- Recommended Testnet: Sepolia
- Recommended DevOps: foundry-devops
Testnet Faucets
- Main Faucet: https://faucets.chain.link
- Backup Faucet: https://sepoliafaucet.com/
⚠️ All code associated with this course is for demo purposes only. They have not been audited and should not be considered production ready. Please use at your own risk.
Resources For This Course
- AI Frens
-
ChatGPT
- Just know that it will often get things wrong, but it's very fast!
-
Phind
- Like ChatGPT, but it searches the web
- Bard
- Other AI extensions
-
ChatGPT
- Github Discussions
- Ask questions and chat about the course here!
-
Stack Exchange Ethereum
- Great place for asking technical questions about Ethereum
-
Peeranha
- Decentralized Stack Exchange!
Bonus NFTs
These are 100% optional to do.
After every lesson, you'll see two QR codes. Those codes will send you to an NFT deployed to Sepolia or Arbitrum. They contain a challenge for you to solve, and in return, you'll be given an AWESOME NFT.
Important Notes for Arbitrum
IF YOU DECIDE TO MINT THE REAL NFT:
- We didn't audit the NFT, so if you want to make sure you'll be safe, interact with the contract using a burner wallet (a wallet with very little money that you don't use for anything else)
- In fact... Get good at interacting with wallets from a burner wallet
- Read my Tweet thread on basic wallet safety
- It might be a good idea to wait till later in the course when we teach you about verifying metamask transactions.
- Feel free to mint NFTs on sepolia without worrying about the above
Bridging to Arbitrum
- We didn't show you how to bring ETH -> Arbitrum, but the process would be:
- Send ETH -> one of your wallets like:
- Use the Arbitrum Bridge
Video 1
Lesson 0: Welcome to the Course!
Welcome to the Course!
⭐️ (0:00:00) | Lesson 0: Welcome!
Best Practices
- Follow the repository: While going through the course be 100% certain to follow along with the github repository. If you run into in an issue check the chronological-updates in the repo.
- Be Active in the community: Ask questions and engage with other developers going through the course in the discussions tab, be sure to go and say hello or gm! This space is different from the other industries, you don't have to be secretive; communicate, network and learn with others :)
- Learn at your own pace: It doesn't matter if it takes you a day, a week, a month or even a year. Progress >>> Perfection
- Take Breaks: You will exhaust your mind and recall less if you go all out and watch the entire course in one sitting. Suggested Strategy every 25 minutes take a 5 min break, and every 2 hours take a longer 30 min break
- Refer to Documentation: Things are constantly being updated, so whenever Patrick opens up some documentation, open it your end and maybe even have the code sample next to you.
- Use ChatGPT and/or the course chat
Lesson 1: Blockchain Basics
⭐️ (0:13:54) | Lesson 1: Blockchain Basics
What is a Blockchain? What does a blockchain do?
- Bitcoin Whitepaper
- Ethereum Whitepaper
- What is a Smart Contract?
- Nick Szabo
- Hybrid Smart Contracts
- Blockchain Oracles
- Terminology
- Web3
- What is a blockchain
The Purpose Of Smart Contracts
⌨️ (0:24:26) | The Purpose Of Smart Contracts
- 🎥 Original Video
- 🦬 My ETH Denver Talk
- 🍔 McDonalds Scandal
- ⛓ More on the evolution of agreements
- ✍️ What is a Smart Contract?
- 🧱 How does a blockchain work?
- 🔮 Chainlink & Oracles
Other Blockchain Benefits
⌨️ (0:39:53) | Other Blockchain Benefits
- Decentralized
- Transparency & Flexibility
- Speed & Efficiency
- Security & Immutability
- Counterparty Risk Removal
- Trust Minimized Agreements
What have Smart Contracts done so far?
⌨️ (0:44:20) | What have Smart Contracts done so far?
Making Your First Transaction
⌨️ (0:46:55) | Making Your First Transaction
- Metamask Download Link
- Etherscan
- Sepolia Etherscan
- Sepolia Faucet (Check the link token contracts page)
- NOTE: The Chainlink documentation always has the most up to date faucets on their link token contracts page. If the faucet above is broken, check the chainlink documentation for the most up to date faucet.
- OR, use the Sepolia ETH Faucet, just be sure to swap your metamask to Sepolia!
Gas I: Introduction to Gas
⌨️ (1:06:16) | Gas I: Introduction to Gas
How Do Blockchains Work?
⌨️ (1:15:39) | How Do Blockchains Work?
Signing Transactions
⌨️ (1:33:09) | Signing Transactions
Gas II
- Block Rewards
- Advanced Gas
- EIP 1559
- GWEI, WEI, and ETH
Gas II Summary
High-Level Blockchain Fundamentals
⌨️ (1:51:36) | High-Level Blockchain Fundamentals
Lesson 2: Welcome to Remix - Remix Simple Storage
💻 Code: https://github.com/cyfrin/remix-simple-storage-f23
Introduction
⭐️ (2:10:42) | Lesson 2: Welcome to Remix - Simple Storage
Setting Up Your First Contract
⌨️ () Setting Up Your First Contract
- Versioning
- Take notes in your code!
- What is a software license
- SPDX License
- Compiling
- Contract Declaration
Basic Solidity: Types
⌨️ () Basic Solidity Types
-
Types & Declaring Variables
-
uint256
,int256
,bool
,string
,address
,bytes32
- Solidity Types
- Bits and Bytes
-
- Default Initializations
- Comments
Basic Solidity: Functions
⌨️ () Basic Solidity Functions
- Functions
- Deploying a Contract
- Smart Contracts have addresses just like our wallets
- Calling a public state-changing Function
- Visibility
- Gas III | An example
- Scope
- View & Pure Functions
Basic Solidity: Arrays & Structs
⌨️ () Basic Solidity Arrays & Structs
- Structs
- Intro to Storage
- Arrays
- Dynamic & Fixed Sized
-
push
array function
Basic Solidity: Compiler Errors and Warnings
⌨️ () Basic Solidity Errors & Warnings
- Yellow: Warnings are Ok
- Red: Errors are not Ok
Memory, Storage, Calldata (Intro)
⌨️ () Basic Solidity Memory, Storage, & Calldata (Intro)
- 6 Places you can store and access data
- calldata
- memory
- storage
- code
- logs
- stack
Mappings
⌨️ () Basic Solidity Mappings
Deploying your First Contract
⌨️ () Deploying your First Contract
- A testnet or mainnet
- Connecting Metamask
- Find a faucet here
- See the faucets at the top of this readme!
- Interacting with Deployed Contracts
The EVM & A Recap of Lesson 2
⌨️ () The EVM & A Recap of Lesson 2
- The EVM
Lesson 3: Remix Storage Factory
💻 Code: https://github.com/cyfrin/remix-storage-factory-f23
Introduction
⭐️ (3:29:58) | Lesson 3 | Storage Factory
Basic Solidity: Importing Contracts into other Contracts
⌨️ () Importing Contracts into other Contracts
Basic Solidity: Interacting with other Contracts
⌨️ () Interacting with other contracts
- To interact, you always need: ABI + Address
- ABI
Basic Solidity: Inheritance & Overrides
⌨️ () Inheritance & Overrides
Lesson 3 Recap
⌨️ () Lesson 3 Recap
Lesson 4: Remix Fund Me
💻 Code: https://github.com/Cyfrin/remix-fund-me-f23
Introduction
⭐️ (4:09:08) | Lesson 4 | Fund Me
Setup
Sending ETH through a function
Reverts
Getting real world price data (Chainlink)
- What is a blockchain oracle?
- What is the oracle problem?
- Chainlink
- Chainlink Price Feeds (Data Feeds)
- Chainlink VRF
- Chainlink Keepers
- Chainlink API Calls
- Importing Tokens into your Metamask
- Request and Receive Chainlink Model
Quick recap I
Interfaces
AI Help III
Importing from NPM / GitHub
Getting Prices from Chainlink
More solidity math
- Multiply before you divide
- tuple
- Floating Point Numbers in Solidity
- Type Casting
- Gas Estimation Failed
- Someone should make an article explaining this error
msg.sender
- msg.sender
- named mappings
Quick recap II
Library
SafeMath
For Loop
- For Loop
-
/* */
is another way to make comments
Resetting an array
Transfer, Send, and Call
Constructor
Modifiers
Testnet Demo
Advanced Solidity
Immutable & Constant
- Immutable
- Constant
- Current ETH Gas Prices
- Don't stress about gas optimizations! (yet)
- Naming Conventions
Custom Errors
Receive & Fallback Functions
Lesson 5: AI Prompting, Asking Questions, and Getting Help
DO NOT SKIP THIS!!
⭐️ (6:00:00) | Lesson 5 | AI Prompting
Intro
7 Tips for this Course
Setting up GitHub
Formatting a question
- It's a good idea to ask your AI buddy to format your questions in markdown *
SpeedRunEthereum
- Special Guest Austin
Lesson 6: Foundry Simple Storage
💻 Code: https://github.com/Cyfrin/foundry-simple-storage-f23
Introduction
⭐️ (6:00:00) | Lesson 6 | Foundry Simple Storage
Installation & Setup (MacOS & Linux)
Windows Setup
- Special Guest Vasiliy
-
WSL
- When working in WSL, use Linux commands instead of Windows commands
- TroubleShooting
-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
⚠️ Please use Gitpod as an absolute last resort
Gitpod
-
Gitpod
- If using this, NEVER share a private key with real money on Gitpod
- Ideally you figure out the MacOS, Linux, or Windows install though
Local Development Introduction
-
CMD + K
orCTRL + K
clears the terminal -
mkdir ethers-simple-storage-fcc
-
code .
to open VSCode in a new VSCode window
Foundry Install
VSCode Setup II
- CoPilot
- Copilot labs
- Hardhat Solidity Extension
- VSCodium
-
mkdir foundry-f23
Foundry Setup
- FreeCodeCamp Bash
Formatting Solidity in VSCode
- Format your solidity code with in your
settings.json
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"[javascript]":{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
Compiling in Foundry
Deploying to a local chain I (Anvil or Ganache)
Adding another network to metamask
Deploying to a local chain II (Forge Create)
- 2 Ways to deploy:
-
-
forge create
-
-
-
forge script
-
-
Private Key Rant I
-
history -c
Deploying to a local chain III (Forge Script)
What is a transaction (But actually)
cast --to-base 0x01 dec
Private Key R ant II
-
cast send
-
source .env
Can you Encrypt a Private Key -> a keystore in foundry yet??
A: No
ThirdWeb Deploy
- Special Guest Ciara
- nodejs install
- npm install
- thirdweb
Private Key Rant Summary:
Summary:
When you look to deploy
with real money, you should use either:
1. A password encrypted keystore
2. Something like thirdweb deploy
The idea is you never want to have
your private key or password
ANYWHERE written in plain text
(Aka, you always want it encrypted)
Cast Send
Deploying to a testnet or a mainnet
Verifying a contract the manual way
Cleaning up the project
-
forge fmt
-
README.md
Alchemy
Summary
🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊
Completed Video 1!!
🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊
Video 2: https://youtu.be/sas02qSFZ74
Lesson 7: Foundry Fund Me
⭐️ (0:00:00) | Lesson 7: Foundry Fund Me
💻 Code:https://github.com/Cyfrin/foundry-fund-me-f23
Introduction
Setup
Testing Introduction
Setup Continued
Tests
Debugging Tests I
Advanced Deploy Scripts I
Forked Tests
- 4 types of testing:
1. Unit: Testing a single function
2. Integration: Testing multiple functions
3. Forked: Testing on a forked network
4. Staging: Testing on a live network (testnet or mainnet)
Refactoring I: Testing Deploy Scripts
Refactoring II: Helper Config
- block.chainid
-
Chain ID List
- 11155111 is ETH Sepolia
- 1 is ETH Mainnet
Refactoring III: Mocking (continued)
- Mocking
- Chainlink Github
- Multiple Versions of Solidity
Magic Numbers
Break time!
Take a break!
More Cheatcodes
More Coverage
- State tree testing
- Arrange, Act, Assert
- hoax
- uint160 -> address
- vm.startPrank
Chisel
Gas: Cheaper Withdraw
- Gas Reporter
-
forge snapshot
-
vm.txGasPrice
-
gasLeft()
-
tx.getprice
Storage
** Advanced **
cast storage
- Opcodes
- Opcodes by Gas
- Opcodes by Gas
- Append
s_
to storage variables - Append
i_
to immutable variables - Caps lock and underscore constant variables
- Chainlink Solidity Style Guide
Gas: Cheaper Withdraw (continued)
- evm.codes
- Style Guide
- NatSpec
Interactions.s.sol
Makefile
Pushing to GitHub
- Add these to your
.gitignore
-
.env
-
lib/
-
broadcast/
-
- Git Docs
- GitHub docs
- Github Quickstart
- What is Git?
- The quickstart that we follow in the video
- Learn about git and GitHub
🐸🐦 Tweet Me (add your repo in)!
Recap
Lesson 8: Html/Js Fund Me (Quick Fullstack / Front End Tutorial)
⭐️ (2:37:02) | Lesson 8: HTML Fund Me
💻 Code: https://github.com/Cyfrin/html-fund-me-f23
Introduction
Setup
How metamask works with your browser
Introduction to function selectors
Recap
Lesson 9: Foundry Smart Contract Lottery
⭐️ (3:04:09) | Lesson 9: Smart Contract Lottery
💻 Code: https://github.com/Cyfrin/foundry-smart-contract-lottery-f23
Introduction
Raffle.sol Setup
- Raffle.sol Setup
Solidity Contract Layout
// Layout of Contract:
// version
// imports
// errors
// interfaces, libraries, contracts
// Type declarations
// State variables
// Events
// Modifiers
// Functions
// Layout of Functions:
// constructor
// receive function (if exists)
// fallback function (if exists)
// external
// public
// internal
// private
// internal & private view & pure functions
// external & public view & pure functions
Custom Errors
- Custom Errors in Solidity
Events
- Introduction to Events
- Events & Logging Video
- Events & Logging in Hardhat
block.timestamp
Chainlink VRF
- Introduction to Chainlink VRF
- Special Guest Richard
Sub-Lesson: Chainlink VRF
- Chainlink VRFv2 Docs
- Chainlink VRFv2 Walkthrough
- Chainlink Contracts
Implementing Chainlink VRF - Introduction
- Implementing Chainlink VRF
Implementing Chainlink VRF - The Request
Implementing Chainlink VRF - The FulFill
Chainlink VRF Recap
Modulo
- Modulo
Enum
Resetting an array
Note on building
CEI
Introduction to Chainlink Automation
- Chainlink Automation Docs
- Chainlink Automation Walkthrough
Implementing Chainlink Keepers - checkUpkeep
Enums
- Enum
Implementing Chainlink Keepers - checkUpkeep continued
- block.timestamp
Implementing Chainlink Keepers - performUpkeep
Mid-Lesson Recap
Tests & Deploy Script Setup
Mock Chainlink VRF Coordinator
Tests & Deploy Script Continued
Lots of Tests
Testing Events in Foundry
vm.roll & vm.warp
Create Subscription Script
Create Subscription from the UI
Fund Subscription Script
Add Consumer Script
More Tests
-
forge coverage --report debug
PerformUpkeep Tests
- Expecting Custom Errors
Getting Event Data into Foundry Scripts
-
vm.recordLogs
Intro to Fuzz tests
One Big Test
Passing the private key to vm.startBroadcast
Integrations Test
Testnet Demo - Makefile setup
Testnet Demo - The Demo
Console.log Debugging
forge test --debug
Recap
Recommended LINK amounts for Sepolia Staging Test:
- Chainlink VRF: 2 LINK
- Chainlink Keepers: 8 LINK
Lesson 10: Foundry ERC20s
⭐️ (7:07:04) | Lesson 10: ERC20s
💻 Code: https://github.com/Cyfrin/foundry-erc20-f23
What is an ERC? What is an EIP?
- What is an EIP?
- EIPs codebase
What is an ERC20?
- Video (using brownie/python)
- EIP-20
- ERC-677
- EIP-777
Manually Creating an ERC20 Token
-
.github
ERC20 Token - Openzeppelin
- Openzeppelin
- Openzeppelin Contracts
- Solmate (Openzeppelin alternative)
Deploy Script
AI Tests
Lesson 10 Recap
Lesson 11: Foundry NFTs | MoodNFT
⭐️ (7:40:56) | Lesson 11: NFTs
💻 Code: https://github.com/Cyfrin/foundry-nft-f23
Introduction
What is an NFT?
- Video
- [Optional: All on Chain SVG NFT]
- EIP-721
Foundry Setup
- TokenURI
- Pudgy Penguin Example
IPFS
Using IPFS
Basic NFT: Deploy Script
Basic NFT: Tests
- Comparing strings in solidity
-
chisel
Basic NFT: Interactions
Basic NFT: Testnet Demo
The issue with IPFS & HTTPS TokenURI NFTs
What is an SVG?
SVG NFT: Introduction
SVG NFT: Encoding the NFT
SVG NFT: Flipping the mood
SVG NFT: Deploy Script
SVG NFT: Debugging practice & some notes
SVG NFT: Anvil Demo
Advanced: EVM Opcodes, Encoding, and Calling
abi.encode & abi.encodePacked
- abi.encode
- abi.encodePacked Thanks to Alex Roan for his help on this session!
- Example Contract Creation Transaction What REALLY is the ABI?
- EVM Opcodes
- More EVM Opcodes
- Solidity Cheatsheet
- abi.encode vs abi.encodePacked
Introduction to Encoding Function Calls Directly
Introduction to Encoding Function Calls Recap
Encoding Function Calls Directly
- Function Selector
- Function Signature
Verifying Metamask Transactions
- Check the address
- Check the function selector
- Decode the calldata
Filecoin & Arweave
- Special Guest Ally
Lesson 11 Recap
🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊
Completed Video 2!!
🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊
Lesson 12: Foundry DeFi | Stablecoin (The PINNACLE PROJECT!! GET HERE!)
💻 Code: https://github.com/Cyfrin/foundry-defi-stablecoin-f23
Introduction
⭐️ (0:00:00) | Lesson 12: DeFi Stablecoins
What is DeFi?
- What is DeFi?
- DefiLlama
- Bankless
- MEV
- Aave
- My Previous Aave Video on Shorting Assets
- DAI
- Uniswap
- Maximal Extractable Value (MEV)
Code Walkthrough
What is a stablecoin (But actually)
- Video
- MakerDAO Forums
DecentralizedStableCoin.sol
DSCEngine.sol Setup
Deposit Collateral
- Other DeFi Examples:
Mint DSC
Getting the value of our collateral
Health Factor
Minting the DSC
Testing while developing
Deploy Script
Tests
depositCollateralAndMintDsc
redeemCollateral
Liquidate
Setup
Refactoring
Leveling up your testing skillz
Challenge: Code coverage above 80% for DSCEngine.sol
Fuzz (Invariant) Testing
Open-based Fuzz tests
Handler-based Fuzz tests
revert_on_fail = true
Redeeming Collateral
Minting DSC
Debuggin Fuzz Tests
Challenge: Find out why mintDsc
is never being called on our Handler.sol
Price Feed Handling
OracleLib
Note on audit preparedness
Recap
Lens Protocol
- Special Guest Nader
- Lens Protocol
More DeFi Learnings:
QR Code for Lesson 12 Arbitrum:
QR Code for Lesson 12 Arbitrum:
Lesson 13: Foundry Upgrades
💻 Code: https://github.com/Cyfrin/foundry-upgrades-f23
Introduction
⭐️ (4:47:00) | Lesson 13: Upgradable Contracts & Proxies
Upgradable Smart Contracts Overview
Types of Upgrades
- Parameter
- Social Migrate
- Proxy
Delegatecall
Small Proxy Example
Universal Upgradable Smart Contract
Setup
- UUPS vs Transparent
- Abstract Contracts
Initializer
Deploy
- ERC-1967
UpgradeBox
Test / Demo
Testnet Demo
Lesson 14: Foundry DAO / Governance
Plutocracy is bad! Don't default to ERC20 token voting!!
💻 Code: https://github.com/Cyfrin/foundry-dao-f23
Introduction
⭐️ (6:05:45) | Lesson 14 | DAOs & Governance
What is a DAO?
- What is a DAO?
- Special Guest Juliette
How to build a DAO
Setup
- How to build a DAO
- That's Patrick
- PY Code
- Python Video
Governance Token
Governor
Tests
Wrap up
Bonus: Gas optimization tips
- Special Guest Harrison
Lesson 15: Smart Contract Security & Auditing (For developers)
Developers 100% should know all about this! Don't leave the course without at least watching this section!
🖥️ Code: https://github.com/PatrickAlphaC/denver-security
Introduction
⭐️ (7:21:12) | Lesson 15 | Security & Auditing
What is a smart contract audit?
What does the process of manual review look like?
Tools
Manual Review
Static Analysis
Dynamic Analysis
Formal Verification
Symbolic Execution
Fuzzing
Formal Verification (& Symbolic Execution)
Other security stuff
Closing Thoughts
- Common Attacks
- Best Practices
- Attacks
- Damn Vulnerable Defi
- Ethernaut
- Top Smart Contract Auditors
- Some Smart Contract Auditors:
Congratulations
🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed The Course! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊
Where do I go now?
Learning More
- Top 10 learning resources
- Patrick Collins
- CryptoZombies
- Alchemy University
- Speed Run Ethereum
- Ethereum.org
Community
Hackathons
Be sure to check out project grant programs!
And make today an amazing day!
Disclosures
Transparency is important! So we want to disclose any potential conflicts that might have affected my judgement so you can pick tools that are right for you. Patrick is co-founder of Alpha Chain, a blockchain infrastructure company. Alpha Chain runs chainlink, ethereum, binance, polygon, harmony, solana, moonbeam, and moonriver blockchain services. Alpha Chain often works with Alchemy and recieves discounted servies. Patrick is co-founder of Cyfrin, and they do smart contract security & auditing services. Patrick is a co-founder of Chain Accel, who are an advisor on the Peeranha project. Patrick is an advisor on the Chainlink project. The Cyfrin team often does buisness on the Arbitrum L2.
Because of all this, I have added alternatives to each section where we suggest a tool. This video & course was created and sponsored solely by the Cyfrin team.
Thank you
Thanks to everyone who is taking, participating in, and working on this course. It's been a passion project and a data dump of everything I've learnt in the web3 space to get you up to speed quickly. Also, a big thank you to Cyfrin & Chain Accel for encouraging this course to come to light, and many, many, many people from the community.
And thanks to the Cyfrin team for making this possible!