A decentralized funding contract that allows users to send ETH while ensuring a minimum USD value, Built with Foundry.
- Etherscan verified contract here
- Uses Chainlink Price Feeds for accurate ETH/USD conversion
- Implements withdrawal pattern
- Gas-optimized operations
- Comprehensive test suite
- Funding: Users can send ETH (minimum $5 USD equivalent)
- Price Feed Integration: Real-time ETH/USD conversion via Chainlink
- Withdrawal: Only owner can withdraw accumulated funds
- Gas Optimized: Implements gas-efficient withdrawal patterns
- Security: Owner-only functions, secure fund management
- Clone this repository:
git clone https://github.com/yourusername/foundry-fund-me
cd foundry-fund-me
- Install dependencies:
forge install
- Build the project:
forge build
# Run all tests
forge test
# Run tests with gas report
forge test --gas-report
# Run a specific test
forge test --match-test testFunctionName
# Run tests with verbosity
forge test -vv
- Setup environment variables:
cp .env.example .env
# Add your RPC_URL and PRIVATE_KEY to .env
- Deploy:
forge script script/DeployFundMe.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
Fund the contract:
forge script script/Interactions.s.sol:FundFundMe --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
Withdraw funds (only owner):
forge script script/Interactions.s.sol:WithdrawFundMe --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
The project includes:
- Unit tests
- Integration tests
- Forked network tests
forge coverage
This project is licensed under the MIT License - see the LICENSE file for details