Introduction

A comprehensive guide to building a smart contract lottery using Foundry - This lesson explores the Foundry smart contract development environment and dives into a real-world example of creating a lottery contract with verifiable randomness using Chainlink VRF.

Solidity Developer

Foundry Fundamentals

1. Introduction
A comprehensive guide to using Foundry for building smart contracts - The lesson covers the importance of version control when developing smart contracts, and introduces Foundry as the perfect tool to manage your code. Learn how to deploy a contract, interact with storage, write efficient gas-saving tests, and more! Duration: 3min
2. Fund Me project setup
Introduction to the Foundry FundMe project, including setting up GitHub, understanding the FundMe contract, exploring storage and state variables, and creating a new Foundry project folder. Duration: 2min
3. Introduction to smart contracts testing
A guide on testing smart contracts using the \`forge test\` command and the \`counter.t.sol\` example, emphasizing the importance of test-driven development in programming. Duration: 2min
4. Finishing the setup
Continuation of the project setup, including cleaning up unnecessary files, incorporating contracts from Remix, resolving import errors, and directing imports with remappings. Duration: 7min
5. Writing tests for your Solidity smart contract
Detailed explanation on writing and running tests for Solidity smart contracts, including creating test files, understanding the setup function, and using console logs for debugging. Duration: 9min
6. Debug your Solidity tests
A guide to debugging tests in Solidity, including writing and analyzing test functions, using console logs for troubleshooting, and understanding test failures. Duration: 3min
7. Advanced deploy scripts
Tutorial on writing advanced deploy scripts for smart contracts in Solidity, focusing on avoiding hardcoded contract addresses and making contracts more dynamic and adaptable. Duration: 3min
8. Quiz: Foundry Fund Me Intro Quiz
Questions: 4
9. Running tests on chains forks
Instructions on running tests on forked blockchain chains, ensuring functional price feed integrations, and addressing issues related to non-existent contract addresses. Duration: 9min
10. Refactoring your tests
Guide on refactoring tests for better efficiency and clarity, including updating price converter functions and deploying contracts on different networks with ease. Duration: 7min
11. Deploy a mock priceFeed
Detailed guide on setting up a mocked environment for local testing of blockchain smart contracts, emphasizing the benefits and steps for creating mock contracts. Duration: 13min
12. Refactoring the mock smart contract
Comprehensive guide on refactoring mock smart contracts for local network testing, including deploying mock price feed contracts and overcoming common errors. Duration: 4min
13. How to refactor magic number
Explanation of the concept of magic numbers in Solidity code, their drawbacks, and strategies for avoiding them to maintain code readability and efficiency. Duration: 2min
14. Refactoring the mock smart contract pt.2
Continuation of the tutorial on refactoring mock contracts in Solidity, focusing on creating network-agnostic smart contracts for easy deployment across multiple networks. Duration: 4min
15. Foundry tests cheatcodes
Guide on using Foundry tests cheat codes for efficient and effective testing of smart contracts, focusing on deployment strategies, code coverage, and test understanding. Duration: 13min
16. Adding more coverage to the tests
This lesson delves into advanced Solidity unit testing techniques. It includes writing robust tests for the 'getFunder' function and testing the contract owner's withdrawal function using the Arrange-Act-Assert methodology. The lesson aims to strengthen your code backend, making it almost bulletproof. Duration: 15min
17. Introduction to Foundry Chisel
This lesson introduces Chisel, a tool for testing and debugging Solidity code directly in the terminal. It covers the basics of using Chisel, including launching the interactive shell, executing Solidity code, and exploring its functionalities. The lesson is a step-by-step guide to efficient Solidity testing. Duration: 1min
18. Calculate Withdraw gas costs
This lesson focuses on reducing gas consumption in Ethereum smart contracts. It explains how to evaluate gas costs, understand Anvil's zero gas-price, and utilize Solidity's built-in functions to optimize gas usage. The goal is to make contract execution more economical. Duration: 5min
19. Introduction to Storage optimization
In this lesson, you'll learn about optimizing Ethereum smart contract storage to reduce gas consumption. It covers storage variables, their impact on gas usage, and how to efficiently use storage and memory in Solidity. The lesson also includes practical examples using Anvil. Duration: 10min
20. Optimise the withdraw function gas costs
This advanced lesson teaches how to optimize the 'withdraw' function in smart contracts for lower gas costs. It discusses bytecode analysis, storage and memory operations, and practical code changes to reduce gas usage. The lesson includes a comparative analysis of gas usage before and after optimization. Duration: 8min
21. Quiz: Foundry Fund Me Mid section recap Quiz
Questions: 4
22. Create integration tests
Explore the creation of integration tests for Solidity smart contracts. This lesson covers the setup and execution of integration tests, ensuring that contract functions interact correctly with other system parts. It includes practical examples and a guide for setting up a comprehensive test suite. Duration: 15min
23. Automate your smart contracts actions - Makefile
Learn to streamline your development workflow using Makefiles. This lesson teaches how to automate the building and deployment processes of smart contracts. It includes detailed examples of deploying to networks like Sepolia and setting up a comprehensive Makefile for various development tasks. Duration: 8min
24. Zksync Devops
A comprehensive guide to zkSync Devops - The lesson demonstrates the different ways in which unit tests are run on zkSync and Ethereum, highlighting the key differences between zkSync and EVM. This lesson covers how to implement a basic zkSync Devops library and how to test your code to make sure your tests run correctly on either chain. Duration: 15min
25. Pushing to Github
This lesson guides you through the process of pushing your Solidity projects to GitHub. It covers best practices for using Git, managing sensitive information, and updating README files. The lesson is crucial for developers looking to showcase their work and collaborate in the crypto-community. Duration: 16min
26. Section recap
This recap lesson summarizes key points from the course, including professional project setup, codebase refactoring, interaction scripts, gas and storage optimization, Makefiles, and GitHub repositories. It's a comprehensive review of the skills and knowledge gained in the course. Duration: 2min

Course Overview

About the course

What you'll learn

Foundryup, Foundry Forge, and Anvil

Blockchain Oracles

How to create local Blockchain testnets

How to verify a smart contract

How to write and run smart contract tests

Course Description

Who is this course for?

  • Software engineers
  • Web3 developers
  • Blockchain security researchers

Potential Careers

Security researcher

$49,999 - $120,000 (avg. salary)

Smart Contract Engineer

$100,000 - $150,000 (avg. salary)

Web3 developer

$60,000 - $150,000 (avg. salary)

Web3 Developer Relations

$85,000 - $125,000 (avg. salary)

Smart Contract Auditor

$100,000 - $200,000 (avg. salary)

Meet your instructors

Patrick Collins

Patrick Collins

Founder at Cyfrin

Web3 engineer, educator, and Cyfrin co-founder. Patrick's smart contract development and security courses have helped hundreds of thousands of engineers kickstarting their careers into web3.

Guest lecturers:

Richard Gottleber

Richard Gottleber

Developer relations at Chainlink

Vasiliy Gualoto

Vasiliy Gualoto

Developer relations at Cyfrin

Last updated on November 29, 2024

Testimonials

Students Reviews

Read what our students have to say about this course.

Chainlink

Chainlink

Chainlink

Gustavo Gonzalez

Gustavo Gonzalez

Solutions Engineer at OpenZeppelin

Francesco Andreoli

Francesco Andreoli

Lead Devrel at Metamask

Albert Hu

Albert Hu

DeForm Founding Engineer

Radek

Radek

Senior Developer Advocate at Ceramic

Boidushya

Boidushya

WalletConnect

Idris

Idris

Developer Relations Engineer at Axelar

Cyfrin
Updraft
CodeHawks
Solodit
Resources