Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

rionnaldi/learning_hardhat_freecodecamp

Repository files navigation

Hardhat FundMe Project

Build Status
Version
License

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.


Table of Contents

  1. Key Features
  2. Prerequisites
  3. Installation
  4. Usage
  5. Configuration
  6. API Documentation
  7. Project Structure
  8. Testing
  9. Deployment
  10. Contributing
  11. License
  12. Acknowledgments
  13. Contact

Key Features

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

Prerequisites

  • 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 .env file with the following:
    ETHERSCAN_API_KEY=your-etherscan-api-key
    PRIVATE_KEY=your-wallet-private-key

    Tip: Use a .env file to keep sensitive information secure.


Installation

  1. Clone the repository:
    git clone https://github.com/your-repo/hardhat-fundme.git
    cd hardhat-fundme
  2. Install dependencies:
    yarn install
  3. Compile the contracts:
    yarn hardhat compile

Usage

Running a Local Node

Start a local Hardhat network:

yarn hardhat node

Deploying Contracts

Deploy contracts to the local network:

yarn hardhat deploy

Interacting with Contracts

Use Hardhat tasks to interact with deployed contracts:

npx hardhat console

Configuration

Modify helper-hardhat-config.js to customize network settings:

module.exports = {
  networkConfig: {
    31337: {
      name: "localhost",
      ethUsdPriceFeed: "0x...",
    },
    11155111: {
      name: "sepolia",
      ethUsdPriceFeed: "0x...",
    },
  },
  developmentChains: ["hardhat", "localhost"],
}

API Documentation

FundMe.sol

  • fund(): Allows users to fund the contract.
  • withdraw(): Enables the owner to withdraw funds.
  • getFunder(uint256 index): Returns the address of a funder.

Project Structure

contracts/          # Solidity contracts
deploy/             # Deployment scripts
test/               # Unit tests
utils/              # Utility scripts
artifacts/          # Compiled contract artifacts
deployments/        # Deployment metadata

Testing

Run all tests:

yarn test

Generate a gas usage report:

REPORT_GAS=true yarn test

Troubleshooting: If tests fail, ensure your local node is running.


Deployment

Deploy to a testnet (e.g., Sepolia):

yarn hardhat deploy --network sepolia

Verify contracts on Etherscan:

yarn hardhat verify --network sepolia <contract-address> <constructor-args>

Contributing

  1. Fork the repository.
  2. Create a feature branch:
    git checkout -b feature/your-feature
  3. Commit your changes:
    git commit -m "Add your feature"
  4. Push to your fork and create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments


About

Learning from Patrick Collins and Freecodecamp about smart contract with Hardhat framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors