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.
- Introduction
- Features
- Technologies Used
- Installation
- Usage
- Project Structure
- Smart Contract
- Contributing
- License
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.
- Decentralized: Operates on a blockchain network, ensuring security and transparency.
- Smart Contracts: Utilizes smart contracts to handle campaign creation and contributions.
- User Authentication: Secure user authentication via blockchain wallets.
- Responsive Design: Fully responsive design, compatible with various devices.
- Real-time Updates: Real-time updates on campaign status and contributions.
- React: Frontend framework.
- Ethereum: Blockchain platform for smart contracts.
- Solidity: Programming language for writing smart contracts.
- Web3.js: JavaScript library for interacting with the Ethereum blockchain.
- MetaMask: Browser extension for Ethereum wallet management.
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
.
- Connecting Wallet: Users need to connect their Ethereum wallet (e.g., MetaMask) to interact with the platform.
- Creating a Campaign: Users can create new crowdfunding campaigns by specifying the goal amount and deadline.
- Contributing to a Campaign: Users can contribute to existing campaigns using their Ethereum wallet.
- Viewing Campaigns: Users can view the list of all campaigns and their details, including the amount raised and time remaining.
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:
- Campaign creation
- Contribution management
- Fund withdrawal by campaign creators
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:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature
. - Make your changes and commit them:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/your-feature
. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.