Code Monkey home page Code Monkey logo

foundry-full-course-f23's Introduction

Entire course and video content updated June 15, 2024

Blockchain Developer, Smart Contract, & Solidity Career Path - Powered By AI - Beginner to Expert Course
| Foundry Edition 2024 |

Learn smart contract development, and level up your career

Stargazers Forks Contributors Issues MIT License



Welcome to the repository for the Blockchain Developer, Smart Contract, & Solidity Cyfrin Updraft - Career Path
| Powered By AI |
| Beginner to Expert Path |
| Foundry Edition 2024 |

This repository houses course resources and discussions for the course.

Please refer to this for an in-depth explanation of the content:

  • Website - Join Cyfrin Updraft and enjoy 50+ hours of smart contract development courses
  • Twitter - Stay updated with the latest course releases
  • LinkedIn - Add Updraft to your learning experiences
  • Discord - Join a community of 3000+ developers and auditors
  • Newsletter - Weekly security research tips and resources to level up your career
  • Codehawks - Smart contracts auditing competitions to help secure web3

Sections 0 - 6 Sections 7 - 11 Sections 12 - 15
Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI 1 Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI 2 Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI 3

Cyfrin Updraft Courses:

YouTube Playlist

YouTube Playlist of each section

Table of Contents

All the sections for on this repo are for several courses on the Solidity Developer Career path of Cyfrin Updraft.

Resources
  1. Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course | Foundry Edition 2024
  2. Table of Contents
  3. Testnet Faucets
  4. Resources For This Course
  5. Bonus NFTs
Section 0: Welcome to the Course!
  1. Welcome to the course!
  2. Best Practices
Section 1: Blockchain Basics
  1. What is a Blockchain? What does a blockchain do?
  2. The Purpose Of Smart Contracts
  3. Other Blockchain Benefits
  4. What have Smart Contracts done so far?
  5. Making Your First Transaction
  6. Gas I: Introduction to Gas
  7. How Do Blockchains Work?
  8. Signing Transactions
  9. Gas II
  10. Gas II Summary
  11. High-Level Blockchain Fundamentals
  12. L1s L2s and Rollups
  13. Rollup Stages
  14. Making your First Transaction on zkSync
  15. Why zkSync is our Recommended Chain
Section 2: Welcome to Remix - Remix Simple Storage
  1. Introduction
  2. Setting Up Your First Contract
  3. Basic Solidity: Types
  4. Basic Solidity: Functions
  5. Basic Solidity: Arrays & Structs
  6. Basic Solidity: Compiler Errors and Warnings
  7. Memory, Storage, Calldata (Intro)
  8. Mappings
  9. Deploying your First Contract
  10. The EVM & A Recap of Section 2
Section 3: Remix Storage Factory
  1. Introduction
  2. Basic Solidity: Importing Contracts into other Contracts
  3. Basic Solidity: Interacting with other Contracts
  4. Basic Solidity: Inheritance & Overrides
  5. Section 3 Recap
Section 4: Remix Fund Me
  1. Introduction
  2. Setup
  3. Sending ETH through a function
  4. Reverts
  5. Getting real world price data (Chainlink)
  6. Quick recap I
  7. Interfaces
  8. AI Help III
  9. Importing from NPM / GitHub
  10. Getting Prices from Chainlink
  11. More solidity math
  12. msg.sender
  13. Quick recap II
  14. Library
  15. SafeMath
  16. For Loop
  17. Resetting an array
  18. Transfer, Send, and Call
  19. Constructor
  20. Modifiers
  21. Testnet Demo
  22. Advanced Solidity
  23. Section 4 Recap
Section 5: AI Prompting, Asking Questions, and Getting Help
  1. Intro
  2. 7 Tips for this Course
  3. Setting up GitHub
  4. Formatting a question
  5. SpeedRunEthereum
Section 6: Foundry Simple Storage
  1. Introduction
  2. Installation & Setup (MacOS & Linux)
  3. Local Development Introduction
  4. Foundry Install
  5. VSCode Setup II
  6. Foundry Setup
  7. Formatting Solidity in VSCode
  8. Compiling in Foundry
  9. Deploying to a local chain I (Anvil or Ganache)
  10. Adding another network to metamask
  11. Deploying to a local chain II (Forge Create)
  12. Private Key Rant I
  13. Deploying to a local chain III (Forge Script)
  14. What is a transaction (But actually)
  15. Private Key Rant II
  16. Can you Encrypt a Private Key -> a keystore in foundry yet??
  17. ThirdWeb Deploy
  18. Private Key Rant Summary:
  19. Cast Send
  20. Deploying to a testnet or a mainnet
  21. Verifying a contract the manual way
  22. Cleaning up the project
  23. Alchemy and the mempool
  24. Summary
Section 7: Foundry Fund Me
  1. Introduction
  2. Setup
  3. Testing Introduction
  4. Setup Continued
  5. Tests
  6. Debugging Tests I
  7. Advanced Deploy Scripts I
  8. Forked Tests
  9. Refactoring I: Testing Deploy Scripts
  10. Refactoring II: Helper Config
  11. Refactoring III: Mocking (continued)
  12. Magic Numbers
  13. Break time!
  14. More Cheatcodes
  15. More Coverage
  16. Chisel
  17. Gas: Cheaper Withdraw
  18. Storage
  19. Gas: Cheaper Withdraw (continued)
  20. Interactions.s.sol
  21. Makefile
  22. Pushing to GitHub
  23. Recap
Section 8: Html/Js Fund Me (Quick Fullstack / Front End Tutorial)
  1. Introduction
  2. Setup
  3. How metamask works with your browser
  4. Introduction to function selectors
  5. Recap
Section 9: Foundry Smart Contract Lottery
  1. Introduction
  2. Raffle.sol Setup
  3. Solidity Contract Layout
  4. Custom Errors
  5. Events
  6. block.timestamp
  7. Chainlink VRF
  8. Implementing Chainlink VRF - Introduction
  9. Modulo
  10. Enum
  11. Resetting an array
  12. Note on building
  13. CEI
  14. Introduction to Chainlink Automation
  15. Implementing Chainlink Keepers - checkUpkeep
  16. Implementing Chainlink Keepers - checkUpkeep continued
  17. Implementing Chainlink Keepers - performUpkeep
  18. Mid-Section Recap
  19. Tests & Deploy Script Setup
  20. Tests & Deploy Script Continued
  21. Lots of Tests
  22. Create Subscription Script
  23. Create Subscription from the UI
  24. Fund Subscription Script
  25. Add Consumer Script
  26. More Tests
  27. PerformUpkeep Tests
  28. Getting Event Data into Foundry Scripts
  29. Intro to Fuzz tests
  30. One Big Test
  31. Passing the private key to vm.startBroadcast
  32. Integrations Test
  33. Testnet Demo - Makefile setup
  34. Testnet Demo - The Demo
  35. Console.log Debugging
  36. forge test --debug
  37. Recap
Section 10: Foundry ERC20s
  1. What is an ERC? What is an EIP?
  2. What is an ERC20?
  3. Manually Creating an ERC20 Token
  4. ERC20 Token - Openzeppelin
  5. Deploy Script
  6. AI Tests
  7. Section 10 Recap
Section 11: Foundry NFTs | MoodNFT
  1. Introduction
  2. What is an NFT?
  3. Foundry Setup
  4. IPFS
  5. Using IPFS
  6. Basic NFT: Deploy Script
  7. Basic NFT: Tests
  8. Basic NFT: Interactions
  9. Basic NFT: Testnet Demo
  10. The issue with IPFS & HTTPS TokenURI NFTs
  11. What is an SVG?
  12. SVG NFT: Introduction
  13. SVG NFT: Encoding the NFT
  14. SVG NFT: Flipping the mood
  15. SVG NFT: Deploy Script
  16. SVG NFT: Debugging practice & some notes
  17. SVG NFT: Anvil Demo
  18. Advanced: EVM Opcodes, Encoding, and Calling
  19. Verifying Metamask Transactions
  20. Filecoin & Arweave
  21. Section 11 Recap
Section 12: Foundry DeFi | Stablecoin (The PINNACLE PROJECT!! GET HERE!)
  1. What is DeFi?
  2. Code Walkthrough
  3. What is a stablecoin (But actually)
  4. DecentralizedStableCoin.sol
  5. DSCEngine.sol Setup
  6. Deposit Collateral
  7. Mint DSC
  8. Testing while developing
  9. depositCollateralAndMintDsc
  10. redeemCollateral
  11. Liquidate
  12. Leveling up your testing skillz
  13. Fuzz (Invariant) Testing
  14. Open-based Fuzz tests
  15. Handler-based Fuzz tests
  16. Price Feed Handling
  17. OracleLib
  18. Note on audit preparedness
  19. Recap
  20. Lens Protocol
Section 13: Foundry Merkle Airdrop and Signatures
  1. Introduction to Merkle Airdrops and Code Walkthrough
  2. Project Setup
  3. Merkle Proofs
  4. Base Airdrop Contract
  5. Already Claimed Check
  6. Merkle Tree Scripts
  7. Writing the Tests
  8. Deployment Script
  9. Adding Signature Verification
  10. Signature Standards
  11. ECDSA Signatures
  12. Transaction Types Introduction
  13. Transaction Types
  14. Blob Transactions
  15. Type 113 Transactions
  16. Implementing Signatures
  17. Modifying the Tests
  18. Test on zkSync (optional)
  19. Create Claiming Script
  20. Creating a Signature
  21. Splitting a Signature
  22. Executing the Anvil Script
  23. Deploy and Claim on zkSync Local Node
  24. Deploy and Claim on zkSync Sepolia
  25. Summary
Section 14: Foundry Upgrades
  1. Introduction
  2. Upgradable Smart Contracts Overview
  3. Types of Upgrades
  4. Delegatecall
  5. Small Proxy Example
  6. Universal Upgradable Smart Contract
  7. Testnet Demo
Section 15: Foundry Account Abstraction
Section 16: Foundry DAO / Governance
  1. Introduction
  2. What is a DAO?
  3. How to build a DAO
  4. Wrap up
  5. Bonus: Gas optimization tips
Section 17: Smart Contract Security & Auditing (For developers)
  1. Introduction
  2. What is a smart contract audit?
  3. Tools
  4. What does the process of manual review look like?
  5. Formal Verification
  6. Closing Thoughts
Congratulations
  1. Where do I go now?

Disclosures

Thank you

Recommended Tools

⚠️ 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.

Chainlist

Resources For This Course

Bonus NFTs

These are 100% optional to do.

After every section, in this GitHub repo will be a link to a contract on Sepolia or zkSync. They contain a challenge for you to solve, and in return, you'll be given an AWESOME NFT.

Important Notes for zkSync

IF YOU DECIDE TO MINT THE REAL NFT:

  1. 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)
    1. In fact... Get good at interacting with wallets from a burner wallet
  2. Read my Tweet thread on basic wallet safety
  3. It might be a good idea to wait till later in the course when we teach you about verifying metamask transactions.
  4. Feel free to mint NFTs on sepolia without worrying about the above

Bridging to zkSync

  1. The process for bridging looks like the following:
    1. Buy ETH (On an exchange like Coinbase or Kraken)
  2. Send ETH -> one of your wallets like:
    1. Metamask
    2. Frame
    3. Rainbow
    4. Argent
    5. Coinbase Wallet
  3. Use the zkSync Bridge

Video 1


Solidity, Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course


Section 0: Welcome to the Course!

Welcome to the Course!

⭐️ (0:00:00) | Section 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 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 on your end and maybe even have the code sample next to you.
  • Use ChatGPT and/or the course chat

(back to top) ⬆️

Section 1: Blockchain Basics

⭐️ (0:13:54) | Section 1: Blockchain Basics

What is a Blockchain? What does a blockchain do?

The Purpose Of Smart Contracts

⌨️ (0:24:26) | The Purpose Of Smart Contracts

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

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

⌨️ (1:42:15) | Gas II

Gas II Summary

⌨️ (1:48:40) | Gas II Summary

High-Level Blockchain Fundamentals

⌨️ (1:51:36) | High-Level Blockchain Fundamentals

L1s L2s and Rollups

Rollup Stages

Making your First Transaction on zkSync

Why zkSync is our Recommended Chain

Section 1 NFTs

(back to top) ⬆️

Section 2: Welcome to Remix - Remix Simple Storage

💻 Code: https://github.com/cyfrin/remix-simple-storage-cu

Introduction

⭐️ (2:10:42) | Section 2: Welcome to Remix - Simple Storage

Setting Up Your First Contract

⌨️ (2:16:40) | Setting Up Your First Contract

Basic Solidity: Types

⌨️ (2:24:09) | Basic Solidity Types

Basic Solidity: Functions

⌨️ (2:31:57) | 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

⌨️ (2:51:29) | Basic Solidity Arrays & Structs

  • Structs
  • Intro to Storage
  • Arrays
  • Dynamic & Fixed Sized
  • push array function

Basic Solidity: Compiler Errors and Warnings

⌨️ (3:03:31) | Basic Solidity Errors & Warnings

  • Yellow: Warnings are Ok
  • Red: Errors are not Ok

Memory, Storage, Calldata (Intro)

⌨️ (3:08:13) | Basic Solidity Memory, Storage, & Calldata (Intro)

  • 6 Places you can store and access data
    • calldata
    • memory
    • storage
    • code
    • logs
    • stack

Mappings

⌨️ (3:14:37) | Basic Solidity Mappings

Deploying your First Contract

⌨️ (3:17:46) | Deploying your First Contract

  • A testnet or mainnet
  • Connecting Metamask
  • Find faucets here!
  • See the faucets at the top of this readme!
  • Interacting with Deployed Contracts

zkSync L2 deploy

  • zkSync compiler edition: 0.8.24

The EVM & A Recap of Section 2

⌨️ (3:27:07) | The EVM & A Recap of Section 2

  • The EVM

Section 2 NFTs

(back to top) ⬆️

Section 3: Remix Storage Factory

💻 Code: https://github.com/cyfrin/remix-storage-factory-cu

Introduction

⭐️ (3:29:58) | Section 3 | Storage Factory

Basic Solidity: Importing Contracts into other Contracts

⌨️ (3:41:30) | Importing Contracts into other Contracts

Basic Solidity: Interacting with other Contracts

⌨️ (3:52:49) | Interacting with other contracts

  • To interact, you always need: ABI + Address
  • ABI

Basic Solidity: Inheritance & Overrides

⌨️ (4:00:44) | Inheritance & Overrides

Section 3 Recap

⌨️ (4:07:37) | Section 3 Recap

Section 3 NFTs

(back to top) ⬆️

Section 4: Remix Fund Me

💻 Code: https://github.com/Cyfrin/remix-fund-me-cu

Introduction

⭐️ (4:09:08) | Section 4 | Fund Me

Setup

⌨️ (4:12:20) | Setup

Sending ETH through a function

⌨️ (4:14:00) | Sending ETH through a function

Reverts

⌨️ (4:18:15) | Reverts

Getting real world price data (Chainlink)

⌨️ (4:22:06) | Getting real world price data (Chainlink)

Quick recap I

⌨️ (4:36:22) | Quick recap I

Interfaces

⌨️ (4:37:08) | Interfaces

AI Help III

⌨️ (4:43:31) | AI Help III

Importing from NPM / GitHub

⌨️ (4:46:03) | Importing from NPM / GitHub

Getting Prices from Chainlink

⌨️ (4:48:07) | Getting Prices from Chainlink

More Solidity math

⌨️ (4:52:00) | More Solidity math

msg.sender

⌨️ (4:58:07) | msg.sender

Quick recap II

⌨️ (4:59:53) | Quick recap II

Library

⌨️ (5:00:46) | Library

SafeMath

⌨️ (5:05:45) | SafeMath

For Loop

⌨️ (5:10:48) | For Loop

  • For Loop
  • /* */ is another way to make comments

Resetting an array

⌨️ (5:15:32) | Resetting an array

Transfer, Send, and Call

⌨️ (5:16:32) | Transfer, Send, and Call

Constructor

⌨️ (5:24:23) | Constructor

Modifiers

⌨️ (5:27:37) | Modifiers

Testnet Demo

⌨️ (5:29:54) | Tesnet Demo

Advanced Solidity

⌨️ (5:34:01) | Advanced Solidity

Immutable & Constant

⌨️ (5:34:53) | Immutable & Constant

Custom Errors

⌨️ (5:42:08) | Custom Errors

Receive & Fallback Functions

⌨️ (5:44:56) | Receive & Fallback Functions

Section 4 Recap

⌨️ (5:57:10) | Section 4 Recap

Section 4 NFTs

(back to top) ⬆️

Section 5: AI Prompting, Asking Questions, and Getting Help

DO NOT SKIP THIS!!

⭐️ (6:00:00) | Section 5 | AI Prompting

Intro

7 Tips for this Course

Setting up GitHub

⌨️ (6:12:57) | Setting up GitHub

Formatting a question

⌨️ (6:14:24) | Formatting a question

  • It's a good idea to ask your AI buddy to format your questions in markdown *

SpeedRunEthereum

⌨️ (6:19:58) | SpeedRunEthereum

Section 5 NFTs

(back to top) ⬆️

Section 6: Foundry Simple Storage

💻 Code: https://github.com/Cyfrin/foundry-simple-storage-cu

Introduction

⭐️ (6:23:59) | Section 6 | Foundry Simple Storage

Installation & Setup (MacOS & Linux)

⌨️ (6:29:44) | Installation & Setup (MacOS & Linux)

Windows Setup (WSL)

⌨️ (6:32:26) | Windows Setup (WSL)

  • 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

⌨️ (6:40:19) | 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 or CTRL + K clears the terminal
  • code . to open VSCode in a new VSCode window

Foundry Install

⌨️ (6:44:37) | Foundry Install

VSCode Setup II

⌨️ (6:52:00) | VSCode Setup II

  • CoPilot
  • Copilot labs
  • Hardhat Solidity Extension
  • VSCodium
  • mkdir foundry-cu
  • cd foundry-cu
  • mkdir foundry-simple-storage-cu

Foundry Setup

⌨️ (6:57:17) | Foundry Setup

  • FreeCodeCamp Bash

Formatting Solidity in VSCode

⌨️ (7:04:19) | 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

⌨️ (7:08:31) | Compiling in Foundry

Compiling to zkSync in foundry-zksync

Deploying to a local chain I (Anvil or Ganache)

⌨️ (7:09:49) | Deploying to a local chain I (Anvil or Ganache)

Adding another network to Metamask

⌨️ (7:17:44) | Adding another network to Metamask

Deploying to a local chain II (Forge Create)

⌨️ (7:19:41) | Deploying to a local chain II (Forge Create)

  • 2 Ways to deploy:
      1. forge create
      1. forge script

Private Key Rant I

⌨️ (7:23:45) | Private Key Rant I

  • history -c

Deploying to a local chain III (Forge Script)

⌨️ (7:26:17) | Deploying to a local chain III (Forge Script)

What is a transaction (But actually)

⌨️ (7:36:02) | What is a transaction (But actually)

cast --to-base 0x01 dec

Private Key Rant II

⌨️ (7:41:41) | Private Key Rant II

  • cast send
  • source .env

Can you Encrypt a Private Key -> a keystore in foundry yet??

⌨️ (7:45:00) | Can you Encrypt a Private Key -> a keystore in foundry yet??

  • A: No Yes, try the new feature by
cast wallet import your-account-name --interactive
Enter private key:
Enter password:
`your-account-name` keystore was saved successfully. Address: address-corresponding-to-private-key
forge script <script> --rpc-url <rpc_url> --account <account_name> --sender <address> --broadcast

ThirdWeb Deploy

⌨️ (7:51:44) | ThirdWeb Deploy

Private Key Rant Summary:

⌨️ (7:56:25) | 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

⌨️ (7:56:40) | Cast Send

Deploying to a testnet or a mainnet

⌨️ (8:00:26) | Deploying to a testnet or a mainnet

Verifying a contract the manual way

⌨️ (8:06:06) | Verifying a contract the manual way

Cleaning up the project

⌨️ (8:07:43) | Cleaning up the project

  • forge fmt
  • README.md

Alchemy and the mempool

⌨️ (8:10:28) | Alchemy and the mempool

Summary

⌨️ (8:21:28) | Summary

Section 6 NFTs

(back to top) ⬆️

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Completed Video 1!!

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊


Solidity, Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course


Section 7: Foundry Fund Me

⭐️ (0:00:00) | Section 7: Foundry Fund Me

💻 Code: https://github.com/Cyfrin/foundry-fund-me-cu

Introduction

⌨️ (0:09) | Introduction

Setup

⌨️ (2:51) | Setup

Testing Introduction

⌨️ (4:40) | Testing Introduction

Setup Continued

⌨️ (6:14) | Setup Continued

Tests

⌨️ (11:54) | Tests

Debugging Tests I

⌨️ (20:45) | Debugging Tests I

Advanced Deploy Scripts I

⌨️ (23:16) | Advanced Deploy Scripts I

Forked Tests

⌨️ (25:47) | Forked Tests

  • The test option -m regex is deprecated. Please use --match-test or --mt instead.
forge test -m testPriceFeedVersionIsAccurate -vvv

is deprecated. Please use

forge test --match-test testPriceFeedVersionIsAccurate -vvv
  • 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

⌨️ (34:17) | Refactoring I: Testing Deploy Scripts

Refactoring II: Helper Config

⌨️ (41:28) | Refactoring II: Helper Config

Refactoring III: Mocking

⌨️ (54:32) | Refactoring III: Mocking

Magic Numbers

⌨️ (58:40) | Magic Numbers

Refactoring III: Mocking (continued)

⌨️ (1:00:45) | Refactoring III: Mocking (continued)

Break time!

⌨️ (1:05:02) | Break time!


Take a break!


More Cheatcodes

⌨️ (1:05:06) | More Cheatcodes

More Coverage

⌨️ (1:17:36) | More Coverage

Chisel

⌨️ (1:32:26) | Chisel

Gas: Cheaper Withdraw

⌨️ (1:33:50) | Gas: Cheaper Withdraw

  • Gas Reporter
  • forge snapshot
  • vm.txGasPrice
  • gasLeft()
  • tx.getprice

Storage

⌨️ (1:38:37) | Storage

cast storage

Gas: Cheaper Withdraw (continued)

⌨️ (1:48:20) | Gas: Cheaper Withdraw (continued)

Interactions.s.sol

⌨️ (1:56:11) | Interactions.s.sol

Makefile

⌨️ (2:10:56) | Makefile

Pushing to GitHub

⌨️ (2:19:17) | Pushing to GitHub

⌨️ (2:34:56) | Tweet Me (add your repo in)!

Section 7: Recap

⌨️ (2:35:13) | Section 7: Recap

Section 7 NFTs

(back to top) ⬆️

Section 8: Html/Js Fund Me (Quick Fullstack / Front End Tutorial)

⭐️ (2:37:02) | Section 8: HTML Fund Me

💻 Code: https://github.com/Cyfrin/html-fund-me-cu

Introduction

Setup

⌨️ (2:38:59) | Setup

How Metamask works with your browser

⌨️ (2:40:25) | How Metamask works with your browser

Introduction to function selectors

⌨️ (2:52:34) | Introduction to function selectors

Recap

⌨️ (3:00:00) | Recap

Section 8 NFTs

  • IPFS hash for website - ipfs://QmdCBj5B188qzXgG1LUCD6aKe6RJHqbSgu7YfPyncDirzh

(back to top) ⬆️

Section 9: Foundry Smart Contract Lottery

⭐️ (3:04:09) | Section 9: Smart Contract Lottery

💻 Code: https://github.com/Cyfrin/foundry-smart-contract-lottery-cu

Introduction

⌨️ (3:04:11) | Introduction

Raffle.sol Setup

⌨️ (3:08:16) | Raffle.sol Setup

  • Raffle.sol Setup

Solidity Contract Layout

⌨️ (3:15:53) | 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

⌨️ (3:17:37) | Custom Errors

  • Custom Errors in Solidity

Events

⌨️ 3:22:00 | Events

  • Introduction to Events
  • Events & Logging Video
  • Events & Logging in Hardhat

block.timestamp

⌨️ (3:33:29) | block.timestamp

Chainlink VRF

⌨️ (3:37:13) | Chainlink VRF

  • Introduction to Chainlink VRF

Sub-Section: Chainlink VRF

  • Chainlink VRFv2 Docs
  • Chainlink VRFv2 Walkthrough
  • Chainlink Contracts

Implementing Chainlink VRF - Introduction

⌨️ (3:47:21) | Implementing Chainlink VRF - Introduction

  • Implementing Chainlink VRF
forge install smartcontractkit/[email protected] --no-commit

Modulo

⌨️ (4:03:32) | Modulo

  • Modulo

Enum

⌨️ (4:08:57) | Enum

Resetting an array

⌨️ (4:13:04) | Resetting an array

Note on building

⌨️ (4:14:31) | Note on building

CEI (Checks, Effects, Interactions)

⌨️ (4:16:00) | CEI (Checks, Effects, Interactions)

Introduction to Chainlink Automation

⌨️ (4:18:31) | Introduction to Chainlink Automation

  • Chainlink Automation Docs
  • Chainlink Automation Walkthrough

Implementing Chainlink Keepers - checkUpkeep

⌨️ (4:33:47) | Implementing Chainlink Keepers - checkUpkeep

Enums

  • Enum

Implementing Chainlink Keepers - checkUpkeep continued

  • block.timestamp

Implementing Chainlink Keepers - performUpkeep

⌨️ (4:40:10) | Implementing Chainlink Keepers - performUpkeep

Mid-Section Recap

⌨️ (4:43:00) | Mid-Section Recap

Tests & Deploy Script Setup

⌨️ (4:44:08) | Tests & Deploy Script Setup

Mock Chainlink VRF Coordinator

⌨️ (4:52:02) | Mock Chainlink VRF Coordinator

Tests & Deploy Script Continued

⌨️ (4:56:25) | Tests & Deploy Script Continued

Lots of Tests

⌨️ (5:04:50) | Lots of Tests

Testing Events in Foundry

⌨️ (5:09:37) | Testing Events in Foundry

vm.roll & vm.warp

⌨️ (5:12:37) | vm.roll & vm.warp

Create Subscription Script

⌨️ (5:15:21) | Create Subscription Script

Create Subscription from the UI

⌨️ (5:26:41) | Create Subscription from the UI

Fund Subscription Script

⌨️ (5:30:19) | Fund Subscription Script

Add Consumer Script

⌨️ (5:42:29) | Add Consumer Script

More Tests

⌨️ (5:52:44) | More Tests

  • forge coverage --report debug

PerformUpkeep Tests

⌨️ (5:59:12) | PerformUpkeep Tests

  • Expecting Custom Errors

Getting Event Data into Foundry Scripts

⌨️ (6:03:23) | Getting Event Data into Foundry Scripts

  • vm.recordLogs

Intro to Fuzz tests

⌨️ (6:11:48) | Intro to Fuzz tests

One Big Test

⌨️ (6:15:41) | One Big Test

Passing the private key to vm.startBroadcast

⌨️ (6:26:30) | Passing the private key to vm.startBroadcast

Integrations Test

⌨️ (6:41:08) | Integrations Test

Testnet Demo - Makefile setup

⌨️ (6:44:42) | Testnet Demo - Makefile setup

Testnet Demo - The Demo

⌨️ (6:52:33) | Testnet Demo - The Demo

Console.log Debugging

⌨️ (6:59:30) | Console.log Debugging

forge test --debug

⌨️ (7:01:06) | forge test --debug

Recap

⌨️ (7:02:07) | Recap

Recommended LINK amounts for Sepolia Staging Test:

  • Chainlink VRF: 2 LINK
  • Chainlink Keepers: 8 LINK

Section 9 NFTs

(back to top) ⬆️

Section 10: Foundry ERC20s

⭐️ (7:08:04) | Section 10: ERC20s

💻 Code: https://github.com/Cyfrin/foundry-erc20-cu

What is an ERC? What is an EIP?

  • What is an EIP?
  • EIPs codebase

What is an ERC20?

⌨️ (7:10:42) | What is an ERC20?

Manually Creating an ERC20 Token

⌨️ (7:12:06) | Manually Creating an ERC20 Token

  • .github

ERC20 Token - Openzeppelin

⌨️ (7:19:01) | ERC20 Token - Openzeppelin

Deploy Script

⌨️ 7:22:58 | Deploy Script

AI Tests

⌨️ (7:25:48) | AI Tests

Section 10 Recap

Section 10 NFTs

(back to top) ⬆️

Section 11: Foundry NFTs | MoodNFT

⭐️ (7:40:56) | Section 11: NFTs

💻 Code: https://github.com/Cyfrin/foundry-nft-cu

Introduction

What is an NFT?

⌨️ (7:43:21) | What is an NFT?

  • Video
  • Optional: All on Chain SVG NFT
  • EIP-721

Foundry Setup

⌨️ (7:49:54) | Foundry Setup

  • TokenURI
  • Pudgy Penguin Example

IPFS

⌨️ (8:00:24) | IPFS

Using IPFS

⌨️ (8:07:30) | Using IPFS

Basic NFT: Deploy Script

⌨️ (8:13:59) | Basic NFT: Deploy Script

Basic NFT: Tests

⌨️ (8:15:25) | Basic NFT: Tests

  • Comparing strings in solidity
  • chisel

Basic NFT: Interactions

⌨️ (8:25:31) | Basic NFT: Interactions

Basic NFT: Testnet Demo

⌨️ (8:28:24) | Basic NFT: Testnet Demo

The issue with IPFS & HTTPS TokenURI NFTs

⌨️ (8:34:32) | The issue with IPFS & HTTPS TokenURI NFTs

What is an SVG?

⌨️ (8:38:30) | What is an SVG?

SVG NFT: Introduction

⌨️ (8:45:54) | SVG NFT: Introduction

SVG NFT: Encoding the NFT

⌨️ (8:50:03) | SVG NFT: Encoding the NFT

SVG NFT: Flipping the mood

⌨️ (9:06:41) | SVG NFT: Flipping the mood

SVG NFT: Deploy Script

⌨️ (9:08:44) | SVG NFT: Deploy Script

SVG NFT: Debugging practice & some notes

⌨️ (9:25:46) | SVG NFT: Debugging practice & some notes

SVG NFT: Anvil Demo

⌨️ (9:31:29) | SVG NFT: Anvil Demo

Advanced: EVM Opcodes, Encoding, and Calling

⌨️ (9:44:02) | 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

⌨️ (10:06:27) | Introduction to Encoding Function Calls Directly

Introduction to Encoding Function Calls Recap

⌨️ (10:12:16) | Introduction to Encoding Function Calls Recap

Encoding Function Calls Directly

⌨️ (10:14:15) | Encoding Function Calls Directly

  • Function Selector
  • Function Signature

Verifying Metamask Transactions

⌨️ (10:28:45) | Verifying Metamask Transactions

  1. Check the address
  2. Check the function selector
  3. Decode the calldata

Section 11 Recap

⌨️ (10:36:31) | Section 11 Recap

Section 11 NFTs

(back to top) ⬆️

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Completed Video 2!!

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊


Solidity, Blockchain Developer, Smart Contract, & Solidity Course - Powered By AI - Beginner to Expert Course


Section 12: Foundry DeFi | Stablecoin (The PINNACLE PROJECT!! GET HERE!)

💻 Code: https://github.com/Cyfrin/foundry-defi-stablecoin-cu

Introduction

⭐️ (0:00:00) | Section 12: DeFi Stablecoins

What is DeFi?

Code Walkthrough

⌨️ (0:09:17) | Code Walkthrough

What is a stablecoin (But actually)

⌨️ (0:12:23) | What is a stablecoin (But actually)

DecentralizedStableCoin.sol

⌨️ (0:40:41) | DecentralizedStableCoin.sol

DSCEngine.sol Setup

⌨️ (0:54:44) | DSCEngine.sol Setup

Deposit Collateral

⌨️ (1:04:49) | Deposit Collateral

Mint DSC

Getting the value of our collateral

⌨️ (1:22:51) | Getting the value of our collateral

Health Factor

⌨️ (1:39:11) | Health Factor

Minting the DSC

⌨️ (1:46:02) | Minting the DSC

Testing while developing

Deploy Script

⌨️ (1:47:28) | Deploy Script

Tests

⌨️ (2:02:24) | Tests

depositCollateralAndMintDsc

⌨️ (2:13:45) | depositCollateralAndMintDsc

redeemCollateral

⌨️ (2:16:12) | redeemCollateral

Liquidate

Setup

⌨️ (2:27:49) | Setup

Refactoring

⌨️ (2:44:45) | Refactoring

Leveling up your testing skillz

⌨️ (2:56:55) | Leveling up your testing skillz

Challenge: Get DSCEngine.sol test coverage above 85%

Fuzz (Invariant) Testing

⌨️ (3:13:50) | Fuzz (Invariant) Testing

Open-based Fuzz tests

⌨️ (3:27:18) | Open-based Fuzz tests

Handler-based Fuzz tests

revert_on_fail = true

⌨️ (3:46:55) | revert_on_fail = true

Redeeming Collateral

⌨️ (4:03:57) | Redeeming Collateral

Minting DSC

⌨️ (4:09:42) | Minting DSC

Debugging Fuzz Tests

⌨️ (4:15:01) | Debugging Fuzz Tests

Challenge: Find out why mintDsc is never being called on our Handler.sol

Price Feed Handling

⌨️ (4:23:30) | Price Feed Handling

OracleLib

⌨️ (4:31:28) | OracleLib

Note on audit preparedness

⌨️ (4:39:57) | Note on audit preparedness

Recap

⌨️ (4:41:06) | Recap

Lens Protocol

⌨️ (4:44:38) | Lens Protocol

More DeFi Learnings:

Section 12 NFTs

(back to top) ⬆️

Section 13: Foundry Merkle Airdrop and Signatures

💻 Code: https://github.com/Cyfrin/foundry-merkle-airdrop-cu

  • Introduction to Merkle Airdrops and Code Walkthrough
  • Project Setup
  • Merkle Proofs

Base Airdrop Contract

  • Second preimage attack articles [1, 2]

  • Already Claimed Check

  • Merkle Tree Scripts

  • Writing the Tests

  • Deployment Script

  • Adding Signature Verification

Signature Standards

ECDSA Signatures


  • Transaction Types Introduction

Transaction Types

Blob Transactions


  • Type 113 Transactions
  • Implementing Signatures
  • Modifying the Tests
  • Test on zkSync (optional)
  • Create Claiming Script
  • Creating a Signature
  • Splitting a Signature
  • Executing the Anvil Script
  • Deploy and Claim on zkSync Local Node
  • Deploy and Claim on zkSync Sepolia
  • Summary

Section 13 NFTs (TBD)

Section 14: Foundry Upgrades

💻 Code: https://github.com/Cyfrin/foundry-upgrades-cu

Introduction

⭐️ (4:47:00) | Section 13: Upgradable Contracts & Proxies

Upgradable Smart Contracts Overview

Types of Upgrades

  1. Parameter
  2. Social Migrate
  3. Proxy
    1. Proxy Gotchas
      1. Function Collisions
      2. Storage Collisions
    2. Metamorphic Upgrades
    3. Transparent
    4. UUPS
    5. Diamond

Delegatecall

⌨️ (5:02:20) | Delegatecall

Small Proxy Example

⌨️ (5:10:24) | Small Proxy Example

Universal Upgradable Smart Contract

Setup

⌨️ (5:21:53) | UUPS Setup

Initializer

⌨️ (5:34:24) | Initializer

Deploy

⌨️ (5:43:34) | Deploy

UpgradeBox

⌨️ (5:48:29) | Upgradebox

Test/Demo

⌨️ (5:53:48) | Test/Demo

Testnet Demo

⌨️ (5:59:40) | Testnet Demo

Section 14 NFTs

(back to top) ⬆️

Section 15: Foundry Account Abstraction

💻 Code: https://github.com/Cyfrin/minimal-account-abstraction

  • What is account abstraction?
  • What is native account abstraction?
  • How does zkSync do account abstraction?
  • What is EIP-4337?
  • What are zkSync system contracts?

Section 15 NFTs (TBD)

Section 16: Foundry DAO / Governance

Plutocracy is bad! Don't default to ERC20 token voting!!

💻 Code: https://github.com/Cyfrin/foundry-dao-cu

Introduction

⭐️ (6:05:45) | Section 14 | DAOs & Governance

What is a DAO?

How to build a DAO

Setup

Governance Token

Governor

Tests

Wrap up

Bonus: Gas optimization tips

Section 16 NFTs

(back to top) ⬆️

Section 17: Smart Contract Security & Auditing (For developers)

Developers 100% should know all about this! Don't leave the course without at least watching this section!

Important

We highly recommend you head over to the end-to-end Cyfrin Updraft Security and Auditing Curriculum.

🖥️ Code: https://github.com/PatrickAlphaC/denver-security

Introduction

⭐️ (7:21:12) | Section 15 | Security & Auditing

What is a smart contract audit?

⌨️ (7:24:47) | What is a smart contract audit?

Tools

⌨️ (7:31:11) | What tools do security professionals use?

Manual Review

Static Analysis

Dynamic Analysis

Formal Verification

Symbolic Execution

Fuzzing

Formal Verification (& Symbolic Execution)

Other security stuff

What does the process of manual review look like?

⌨️ (7:42:32) | Manual Review with Tincho

Formal Verification

⌨️ (7:56:35) | Formal Verification

Closing Thoughts

⌨️ (8:10:56) | Wrap. Up

Section 17 NFTs

(back to top) ⬆️

Congratulations

🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊 Completed The Course! 🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊🎊

Where do I go now?

Learning More

Community

Hackathons

Be sure to check out project grant programs!

And make today an amazing day!

(back to top) ⬆️

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 receives discounted services. Patrick is the co-founder of Cyfrin, and they do smart contract security & auditing services. Patrick is also the co-founder of Chain Accel, who is an advisor on the Peeranha project.

Because of all this, I have added alternatives to each section where we suggest a tool.

(back to top) ⬆️

Sponsors

A huge thank you to our sponsors. These are the groups and technologies

(back to top) ⬆️

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!

License

Cyfrin Updraft content is open-sourced licensed as GPLv3.

Cyfrin Twitter Cyfrin YouTube Cyfrin LinkedIn

(back to top) ⬆️

foundry-full-course-f23's People

Contributors

0xjarix avatar 0xosiris avatar aayush-gupta-coder avatar ae-0h avatar allwin199 avatar anaarsonist avatar andrejkanuch avatar asobiesk avatar chefaharoni avatar cromewar avatar devblixt avatar devswayam avatar egeaybars123 avatar equious avatar eridianalpha avatar ethanol48 avatar eversmile12 avatar f3d0ss avatar harshh18 avatar joeypearson822 avatar lostintime101 avatar mahadihassanriyadh avatar mekongdelta-mind avatar osneue avatar pacelliv avatar patrickalphac avatar robocrypter avatar shikhar229169 avatar shiva-sai-ssb avatar sunnystefi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foundry-full-course-f23's Issues

Seem like we might have problem with getting the total collateral value in USD, if any of our user had deposited the two tokens that our protocol supports(weth, wbtc)

Describe the enhancement

So when we were doing the conversion of user deposited collateral to USD we loop through each token supported by our contract and get the balance of the user for each of them and then went ahead to add it all up to the total collateral deposited , code below

function getTotalCollateralDepositedByUser(address _user) private view returns(uint256 _totalCollateralDeposited){
        for(uint256 i; i < s_protocolSupportedCollateralToken.length; i++){
            address[] memory copied_s_protocolSupportedCollateralToken = s_protocolSupportedCollateralToken;
            address token = copied_s_protocolSupportedCollateralToken[i];
            uint256 balanceOnToken = s_userToAmountDepositedOnVariousCollateralToken[_user][token];
            _totalCollateralDeposited += balanceOnToken;
        }

        return _totalCollateralDeposited;
    }

The above code seem very fine and okay , but lets assume the scenario where a user deposited 1 eth and 2 btc to our protocol, doing the above would help get the total deposited collateral but i think we would have problem when we want to convert the total collateral deposited to USD, the reason being which of the token USD price would we be using ?.

We never ran into that issue during the tutorial because we never deposited wbtc which makes everything turns out as expected.

So i think we are supposed to get the total collateral deposited by a user for each of the supported token store them separately and and then get the equivalent USD price for each of them separately and after getting the USD value for each of the deposited Collateral then we can sum them to have the total collateral deposited by each user in USD. like that we would be calculating the USD value for different token with their respective USD price.

Maybe i am not making sense but thats what i found and i think i should share as @PatrickAlphaC mentions the code would be going through an Audit. Thanks for all you do @PatrickAlphaC.

If this is confirmed to make sense then i would fork the repo and make the amendment, thanks 🙏

Link in Lesson 1 not working: Error 406

Describe the enhancement

When going to chain.link/education/defi link in Lesson1 section = `

What have Smart Contracts done so far?` . It is showing that the link is bad, that is its showing error 406. Maybe you can update the link, or I can do so.

Timestamps

Describe the enhancement

Each section of the video is broken up by a screen that looks like this:
Screenshot 2023-06-06 at 1 28 56 PM

It would be great if we could add timestamps in this repo for each one of these.

Modulo examples error

Lesson

Lesson 9

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/sas02qSFZ74?t=14685

Describe the bug

Love the videos, they have been very helpful. Just noticed a minor error when explaining modulo which might trip someone up if they haven't come across it before. Examples shown on remix in the demo are the wrong way around.

It shows on screen (line 11):

// 2 % 2 = 0. 2 % 3 = 1.      2 % 6 = 0.  2 % 7 = 1

What it should be:

// 2 % 2 = 0. 3 % 2 = 1.      6 % 2 = 0.  7 % 2 = 1

Modulo calculation examples are wrong

Lesson

Lesson 9

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://www.youtube.com/watch?v=sas02qSFZ74&t=14654s

Describe the bug

In video, Lesson 9, Chapter Chainlink VRF Recap where you explain modulo (timestamp 4:04:27),

you mention some modulo calculations that are wrong:

2 % 3 = 1  // This is WRONG! Correct result is 2
2 % 6 = 0  // This is WRONG! Correct result is 2
2 % 7 = 1  // This is WRONG! Correct result is 2

I assume you wanted to say:

3 % 2 = 1
6 % 2 = 0
7 % 2 = 1

lesson:11 Can't Mint with ```make``` after deploying

mint:
	@forge script script/Interactions.s.sol:MintBasicNft $(NETWORK_ARGS)

i was using this where

ifeq ($(findstring --network sepolia,$(ARGS)),--network sepolia)
NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
endif

but I was still getting an error
while running it maunally without using make mint in the terminal it succeeded don't know why it was not working with make

Originally posted by @highHumann in #402 (reply in thread)

FAIL. Reason: call did not revert as expected

Lesson

Lesson 7

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Windows

Describe the bug

i don't know why it's didn't revert!
here is part of test code:

contract FundMeTest is Test {
    // constructor() {

    // }
    FundMe fundMe;
    address SENDER = makeAddr("jaunepr");
    uint256 constant SEND_VALUE = 1 ether;
    uint256 constant SENDER_BALANCE = 10 ether;

    // uint256 constant FUNDERS_INDEX = 0;

    function setUp() external {
        DeployFundMe deployFundMe = new DeployFundMe();
        fundMe = deployFundMe.run();
        vm.deal(SENDER, SENDER_BALANCE);
    }
    modifier funded() {
        vm.prank(SENDER);
        fundMe.Fund{value: SEND_VALUE}();
        _;
    }

    function testOnlyOwnerCanWithdraw() public funded {
        vm.prank(SENDER);
        vm.expectRevert();
        fundMe.Withdraw();
    }

and i use forge test --match-test testOnlyOwnerCanWithdraw -vvv
then, here is ouput:

[FAIL. Reason: call did not revert as expected] testOnlyOwnerCanWithdraw() (gas: 108176)
Traces:
  [108176] FundMeTest::testOnlyOwnerCanWithdraw()
    ├─ [0] VM::prank(jaunepr: [0xD32aC66b047b3Ba085a452E26814BD4F20A99929])
    │   └─ ← ()
    ├─ [81354] FundMe::Fund{value: 1000000000000000000}()
    │   ├─ [8993] MockV3Aggregator::latestRoundData() [staticcall]
    │   │   └─ ← 1, 200000000000 [2e11], 1, 1, 1
    │   └─ ← ()
    ├─ [0] VM::prank(jaunepr: [0xD32aC66b047b3Ba085a452E26814BD4F20A99929])
    │   └─ ← ()
    ├─ [0] VM::expectRevert(custom error f4844814:)
    │   └─ ← ()
    ├─ [6788] FundMe::Withdraw()
    │   ├─ [0] jaunepr::fallback{value: 1000000000000000000}()
    │   │   └─ ← ()
    │   └─ ← ()
    └─ ← call did not revert as expected

Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 1.75ms
 
Ran 1 test suites: 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/FundMeTest.t.sol:FundMeTest
[FAIL. Reason: call did not revert as expected] testOnlyOwnerCanWithdraw() (gas: 108176)

Encountered a total of 1 failing tests, 0 tests succeeded

Lesson 6 Foundry installation error

"Seems like Windows and Ubuntu WSL have different opinions on 'forge --version'. On Windows, it's all 'I got this,' but in WSL, it's like 'What command?'. 🙄 Any tips for syncing up these two worlds or should I just stick to the 'normal' terminal in VS Code? 🤔

4-Lesson.sol Challenge | Line 40 Typo

Lesson

Lesson 4

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

None

Describe the bug

Line 40 of the 4-Lesson.sol challenge code contains a typo in the "10e10" number:
actualPrice = actualPrice * 10e10;

Should be "1e10":
actualPrice = actualPrice * 1e10;

To pass the challenge, add an extra zero to your answer.
For examlpe, if getPrice() returns:
1637320000000000000000, you need to paste this number plus 0, like this:
16373200000000000000000

It would be better if the Readme file contains direct link to Link Token Contract.

Describe the enhancement

I was going through readme file In lesson 9 in which we deploy our own Link Token contract for anvil chain ht direct link to the contract was not there. It would be better if its included in the readme file with the time stamp.

image

Video TimeStamp

Link

Github Repo Link that i would like to add

Link

Also the Command to install the solmate package

forge install transmissions11/solmate --no-commit

Interact with SmartContract from the bash

Lesson

Lesson 6

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Windows

Describe the bug

when i try to call "retreive()" function this error appears
' ' '
(code: 3, message: execution reverted, data: Some(String("0x")))
' ' '

Lesson 1 Caption: "Layer 2: Any application built on top of a layer 2"

Lesson

Lesson 1

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://www.youtube.com/watch?v=umepbfKp5rI&t=6155s

Describe the bug

Thank you for creating the video! I noticed a small error in the caption in this screenshot - I believe it should say "on top of a Layer 1" rather than what's currently written.
It's not a major issue at all, I just wanted to provide the feedback in case it's helpful for improving the accuracy of the captions for future viewers.
Thank you again for the great work on these educational videos!

image

Add Steps to Deploy after Private Key Encryption

Describe the enhancement

In Lesson 6,

cast wallet import your-account-name --interactive
Enter private key:
Enter password:
`your-account-name` keystore was saved successfully. Address: address-corresponding-to-private-key

After following the above steps, below step has to be followed

forge script <script> --rpc-url <rpc_url> --account <account_name> --sender <address> --broadcast

This step is missing.

Promotion competition! ($6,000 in prizes!)

$6,000 Prize pool

I will budget $5,000 to the top 20 promotions of this course ($250 in ETH each!).

And a grand prize of $1,000 for the best piece of marketing material!

The goal of this is to get developers up to speed on web3. If we are going to get web3 to retail, we need more developers like yourself taking courses like this. So this is your chance to join the fight and make some dope content!

To enter

  1. Wait till the course launches. All entries posted here before the Video is up are disqualified.

  2. Comment on this issue with a link to your

  • TikTok / YouTube shorts
  • Twitter Threads
  • LinkedIn posts
  • YouTube videos
  • Blogs
  • Meme on Reddit
  • Other
  1. In the media (not the comment on this issue), you must include an ARBITRUM address, which I will send at the end of the Judging period. (Sometime in July or August).

  2. I will NOT send money to smart contract-based accounts (It MUST be an EOA).

  3. This issue will be closed July 6th, 2023. That will be the last day to post!

To claim your prize

I will send the payments after the judging period in ETH on ARBITRUM. I will not be responsible for it you mess up sending the address. Sorry.

Judging

July 6th 2023 I'll start judging, and I will award prizes to the following different categories:

  1. Most reach
  2. How funny it is
  3. How many web2 developers take the course based off your content
  4. How good the SEO is
  5. How creative it is

An entry can only win on one of the categories.

I will give out at least 2 awards to each of the following mediums:

  • TikTok / YouTube shorts
  • Twitter Threads
  • LinkedIn posts
  • YouTube videos
  • Blogs
  • Meme on Reddit
  • Something else

So yes, if you have a banger tweet, that's eligible.

Sadly, I don't have time to coordinate a DAO around this, so judging will be 100% my discretion. If you don't like my judging, too bad 😜

Lesson 6 : Ganache URL not connecting while deploying SimpleStorage contract

Discussed in #1282

Originally posted by Meherabhossen January 4, 2024
im getting error on this

[⠊] Compiling...
No files changed, compilation skipped
Error: 
error sending request for url (http://127.0.0.1:7545/): error trying to connect: tcp connect error: Connection refused (os error 111)

Context:
- Error #0: error trying to connect: tcp connect error: Connection refused (os error 111)
- Error #1: tcp connect error: Connection refused (os error 111)
- Error #2: Connection refused (os error 111)

this is my command

forge create SimpleStorage --rpc-url http://127.0.0.1:7545 --interactive
```</div>

Upload .srt file to YouTube

Describe the enhancement

It would be great if someone could:

  1. Convert the YouTube video -> a transcript (using a tool like Descript to auto convert)
  2. Manually update the transcript where the tool gets it wrong
  3. Send me the .srt file

Then I will add it to YouTube

Unnecessary type casting in MoodNft.sol and DeployMoodNft.s.sol contracts

Lesson 11

Operating System

macOS (Apple Silicon)

Describe the bug

Hi to the foundry course community :)

I noticed some unnecessary type castings in 2 contracts.

In MoodNft.sol : https://github.com/Cyfrin/foundry-nft-f23/blob/1e0cb4ed67e79f219889c3fac98fff0e766fd64b/src/MoodNft.sol#L95

casting the result of abi.encodePacked() into a bytes variable (array of bytes) is redondant as abi.encodePacked() result is itself an array of bytes.

Same thing happens in DeployMoodNft.s.sol : https://github.com/Cyfrin/foundry-nft-f23/blob/1e0cb4ed67e79f219889c3fac98fff0e766fd64b/script/DeployMoodNft.s.sol#L41-L43

This time, abi.encodePacked() result, which is of bytes types, is converted to string, and then back to bytes.

I removed these castings and everything compiles and works well.

I can make a PR in the MoodNft repo if you confirm this issue.

Thanks a lot to @PatrickAlphaC for this AMAZING content :) !!!!

could not install foundry.

Screenshot 2023-08-01 211005
I have tried most of the methods mentioned in the discussions tab. But at the end i got the same output. so i have to open the issue. if any one have a sloution then please discuss , it will be very helpful.

hi

hi i have issu whith this command in my terminal

forge create SimpleStorage --rpc-url http://127.0.0.1:7545
 --interactive

when i want to run this command i got this error:

forge create SimpleStorage --rpc-url http://127.0.0.1:7545
--interactive
[⠢] Compiling...
[⠆] Compiling 1 files with 0.8.19
[⠰] Solc 0.8.19 finished in 81.31ms
Compiler run successful!
Error: 
Error accessing local wallet. Did you set a private key, mnemonic or keystore?
Run `cast send --help` or `forge create --help` and use the corresponding CLI
flag to set your key via:
--private-key, --mnemonic-path, --aws, --interactive, --trezor or --ledger.
Alternatively, if you're using a local node with unlocked accounts,
use the --unlocked flag and either set the `ETH_FROM` environment variable to the address
of the unlocked account you want to use, or provide the --from flag with the address directly.
zsh: command not found: --interactive

how can i fix this? please help

Lesson 6, we can use interactive when we are running scripts

Lesson

Lesson 6

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://www.youtube.com/watch?v=umepbfKp5rI&t=27765s

Describe the bug

We can use interactive to enter private key when we are running scripts, instead of --interactive/-i, we can use --interactives <num>/-i <num>, and specify the sender address with --sender

For example :

forge script script/DeploySimpleStorage.s.sol --rpc-url http://127.0.0.1:8545 --broadcast --sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -i 1

Trying to create a new project in foundry. Error 'init' is not a valid subcommand

Lesson

Lesson 1

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/umepbfKp5rI?t=25276

Operating System

macOS (Intel)

Describe the bug

Hi everyone,
I have ran forge init and I'm getting the following error message. Can't figure out how to get over this issue and would love help. Thanks.

jordanbishop@Jordans-MacBook-Pro foundry-simple-storage-f23 % forge init                    
──────────────
✖ 'init' is not a valid subcommand. See 'forge --help'
──────────────
ℹ Did you mean this?
  - forge join
  - forge asset
  - forge config
  - forge help
  - forge install
  - forge logs
  - forge ls
  - forge ps
  - forge start
  - forge stop
  - forge tx
  - forge use
  - forge web

I also ran forge which and got the following.

jordanbishop@Jordans-MacBook-Pro foundry-simple-storage-f23 % which forge
/usr/local/bin/forge

why "emit RaffleEnter(PLAYER)" from test?

Lesson

Lesson 9

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/sas02qSFZ74?t=18743

Operating System

Windows

Describe the bug

I am in Lesson 9. In the following test, I don't get why the test need to "emit RaffleEnter(PLAYER)"?

in test/unit/RaffleTest.s.sol

function testEmitsEventOnEntrance() public {
        // Arrange
        vm.prank(PLAYER);

        // Act / Assert
        vm.expectEmit(true, false, false, false, address(raffle));
        
        emit RaffleEnter(PLAYER); // todo: shuoldn't the next call emit?
        raffle.enterRaffle{value: raffleEntranceFee}();
    }

I ask this because the next call "raffle.enterRaffle{value: raffleEntranceFee}()" will emit the event,
in src/Raffle.sol

    function enterRaffle() public payable {
        // require(msg.value >= i_entranceFee, "Not enough value sent");
        // require(s_raffleState == RaffleState.OPEN, "Raffle is not open");
        if (msg.value < i_entranceFee) {
            revert Raffle__SendMoreToEnterRaffle();
        }
        if (s_raffleState != RaffleState.OPEN) {
            revert Raffle__RaffleNotOpen();
        }
        s_players.push(payable(msg.sender));
        // Emit an event when we update a dynamic array or mapping
        // Named events with the function name reversed
        emit RaffleEnter(msg.sender);
    }

Error with running "forge script"

Hey guys,
I'm having difficulties with the last part of video 1; deploying "SimpleStorage.sol" in foundry; where there is a script to deploy the smart contract.
here is the script from the first video of the course:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

// import {Script} from "../lib/forge-std/src/Script.sol";
import {Script} from "forge-std/Script.sol";
import {SimpleStorage} from "../src/SimpleStorage.sol";

contract DeploySimpleStorage is Script {
    function run() external returns (SimpleStorage) {
        vm.startBroadcast();
        SimpleStorage simpleStorage = new SimpleStorage();
        vm.stopBroadcast();
        return simpleStorage;
    }
}

then when I run "forge script scr/SimpleStorage.sol" in the command line. I get the following error:

[⠊] Compiling...
[⠃] Compiling 22 files with 0.8.21
[⠰] Solc 0.8.21 finished in 4.80s
Compiler run successful!
Error: 
Function `run()` is not implemented in your script.

I have tried the command with other test files but the issue still persists!

anyone has any ideas as to why it keeps referring to "run() " function while it has been defined within the script!

Constructor of "VRFV2WrapperConsumerBase.sol" has 2 arguments instead of 1

In the video, the constructor takes a single argument: address _vrfCoordinator.
In the updated code of VRFV2WrapperConsumerBase.sol, it takes two.
Namely:
constructor(address _link, address _vrfV2Wrapper) { LINK = LinkTokenInterface(_link); VRF_V2_WRAPPER = VRFV2WrapperInterface(_vrfV2Wrapper); }

Stuck at this point.
Confused as to what it needs as the second argument.

Lesson 9 fork url error

2(d11ts1)/1^-b^^-2/9 + ddx(Ass.V).dmb
R2 = rm^2 + 2/1 (oh^-eipi^n2-2mf.rsc
n^3x.u'/ r^2, 64pi rnt?d3/4
.int
-L^2 = 0rc . g3/2pi / Am^-pu.u*.lk
z = r^2 v^2 - 2*.zip
3+1/2Nmf = -Aq' . 1/2hco.dnc
Trc . dt^2 = oH
OH = 5Tu' . 3/5q^2
dryHe = Frv^vu^2
10KT = / . 2/1 Api/-pu.ucc
DM = ds^5/4 - pu^-2mû'. -hu!
arcsen^2 = Apu'-mf'/1
5/0- . Mo - ddt^2E = GEo . Q^nk . pEc - Ec2
dt = 3/2j - dc2 . t^h + KPR+-4/27
mu^2 = -t^2 + arcsen r^216pirsc^-2/1
s = -2/1 rsc^2 - TKqu' +DEc
o = -pmiEc't^3/2
a = d-pmu . QPRRct
q = +- -2/1dp (-R)
cos159 = ^8pi^KPR 24/7 + 2/3 pidrt^2ms / r^2arsen3/0
FRmo = Amu + KP445 -r^2h
gcr =dt^3 . -1/2dt

Chapter 7 Readme Update

Describe the enhancement

Make File Command From Chapter 7 Is not working for some users.

The Install Make Command for Users who have installed Ubantu as a VM in Windows was not working; hence, I wanted to add the alternative link, which is from the official documentation with a tutorial.

I'm trying to deploy the contract, and I'm getting this error: const raw = this.data.get(problem.where).raw?.[problem.from] ^ SyntaxError: Unexpected token '.'

Lesson

Lesson 6

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/umepbfKp5rI?si=UOKIZgpCAJoqP_gP&t=28405

Operating System

Windows

Describe the bug

I have this issue when type "npx thirdweb deploy"

const raw = this.data.get(problem.where).raw?.[problem.from]
                                                     ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/mnt/c/Users/admin/AppData/Roaming/nvm/v19.4.0/node_modules/npm/lib/utils/config/definition.js:33:5)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Add .srt subtitles

Describe the enhancement

I have a subtitles folder where I will put the "raw" AI-generated subtitles. If someone would like to edit them, I will then upload them to YouTube so others can watch and understand easier!

VSCode can't locate chainlink imports

Lesson

Lesson 7

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

None

Describe the bug

Hello,

I'm having a problem with the following line:

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

Source "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File not found. Searched the following locations: "".solidity(6275)

If I use forge build everything works as expected, but vscode "doesn't know" the remapping configuration hence I get the error.

VSCode doesn't show an error if I use:

import {AggregatorV3Interface} from "foundry-fund-me-f24/lib/chainlink-brownie-contracts/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

but then Foundy shows an error.

Is there a way to solve this?

Reason: Assertion failed.] testFailWithoutEnoughEth() (gas: 22948)

Lesson

Lesson 7

https://www.youtube.com/watch?v=sas02qSFZ74)

No response

Operating System

Windows

Describe the bug

here i am trying to run test using forge test.

fund me.sol
function fund() public payable {
        if (msg.value.conversionRate(s_priceFeed) < MINIMUM_USD) {
            revert Not_Sufficient_Amount();
        }```

test.sol
```   function testFailWithoutEnoughEth() public {
        // this test supposed to be passed when we don't have enough eth to
        vm.expectRevert(); // the next line should revert
        fundMe.fund(); // here we are trying to send the zero eth to
    }```

this test should be passed as i am using vm.expectRevert() here why this test failing

OpenZeppelin's Ownable contract updated its constructor

The following question was raised in discussions:

Discussed in #286

Originally posted by Glow-in-the-dark July 8, 2023
in DecentralisedStableCoin.sol, it inherits the 1) ERC20Burnable, which inherits the ERC20, and also the 2) Ownable contract.
However, the constructor of the DecentralizedStableCoin contract, only seems to initiate the constructor of the ERC20() , but not the Ownable() contract, which also have a constructor.

contract DecentralizedStableCoin is ERC20Burnable, Ownable {
    error DecentralizedStableCoin__MustBeMoreThanZero();
    error DecentralizedStableCoin__BurnAmountExceedsBalance();
    error DecentralizedStableCoin__NotZeroAddress();

    constructor () ERC20 ("DecentralizedStableCoin","DSC") {
    }

why is it not something like:

constructor () ERC20("DecentralizedStableCoin","DSC") Ownable(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266){
    }

since under "Ownable.sol", there is a constructor, which is:

    constructor(address initialOwner) {
        _transferOwnership(initialOwner);
    }

My underrstanding is that the child contract inheriting the parent contract, will need to also include the parent's constructor.

Whis is the example:
https://github.com/Cyfrin/foundry-defi-stablecoin-f23/blob/main/src/DecentralizedStableCoin.sol

it inherits both parents, but only instantiate the ERC20 token, and does not include the Ownable's constructor.


There was an update to OpenZeppelin's code two months ago that changed from the code that's used in the course, to what's shown above.
Since the update, address of the owner must be entered manually through the constructor parameter.

I suggest noting this change on YouTube, and I'll also note this in the Decentralized coin repo.

image

here is my integration script.

here is my integration script.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {Script, console} from "forge-std/Script.sol";
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {FundMe} from "../src/FundMe.sol";

contract FundFundMe is Script {
    uint256 SEND_VALUE = .1 ether;

    function fundFundMe(address mostrecentDeployment) public {
        FundMe(payable(mostrecentDeployment)).fund{value: SEND_VALUE}();

        console.log("EgtgGE%s", SEND_VALUE);
    }

    function run() external {
        address mostrecentDeployment = DevOpsTools.get_most_recent_deployment(
            "FundMe",
            block.chainid
        );
        console.log("ugh9uq3r9grtgqegffuuuefbufueu");
        vm.startBroadcast();
        fundFundMe(mostrecentDeployment);
        vm.stopBroadcast();
    }
}

and trace are

  [1139609] → new DevOpsTools@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
    └─ ← 5692 bytes of code

  [277305] → new FundFundMe@0x34A1D3fff3958843C43aD80F30b94c510645C316
    └─ ← 1164 bytes of code

  [57509] FundFundMe::run()
    ├─ [33494] DevOpsTools::get_most_recent_deployment("FundMe", 31337 [3.133e4]) [delegatecall]
    │   ├─ [0] VM::readDir("./broadcast", 3) [staticcall]
    │   │   └─ ← [("IO error for operation on /home/kalmrigaya/hello_foundry/foundry-fund-me/broadcast: No such file or directory (os error 2)", "/home/kalmrigaya/hello_foundry/foundry-fund-me/broadcast", 0, false, false)]
    │   ├─ [0] VM::toString(31337 [3.133e4]) [staticcall]
    │   │   └─ ← "31337"
    │   └─ ← revert: No run-latest.json file found for specified chain
    └─ ← revert: No run-latest.json file found for specified chain


Gas used: 57509
Error: 
script failed: revert: No run-latest.json file found for specified chain

Originally posted by @sagoto80 in #1181

source .env

I am trying to execute a command $ source .env. Also I am in the folder : foundry-simple-storage-f23.Unfortunately it shows: "bash: .env: No such file or directory"
I have checked twice that the .env in the in the Gitignore folder under #Dotenv file
I have saved the .env in the test folder.
May be someone else also have got the same problem? PLease help. Thank you.

@guyInTheChair Did you save the file?

@guyInTheChair Did you save the file?

Originally posted by @alymurtazamemon in #82 (comment)

Mine gave a different error message:

Error: 
Compiler run failed:
Error (7858): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition.
  --> script/DeploySimpleStorage.s.sol:16:1:
   |
16 | }
   | ^

ChatGPT tells me this:
"The error is caused by an incomplete import statement. It seems that the SimpleStorage contract is not being imported correctly.

Please make sure that the path to the SimpleStorage.sol file is correct. Double-check that the file is located in the correct directory relative to the DeploySimpleStorage.sol file.

Assuming that the SimpleStorage.sol file is in the ../src/ directory, you should update the import statement as follows:

solidity
Copy code
import {SimpleStorage} from "../src/SimpleStorage.sol";
Make sure the path is correct and try compiling the code again."

That was yesterday. Now I run the exact script (unchanged from yesterday) again, and it compiles successfully. This is the second time I had to quit the program and than continue the next day, and it suddenly works.

Any thoughts as to why?

VULNERABILITY! redeemCollateral and redeemCollateralForDsc need to have isAllowedToken(tokenCollateralAddress) modifier

Lesson

Lesson 12

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/wUjYK5gwNZs?t=8205

Operating System

Windows

Describe the bug

redeemCollateral and redeemCollateralForDsc need to have isAllowedToken(tokenCollateralAddress) modifier

Summary

Everyone can call redeemCollateral and redeemCollateralForDsc with address that is not allowed. This vulnerability may result in a critical error, specifically: [FAIL. Reason: panic: arithmetic underflow or overflow (0x11)]. This error occurs when attempting to subtract an amount from zero in the following code snippet: s_collateralDeposited[from][tokenCollateralAddress] -= amountCollateral;

Code Snippet

https://github.com/Cyfrin/foundry-defi-stablecoin-f23/blob/7dca86be19d3eea563daa599d3c73840eff16437/src/DSCEngine.sol#L151C8-L151C8

https://github.com/Cyfrin/foundry-defi-stablecoin-f23/blob/7dca86be19d3eea563daa599d3c73840eff16437/src/DSCEngine.sol#L166

Tool used

Manual Review

Recommendation

Include isAllowedToken(tokenCollateralAddress) modifier. This will revert if invalid collateral address is passed.

function redeemCollateralForDsc(address tokenCollateralAddress, uint256 amountCollateral, uint256 amountDscToBurn)
        external
        moreThanZero(amountCollateral)
+      isAllowedToken(tokenCollateralAddress)
    {
        _burnDsc(amountDscToBurn, msg.sender, msg.sender);
        _redeemCollateral(tokenCollateralAddress, amountCollateral, msg.sender, msg.sender);
        revertIfHealthFactorIsBroken(msg.sender);
    }

    function redeemCollateral(address tokenCollateralAddress, uint256 amountCollateral)
        external
        moreThanZero(amountCollateral)
+      isAllowedToken(tokenCollateralAddress)
        nonReentrant
    {
        _redeemCollateral(tokenCollateralAddress, amountCollateral, msg.sender, msg.sender);
        revertIfHealthFactorIsBroken(msg.sender);
    }

Missing QR codes for Lesson 12 challenge

Lesson

Lesson 12

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/wUjYK5gwNZs?t=17213

Describe the bug

In the end of Lesson 12 I don't see any QR codes for the usual challenge at the end of every Lesson. I thought that this was intentionally like this.

On the contrary, I found that there is a Challenge 12 on:
Sepolia: https://sepolia.etherscan.io/address/0xe5760847db2f10a74fc575b4803df5fe129811c1#code
Arbitrum: https://arbiscan.io/address/0x3dbbf2f9acfb9aac8e0b31563dd75a2d69148d64#code

So I understand that QR code is missing in the end of Lesson 12 and should be added in an update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.