Skip to content

RoySudipAvi/Foundry-Fund-Eth

Repository files navigation

FundEth: On-Chain ETH Funding With USD Minimum (Chainlink Oracle)

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

Features:

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

How it works:

  1. Anyone funds ETH (using fund() or by sending ETH directly to the contract).
  2. Each deposit is checked:
    • The ETH amount, converted at the latest Chainlink price, must be at least the minimum USD value.
  3. Owner can withdraw all funds at any time (using withdraw()).
  4. On withdrawal:
    • All deposited amounts are reset, and the funders list is cleared.

Contracts Overview:

FundEth.sol

Key Contract Functions:

  • 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.

Quickstart (Foundry):

Clone and install

git clone https://github.com/RoySudipAvi/Foundry-Fund-Eth.git
cd Foundry-Fund-Eth
forge install

Build contracts

forge build

Test contracts

forge test

Deploy

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

Requirements:

Foundry

Solidity 0.8.28

OpenZeppelin Contracts

License:

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published