A decentralized crowdfunding platform built with Solidity, Hardhat, and Chainlink oracles. This project demonstrates how to integrate price feeds into smart contracts and deploy them to Ethereum-compatible networks.
- Key Features
- Prerequisites
- Installation
- Usage
- Configuration
- API Documentation
- Project Structure
- Testing
- Deployment
- Contributing
- License
- Acknowledgments
- Contact
- Decentralized Crowdfunding: Allows users to fund projects securely using Ethereum.
- Chainlink Integration: Leverages Chainlink oracles for reliable price feeds.
- Gas Reporting: Includes gas usage reports for optimization.
- Etherscan Verification: Automatically verifies contracts on Etherscan.
- Node.js: Ensure you have Node.js installed (>=16.x recommended).
- Yarn: Install Yarn for dependency management.
- Hardhat: Familiarity with Hardhat is recommended.
- Environment Variables: Create a
.envfile with the following:ETHERSCAN_API_KEY=your-etherscan-api-key PRIVATE_KEY=your-wallet-private-key
Tip: Use a
.envfile to keep sensitive information secure.
- Clone the repository:
git clone https://github.com/your-repo/hardhat-fundme.git cd hardhat-fundme - Install dependencies:
yarn install
- Compile the contracts:
yarn hardhat compile
Start a local Hardhat network:
yarn hardhat nodeDeploy contracts to the local network:
yarn hardhat deployUse Hardhat tasks to interact with deployed contracts:
npx hardhat consoleModify helper-hardhat-config.js to customize network settings:
module.exports = {
networkConfig: {
31337: {
name: "localhost",
ethUsdPriceFeed: "0x...",
},
11155111: {
name: "sepolia",
ethUsdPriceFeed: "0x...",
},
},
developmentChains: ["hardhat", "localhost"],
}fund(): Allows users to fund the contract.withdraw(): Enables the owner to withdraw funds.getFunder(uint256 index): Returns the address of a funder.
contracts/ # Solidity contracts
deploy/ # Deployment scripts
test/ # Unit tests
utils/ # Utility scripts
artifacts/ # Compiled contract artifacts
deployments/ # Deployment metadata
Run all tests:
yarn testGenerate a gas usage report:
REPORT_GAS=true yarn testTroubleshooting: If tests fail, ensure your local node is running.
Deploy to a testnet (e.g., Sepolia):
yarn hardhat deploy --network sepoliaVerify contracts on Etherscan:
yarn hardhat verify --network sepolia <contract-address> <constructor-args>- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m "Add your feature" - Push to your fork and create a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Patrick Collins for the Solidity tutorials.
- Chainlink for their oracle services.