Debug your Solidity tests

An insightful explanation to Debugging Foundry Tests: Understanding `msg.sender` and Contract Ownership - Discover why tests checking `msg.sender` might fail due to differing execution contexts between deployment and test calls. Learn to use `address(this)` and `console.log` for accurate owner verification in Foundry tests.

Solidity Developer

Foundry Fundamentals

1. Introduction
A professional transition to Foundry Fund Me - Introduction - Rebuild the classic Fund Me project using the Foundry framework, emphasizing professional workflows, GitHub integration, deployment scripting, and comprehensive testing. Set up a production-grade project structure for your web3 portfolio. Duration: 3min
2. Fund Me project setup
A foundational guide to Setting Up Your Foundry Fund Me Project - Learn to create a new directory, initialize it with `forge init`, and explore the standard Foundry project structure. Get started by understanding the key folders and the default example contract. Duration: 2min
3. Introduction to smart contracts testing
An essential introduction to Understanding Smart Contract Testing with Foundry - Master the basics of Foundry testing, from structuring test files (`*.t.sol`) and using the `setUp` function to writing assertions (`assertEq`) and executing tests with `forge test`. Duration: 2min
4. Finishing the setup
A foundational guide to Setting Up Your Project: Cleaning and Importing Code - Initialize your Foundry project by removing default files and adding your existing Fund Me contract code. Learn to manage external dependencies like Chainlink with `forge install` and configure `foundry.toml` remappings for successful compilation. Duration: 7min
5. Writing tests for your Solidity smart contract
A foundational introduction to Writing Basic Foundry Tests for the FundMe Contract - Learn to set up your Foundry test environment using `forge-std` and the `.t.sol` convention. Write your first Solidity tests with `setUp`, assertions like `assertEq`, and `console.log` for debugging the `FundMe` contract. Duration: 9min
6. Debug your Solidity tests
An insightful explanation to Debugging Foundry Tests: Understanding `msg.sender` and Contract Ownership - Discover why tests checking `msg.sender` might fail due to differing execution contexts between deployment and test calls. Learn to use `address(this)` and `console.log` for accurate owner verification in Foundry tests. Duration: 3min
7. Advanced deploy scripts
An introductory lesson to Creating a Basic Foundry Deployment Script for FundMe - Get started with Foundry scripting by building a basic deployment file for the FundMe contract. Discover essential cheatcodes and script execution while identifying the challenge of hardcoded addresses. Duration: 3min
8. Running tests on chains forks
An essential introduction to Foundry Forked Testing for Live Blockchain Interactions - Understand why local tests fail when calling external contracts and how Foundry forking solves this. Discover how to use `--fork-url`, manage RPC URLs securely, and run tests against live network states. Duration: 9min
9. Refactoring your tests
A practical walkthrough of Refactoring FundMe for Modularity and Test Consistency - Eliminate hardcoded Chainlink addresses for greater contract flexibility across different networks. Improve your Foundry workflow by using deployment scripts within test setups for enhanced consistency and reliability. Duration: 7min
10. Deploy a mock priceFeed
A practical guide to Refactoring for Multi-Chain Deployments: The Helper Config Pattern - Learn how to eliminate hardcoded network addresses using the Helper Config pattern in Foundry. Make your deployment scripts and tests portable across different blockchains by dynamically handling configurations based on `block.chainid`. Duration: 13min
11. Refactoring the mock smart contract
A crucial walkthrough of Refactoring HelperConfig for Local Development with Mocks - Overcome local development hurdles by replacing live dependencies with mock contracts. Learn to integrate Foundry scripting into your HelperConfig to automatically deploy mocks for reliable testing on Anvil. Duration: 4min
12. How to refactor magic number
An essential guide to Eliminate Magic Numbers: Write Clearer, More Maintainable Solidity Code - Understand what "magic numbers" are in Solidity and why they harm code readability and maintenance. Learn the best practice of replacing them with named constants for cleaner, more professional smart contracts. Duration: 2min
13. Refactoring the mock smart contract pt.2
A strategic refinement to Refactoring Fund Me: Advanced Mocking in Foundry - Learn to implement conditional mock deployment within `HelperConfig` for truly network-agnostic tests. Speed up your local Foundry development cycle by efficiently managing mocks and reducing reliance on network forking. Duration: 4min
14. Foundry tests cheatcodes
An essential tutorial on Improving FundMe Tests with Foundry Cheatcodes - Enhance your FundMe testing suite using Foundry cheatcodes like `vm.expectRevert`, `vm.prank`, and `vm.deal`. Understand how to test failure conditions, simulate specific users, and ensure correct state updates. Duration: 13min
15. Adding more coverage to the tests
A practical walkthrough of Comprehensive FundMe Testing with Foundry - Build a robust test suite for your FundMe contract using Foundry cheatcodes like `vm.prank`, `vm.expectRevert`, and `hoax`. Ensure correct state changes and access control for single/multiple users, refactor with modifiers, and measure success using `forge coverage`. Duration: 15min
16. Introduction to Foundry Chisel
A practical guide to Interactive Solidity with Foundry Chisel - Explore `chisel`, Foundry's interactive Solidity shell that runs right in your terminal. Instantly execute and test small Solidity code snippets for rapid debugging, logic verification, and learning. Duration: 1min
17. Calculate Withdraw gas costs
A foundational guide to Measuring and Understanding Gas Costs in Foundry - Learn to benchmark function gas usage with `forge snapshot` and understand Foundry's default zero-cost testing environment. Discover how to simulate real-world transaction fees using cheatcodes for more accurate analysis. Duration: 5min
18. Introduction to Storage optimization
A foundational lesson on Understanding Solidity Storage Layout for Gas Optimization - Delve into Solidity's storage slot allocation and its critical role in gas optimization. Learn how variables, dynamic types, constants, and immutables are stored, and master Foundry tools for inspection. Duration: 10min
19. Optimise the withdraw function gas costs
An efficient walkthrough of Optimizing the FundMe Withdraw Function for Gas Efficiency - Master gas optimization by understanding storage vs. memory costs and caching storage variables. Reduce the transaction fees for your `withdraw` function by avoiding repeated storage reads in loops. Duration: 8min
20. Create integration tests
A hands-on tutorial for Finalizing Your Foundry Fund Me Project - Implement robust interaction scripts and integration tests using Foundry cheatcodes. Validate your entire smart contract workflow from deployment to user interaction. Duration: 15min
21. Automate your smart contracts actions - Makefile
An efficient introduction to Streamlining Your Foundry Workflow with Makefiles - Discover how Makefiles simplify complex Foundry commands like deployment and verification into easy shortcuts. This lesson shows you how to set up `make` targets, use environment variables securely, and automate Etherscan verification. Duration: 8min
22. Zksync Devops
An essential guide to Bridging the Gap: Robust Foundry Testing for EVM and zkSync - Understand why standard Foundry tests can fail on zkSync and vice-versa due to EVM vs. zkEVM differences. Learn to use `cyfrin/foundry-devops` helper contracts and modifiers to ensure tests execute conditionally and accurately target the correct environment. Duration: 15min
23. Pushing to Github
An essential walkthrough to Pushing Your Foundry Smart Contract Project to GitHub - Master the process of connecting your local Foundry project to GitHub using Git version control. Understand how to initialize your repository, manage sensitive files with `.gitignore`, and push your code for collaboration and showcasing. Duration: 16min
24. Section recap
A comprehensive recap of Foundry Fund Me Recap: Building Professional Smart Contracts - Reinforce key professional Foundry skills like structured projects, modular code, scripting interactions, advanced testing (mocks, integration), gas reporting, and automation with Makefiles. 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 ThirdWeb

Last updated on April 5, 2025

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