Block Fund is a decentralized crowdfunding platform built on the blockchain, leveraging the power of React for the frontend. This platform allows users to create and contribute to crowdfunding campaigns securely and transparently.
Block Fund is designed to provide a secure, transparent, and efficient way to raise funds for various projects. By leveraging blockchain technology, it ensures that all transactions are immutable and transparent, providing trust to both project creators and contributors.
To get started with Block Fund, follow these steps:
Clone the repository:
git clone https://github.com/hassan4702/block-fund.git
cd block-fund
Install dependencies:
npm install
Run the development server:
npm start
The application will be available at http://localhost:3000
.
block-fund/
├── public/
│ ├── index.html
│ └── ...
├── src/
│ ├── components/
│ │ ├── CampaignCard.js
│ │ ├── CreateCampaign.js
│ │ ├── Navbar.js
│ │ └── ...
│ ├── contracts/
│ │ ├── BlockFund.sol
│ │ └── ...
│ ├── contexts/
│ │ ├── Web3Context.js
│ │ └── ...
│ ├── pages/
│ │ ├── Home.js
│ │ ├── Campaign.js
│ │ └── ...
│ ├── App.js
│ ├── index.js
│ └── ...
├── package.json
└── README.md
The smart contract is written in Solidity and is located in the src/contracts/BlockFund.sol
file. It handles the core functionality of the platform, including:
pragma solidity ^0.8.0;
contract BlockFund {
struct Campaign {
address payable creator;
uint goal;
uint raisedAmount;
uint deadline;
bool completed;
}
mapping(uint => Campaign) public campaigns;
uint public campaignCount;
function createCampaign(uint _goal, uint _duration) public {
campaignCount++;
campaigns[campaignCount] = Campaign(
payable(msg.sender),
_goal,
0,
block.timestamp + _duration,
false
);
}
function contribute(uint _campaignId) public payable {
Campaign storage campaign = campaigns[_campaignId];
require(block.timestamp < campaign.deadline, "Campaign ended");
require(!campaign.completed, "Campaign completed");
campaign.raisedAmount += msg.value;
if (campaign.raisedAmount >= campaign.goal) {
campaign.completed = true;
}
}
function withdrawFunds(uint _campaignId) public {
Campaign storage campaign = campaigns[_campaignId];
require(msg.sender == campaign.creator, "Not campaign creator");
require(block.timestamp > campaign.deadline, "Campaign not ended");
campaign.creator.transfer(campaign.raisedAmount);
}
}
Contributions are welcome! To contribute:
git checkout -b feature/your-feature
.git commit -m 'Add some feature'
.git push origin feature/your-feature
.This project is licensed under the MIT License. See the LICENSE file for details.