Interact with a smart contract using the CLI

A command-line guide to Interacting with Smart Contracts using Foundry Cast - Learn to modify contract state with `cast send` and query data using `cast call` directly from your terminal. Master decoding hexadecimal return values for easier interpretation.

Solidity Developer

Foundry Fundamentals

1. Introduction - Foundry simple storage
A foundational introduction to Moving from Remix to Foundry: Your First Steps with Professional Tooling - Learn the limitations of Remix and why Foundry is the preferred professional toolchain for faster, Solidity-native development. Prepare to set up your local environment with Foundry and VS Code for automated workflows. Duration: 7min
2. Development environment setup (Mac, Linux)
A step-by-step walkthrough to Initial Setup for macOS and Linux Users - Get your macOS or Linux machine ready by installing the necessary development tools: VSCode and Git. Follow clear instructions for installation and basic usage of the VSCode integrated terminal. Duration: 3min
3. Development environment setup (Windows)
A practical walkthrough to Setting Up Your Windows Development Environment with WSL - Create a powerful Linux development environment directly on Windows using the Windows Subsystem for Linux (WSL). Easily install the VS Code or VSCodium editor via command line or traditional installer for a complete setup. Duration: 9min
4. Develop in cloud using Gitpod
A Security-focused introduction to Using GitPod: An Optional Cloud Development Environment - Explore GitPod as a cloud-based alternative to local development setup. Learn how to launch it, its benefits, and the crucial security risks of remote execution, especially regarding private keys. Duration: 4min
5. Local Setup
An essential lesson to Managing Your VS Code Terminal - Keep your VS Code terminal organized by learning how to clear the view without losing your session. Grasp the key difference between temporarily hiding the terminal panel and completely terminating the session and its running tasks. Duration: 1min
6. Foundry setup
A foundational guide to Installing the Foundry Development Toolkit - Learn to install the complete Foundry suite (`forge`, `cast`, `anvil`, `chisel`) using `foundryup`. Includes verification steps and detailed troubleshooting for common PATH environment variable problems. Duration: 6min
7. Quiz 7 Quiz
Questions: 7
8. Setup your VSCode
A productivity-boosting guide to Mastering Your VSCode Environment: Workflows, Extensions, and Setup - Optimize your VSCode for web3 development using essential workflows, shortcuts, and the integrated terminal. Explore AI extensions like GitHub Copilot, manage project directories, and verify your Foundry toolchain setup. Duration: 6min
9. Create a new Foundry project
A foundational guide to Setting Up Your Foundry Project - Initialize your first professional smart contract environment using `forge init` and understand the standard Foundry project structure. Learn to add contracts and troubleshoot common Git configuration issues during setup. Duration: 7min
10. Foundry Setup (Windows/WSL)
A step-by-step guide to Foundry and Git Setup in WSL - Install the Foundry toolkit (forge, cast, anvil) within your Windows Subsystem for Linux environment using `foundryup`. Configure your Git identity and set up SSH keys for secure, passwordless interaction with GitHub repositories from WSL. Duration: 5min
11. VSCode Solidity setup
A practical setup guide to Professional Solidity Formatting in VS Code - Install the Nomic Foundation Solidity and Better TOML extensions for improved syntax highlighting. Configure VS Code's settings to automatically format your `.sol` files on save, ensuring code consistency and readability. Duration: 4min
12. Compile a smart contract using Foundry
An essential guide to Compiling Solidity Contracts with Foundry Forge - Learn to run the fundamental `forge compile` command to translate Solidity into EVM bytecode. Understand the generated artifacts in the `out` directory, including crucial ABI and bytecode details. Duration: 1min
13. Quiz 13 Quiz
Questions: 8
14. Deploy a smart contract locally using Anvil
An introductory guide to Deploying Smart Contracts to a Local Blockchain with Anvil - Learn how to launch and configure Anvil, Foundry's built-in local blockchain node. Connect your MetaMask wallet using the correct RPC URL and Chain ID, then import pre-funded developer accounts. Duration: 9min
15. How to add a new network to Metamask
An essential guide to Connecting MetaMask to EVM-Compatible Networks - Learn to connect MetaMask to any EVM network, public or private, using built-in lists or manual setup. Understand the crucial role of RPC URLs and how they link to blockchain nodes. Duration: 2min
16. Deploy a smart contract locally using Forge
An introductory guide to Deploying Your Smart Contract with `forge create` - Learn the essentials of deploying contracts to local nodes like Anvil using `forge create`, including setting RPC URLs and managing private keys. Understand common deployment errors and the importance of secure key handling with the `--interactive` flag. Duration: 4min
17. Important: private key safety pt.1
A security-focused guide to Securing Your Assets: Never Expose Private Keys in Foundry - Discover the critical vulnerability of exposing private keys in `forge create` commands and the persistent danger of shell history. Prioritize secure key handling practices from day one to avoid costly mistakes. Duration: 3min
18. Deploy a smart contract locally using Anvil
A robust guide to Deploying Smart Contracts with Foundry Solidity Scripting - Learn to leverage Foundry's scripting capabilities for reproducible and testable deployments, surpassing `forge create`. Understand script anatomy, key cheat codes like `vm.startBroadcast`, and how to execute scripts for simulation or live broadcasting. Duration: 10min
19. What is a transaction
A fundamental breakdown to The Anatomy of a Blockchain Transaction - Delve into the core data structure of blockchain transactions, examining key fields like nonce, gas, value, and data payload. Understand how this cryptographically signed data packet facilitates state changes, from simple transfers to smart contract deployment. Duration: 6min
20. Important: private key safety pt.2
A risk-aware guide to Secure Private Key Management in Foundry: The `.env` Pitfall and Keystore Solutions - Contrast the convenience but high risk of using `.env` files for development keys against the secure standard of encrypted Keystores for production. Learn crucial practices like `.gitignore` and maintaining separate development/production wallets. Duration: 10min
21. Never Use A Env File
A security-focused guide to Secure Private Key Management in Foundry - Understand the severe risks of using `.env` files for private keys and transition to Foundry's secure, encrypted keystore method. Learn to use `cast wallet import` and the `--account` flag to protect your assets. Duration: 10min
22. Interact with a smart contract using the CLI
A command-line guide to Interacting with Smart Contracts using Foundry Cast - Learn to modify contract state with `cast send` and query data using `cast call` directly from your terminal. Master decoding hexadecimal return values for easier interpretation. Duration: 4min
23. Deploying a smart contract on testnet (Sepolia)
A live-network guide to Deploying Your Smart Contract to a Public Testnet with Foundry - Configure Foundry with an Alchemy RPC URL and a funded private key to move beyond local development. Learn to execute `forge script --broadcast` for Sepolia deployment and verify transactions on Etherscan. Duration: 6min
24. Quiz 24 Quiz
Questions: 12
25. Verify a smart contract on Etherscan
A foundational guide to Manually Verifying Your Smart Contract on Etherscan - Learn the importance of Etherscan verification and follow the detailed manual steps to publish your source code. Understand how verification builds trust and enables direct contract interaction via Etherscan's Read/Write tabs. Duration: 1min
26. Cleaning Up the Project
A foundational guide to Maintaining Code Quality and Documentation - Ensure consistent Solidity code style across your project with `forge fmt` to improve readability and reduce conflicts. Learn to craft clear and essential `README.md` files using Markdown for effective project communication and setup. Duration: 3min
27. Foundry Zksync
A foundational guide to Installing Foundry for zkSync Development - Install `foundry-zksync`, the specialized toolkit for zkSync Layer 2 development, and understand why it's necessary. Learn to manage standard and zkSync Foundry versions and verify your setup for compilation. Duration: 7min
28. Compiling Foundry Zksync
A specialized guide to Compiling Smart Contracts for zkSync Era with `foundry-zksync` - Master the zkSync-specific compilation process using the `foundry-zksync` fork and the `forge build --zksync` command. Understand the purpose of the `zkout` directory and how its artifacts differ from standard EVM builds for successful Layer 2 deployment. Duration: 2min
29. Anvil ZkSync Updated
A streamlined guide to Using anvil-zkSync for Local zkSync Testing - Learn about `anvil-zkSync`, the new, simplified way to run a local zkSync development node with `foundry-zksync`. Ditch complex Docker/npx commands and integrate this easier tool into your local testing workflow. Duration: 3min
30. Zksync Local Node
A practical guide to Deploying to zkSync with Foundry - Learn to deploy contracts to zkSync networks using `forge create` with the `--zksync` and `--legacy` flags. Covers deploying to live networks and optionally setting up a local zkSync node for testing. Duration: 10min
31. Zksync Local Deploy
A hands-on guide to Deploying a Smart Contract to a Local zkSync Docker Node using Foundry - Learn to deploy contracts to a local zkSync Era node via Docker using the specialized `foundry-zksync` tool. Master the `forge create` command with essential flags like `--zksync` and `--legacy`, and troubleshoot common path specification errors. Duration: 3min
32. Tx Types
A comparative guide to Understanding Transaction Types in EVM and zkSync - Explore the different transaction types like Legacy, EIP-1559, and EIP-712 used across EVM and zkSync. Understand their fundamental purpose and how they enable specific blockchain features. Duration: 9min
33. Why L2
An economic analysis of Why Deploy to Layer 2 over Ethereum L1 - Learn to estimate potential Ethereum L1 deployment costs by analyzing testnet gas usage with Foundry. Understand the compelling cost-saving benefits that make Layer 2s like zkSync the preferred choice for modern dApp deployment. Duration: 6min
34. Introduction to Alchemy
An observability-focused guide to Understanding the Mempool with Alchemy - Go beyond block explorers with Alchemy to understand the transaction mempool stage. Utilize the Alchemy Dashboard and Mempool Watcher to debug RPC calls and gain insights into pending or dropped transactions. Duration: 11min
35. Wrap up, congratulations!
A foundational recap to Foundry Project Fundamentals - Solidify your understanding of core Foundry tools (`forge`, `cast`, `anvil`), project setup, and deployment scripting. Review contract interaction via `cast`, RPC basics, environment variable management, and Etherscan verification principles. Duration: 3min
36. Quiz 36 Quiz
Questions: 11

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 May 16, 2025