A simple “Fund Me” smart contract where anyone can fund ETH, but only the contract owner can withdraw.
The contract uses Chainlink Data Feeds to ensure every funder deposits at least a specified minimum USD value (converted from ETH in real time).
BASE sepolia deployed contracts
Fund Eth Contract : 0x1E3A65D38bb383AeB758C65E9CC69d0005eEe1C0
Fund in ETH, Minimum in USD:
Anyone can fund this contract with ETH, but each deposit must meet a minimum USD threshold (default: $5), determined via Chainlink ETH/USD price feed.
Owner-Only Withdraw:
Only the contract owner can withdraw all collected ETH, ensuring secure custody and distribution.
Developed with Foundry and Solidity 0.8.26
- Anyone funds ETH (using
fund()
or by sending ETH directly to the contract). - Each deposit is checked:
- The ETH amount, converted at the latest Chainlink price, must be at least the minimum USD value.
- Owner can withdraw all funds at any time (using
withdraw()
). - On withdrawal:
- All deposited amounts are reset, and the funders list is cleared.
FundEth.sol
fund()
– Fund ETH if minimum USD threshold is met.withdraw()
– Only owner can withdraw all ETH; resets funder records.getLatestETHUSDPrice()
– Get the most recent ETH/USD price (from Chainlink).getNumberOfFunders()
,checkFunderByIndex()
,checkAmountFundedByAddress()
– View funder stats.
git clone https://github.com/RoySudipAvi/Foundry-Fund-Eth.git
cd Foundry-Fund-Eth
forge install
forge build
forge test
Follow the Makifile for easier deployment. For example, to deploy the FundEth contract first assign values to all the variable mentioned in Makefile, then run the the following to deploy on base sepolia.
make deploy CONTRACT=FundEth NETWORK=base_sepolia
Foundry
Solidity 0.8.28
OpenZeppelin Contracts
MIT