FundMe is a decentralized funding platform built using Foundry and Solidity, allowing users to fund the contract with a minimum amount of $5 USD (in ETH), using Chainlink's price feed for real-time ETH/USD conversion. This project includes testing capabilities with an Anvil local blockchain and can be deployed to the Sepolia testnet.
- Real-time Price Feed: Fetches the current ETH/USD price via Chainlink.
- Minimum Funding Requirement: Enforces a minimum funding amount of 5 USD.
- Testing and Simulation: Built-in tests that run with Foundry and Anvil, making it easy to test locally.
- Deployment Ready: Scripts for deploying on local and Sepolia testnet environments.
Follow these steps to set up, build, and deploy the project.
- Foundry: Install Foundry and ensure
forge,cast, andanvilare available in your CLI. - Git: Git for cloning the repository.
- Node.js and npm (optional): For advanced setups, especially if deploying and verifying on Etherscan.
- Chainlink Node API key and Ethereum Wallet Private Key (e.g., from MetaMask or a test account).
-
Clone the repository:
git clone https://github.com/yourusername/fundme-foundry.git cd fundme-foundry -
Install Dependencies:
make install
This command installs the necessary dependencies, including:
-
Environment Variables:
Create a
.envfile in the project root and add the following variables or use the .env.example:ANVIL_PRIVATE_KEY=<YOUR_ANVIL_PRIVATE_KEY> PRIVATE_KEY=<YOUR_DEPLOYMENT_PRIVATE_KEY> SEPOLIA_RPC_URL=<YOUR_SEPOLIA_RPC_URL> ETHERSCAN_API_KEY=<YOUR_ETHERSCAN_API_KEY>ANVIL_PRIVATE_KEY: Private key for local Anvil testing.PRIVATE_KEY: Private key for deploying on Sepolia.SEPOLIA_RPC_URL: RPC URL for Sepolia (e.g., from Alchemy or Infura).ETHERSCAN_API_KEY: API key for verifying the contract on Etherscan.
To streamline the development process, use the provided Makefile commands.
-
Clean the Project:
make clean
Cleans the compiled artifacts and resets the project.
-
Build the Project:
make build
Compiles the smart contracts.
-
Run Tests:
forge testRuns tests on the local Anvil blockchain.
-
Start Local Blockchain:
make anvil
Starts an Anvil blockchain instance.
-
Deploy Locally:
make deploy-anvil
Deploys the contract on a local Anvil blockchain.
-
Deploy on Sepolia Testnet:
make deploy-sepolia
Deploys the contract on the Sepolia testnet with Etherscan verification.
-
Start Anvil:
make anvil
-
Run Tests:
forge testThis runs all tests to ensure contract functionality, such as checking minimum funding requirements and fetching accurate price feeds.
To deploy on Sepolia:
-
Make sure
.envhas validSEPOLIA_RPC_URL,PRIVATE_KEY, andETHERSCAN_API_KEY. -
Run the deployment script:
make deploy-sepolia
If the deployment is successful, the script will automatically verify the contract on Etherscan. Check your contract's Etherscan page to see if verification succeeded.