A production-style crowdfunding smart contract built with Solidity and Foundry. This project demonstrates secure ETH funding with USD price enforcement using Chainlink price feeds, along with unit testing, integration testing, and deployment scripting.
Fund Me is a decentralized crowdfunding contract that:
- Accepts ETH deposits
- Enforces a minimum USD funding threshold
- Uses Chainlink price feeds for real-time ETH/USD conversion
- Allows only the contract owner to withdraw funds
- Includes full unit and integration tests
- Uses Foundry for development and scripting
This project demonstrates clean architecture, oracle integration, and modern Solidity best practices.
src/
├── FundMe.sol
└── PriceConverter.sol
-
FundMe.sol
- Main contract
- Handles funding logic
- Stores funders
- Allows owner withdrawal
-
PriceConverter.sol
- Library for ETH → USD conversion
- Integrates with Chainlink AggregatorV3Interface
src/
├── FundMe.sol
└── PriceConverter.sol
script/
├── DeployFundMe.s.sol
├── HelperConfig.s.sol
└── Interactions.s.sol
test/
├── unit/
│ └── FundMeTest.t.sol
├── integration/
│ └── InteractionsTest.t.sol
└── mocks/
└── MockV3Aggregator.sol
lib/
├── chainlink-brownie-contracts
├── forge-std
└── foundry-devops
- Solidity ^0.8.x
- Foundry
- forge-std (Foundry standard library)
- Chainlink Price Feeds
- OpenZeppelin contracts (via vendor libraries)
curl -L https://foundry.paradigm.xyz | bash
foundryup
git clone <your-repo-url>
cd foundry-fund-me
forge install
Run all tests:
forge test
Verbose output:
forge test -vvv
Gas report:
forge test --gas-report
Test coverage includes:
- Unit tests
- Integration tests
- Mocked price feeds
- Owner restrictions
- Withdrawal logic
- Funding validation
Start local node:
anvil
Deploy:
forge script script/DeployFundMe.s.sol \
--rpc-url http://localhost:8545 \
--private-key <your-private-key> \
--broadcast
forge script script/DeployFundMe.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast --verify
HelperConfig.s.sol automatically selects the correct price feed per network.
- Minimum USD funding requirement
- Chainlink oracle integration
- Library-based price conversion
- Owner-only withdrawal
- Custom errors for gas efficiency
- Gas optimization techniques
- Clean separation of concerns
- Script-based deployment
- Environment-based configuration
- Solidity 0.8 built-in overflow protection
- Owner-restricted withdrawals
- Pull-over-push payment model
- Thorough unit testing
- Mocked oracle testing
- Oracle integration in Solidity
- Working with Chainlink AggregatorV3Interface
- Writing reusable libraries
- Writing unit and integration tests in Foundry
- Using scripts for deployment
- Managing different network configurations
- Gas optimization techniques
MIT