This project implements a simple crowdfunding platform called "FundMe" using Hardhat. Users can contribute funds to a campaign, and the owner can withdraw the collected funds.
This directory contains the Solidity smart contract for the FundMe project (FundMe.sol
).
This directory contains scripts for interacting with the deployed contract (fund.js for contributing funds and withdraw.js for withdrawing funds).
This directory contains unit tests for the FundMe.sol
contract.
This file configures the Hardhat development environment.
Node.js
and npm (or yarn) installed on your system.
Clone this repository:
git clone https://github.com/chamsou-ai/hardhat-fund-me-fcc.git
Navigate to the project directory:
cd hardhat-fund-me-fcc
Install dependencies:
npm install # or yarn
Run the tests to ensure the contract works as expected:
yarn test
Optionally, you can run the tests with gas reporting:
REPORT_GAS=true yarn test
Deploying to a testnet or mainnet requires setting up an appropriate provider and funding the deployer account. Do not deploy to a public network with funds you're not comfortable losing.
Start a local development network:
yarn hardhat node
Deploy the contract to the local network:
yarn hardhat deploy --network localhost # Assuming you have a deploy script
fund.js
: Allows contributing funds to a campaign.
withdraw.js
: Enables the owner to withdraw collected funds.
You'll need the contract address and deployer account private key to use these scripts. These details will be available after deployment (check the console output or network explorer).
(Replace placeholders with actual values)
yarn hardhat run scripts/fund.js --contract <contract_address> --value <amount_in_wei>
Explore the FundMe.sol
contract and understand its functionalities.
Modify and extend the scripts provided for more complex interactions.
Consider deploying to a testnet for a more realistic development environment.