A minimal, production-style crowdfunding smart contract system built with Foundry, Chainlink Data Feeds, and modern Solidity patterns.
- Overview
- Features
- zkSync Compatibility
- Getting Started
- Development Environment
- Installation
- Makefile Support
- Configuration & Usage
- Wallet Import via Foundry (cast)
- Compile and Run Tests
- Deploy to Sepolia
- Start a Local Anvil Node
- Deploy Locally
- Unit Tests
- Integration Tests
- Contributing
- Scripts Overview
- Dependencies
- Security
- License
- Acknowledgments
The FundMe contract is a crowdfunding smart contract that:
-
Accepts ETH payments with a minimum USD threshold
-
Uses Chainlink Price Feeds for ETH/USD conversion
-
Maintains a record of funders and their contributions
-
Includes withdrawal functionality restricted to the contract owner
-
Supports both local and testnet deployments
-
Compatible with zkSync via Foundry's zkSync toolchain integration
- FundMe.sol: Accepts ETH contributions, tracks funders, and allows only the owner to withdraw.
- Chainlink Price Feeds: Enforces a minimum USD-denominated funding amount.
- Mock Aggregator: Supports local testing using Anvil.
- Automated Scripts: Deploy, fund, and withdraw using Foundry scripts.
- Comprehensive Tests: Includes both unit and integration tests with Foundry’s native test framework.
This project can be optionally used with zkSync Era for testing and deployment.
To install the Foundry toolchain with zkSync support:
curl -L https://foundry.paradigm.xyz | bash
foundryup --zksync- Foundry
- Node.js (optional, for npm-based dependencies)
- Git
- foundry-devops
- forge-std
- chainlink-brownie-contracts
This project was primarily developed and tested inside Windows Subsystem for Linux (WSL) on Windows 10/11.
If using WSL:
- Use a supported Linux distro (e.g., Ubuntu 20.04 or later).
- Install Foundry and dependencies within WSL (not native Windows).
- Be aware of potential filesystem and networking differences between Windows and WSL.
Linux and macOS users can follow the standard instructions without modification.
Clone the repo and install dependencies:
git clone https://github.com/web3pavlou/foundry-fund-me-f23.git
cd foundry-fund-me-f23
forge installThis project includes a Makefile to streamline common tasks like building, deploying, and testing — including zkSync compatibility.
Make sure you have GNU make installed (default on Linux/macOS; Windows users can use it via WSL or Git Bash).
Common Commands:
make build # Compile contracts with Forge
make test # Run tests
make anvil # Start local Anvil node with tracing and block time
make deploy # Deploy to local Anvil using default test private key
make deploy-sepolia # Deploy to Sepolia with verification
make update # Update Forge dependencies
make zktest # Run zkSync-compatible tests using foundryup-zksync
make interact # Interact with deployed contracts locallycp .env.example .env # Then edit .env with your actual valuesA much more safer way is importing a wallet (private key) into Foundry’s keystore using the new cast wallet import feature.This way the user can encrypt his password locally without saving it in a .env file :
cast wallet import my_wallet_name --private-key $PRIVATE_KEY📌 Available since Foundry PR #5551. Make sure you're using a recent version of Foundry (foundryup) to access this feature.
forge build
forge testforge script script/DeployFundMe.s.sol:DeployFundMe \
--rpc-url $SEPOLIA_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
-vvvvanvilforge script script/DeployFundMe.s.sol:DeployFundMe \
--broadcast \
--rpc-url <RPC_URL> \
--private-key <PRIVATE_KEY>forge testforge test --match-path test/integration/*PRs are welcome!
git clone https://github.com/web3pavlou/foundry-fund-me-f23.git
cd foundry-fund-me-f23
make
DeployFundMe.s.sol: Deploys the FundMe contract.
HelperConfig.s.sol: Handles network configuration and mock deployments.
Interactions.s.sol: Fund and withdraw ETH from FundMe via script.
-
Chainlink Contracts
-
forge-std
-
foundry-devops
-
The contract includes access control mechanisms
-
Owner-only withdrawal functionality
-
Secure fund management
-
Comprehensive test coverage
This project is licensed under the MIT License.
- Chainlink – for providing reliable price feed oracles
- Foundry – for the fast and modern smart contract development framework