FairFund is a transparent blockchain-based aid distribution system designed specifically for small farmers. It implements a farmer-initiated model that allows farmers to request aid directly, enabling donors to contribute to specific farming projects in a transparent and accountable way.
FairFund bridges the gap between donors and small-scale farmers, creating a decentralized platform that:
- Enables farmers to directly request financial assistance for specific agricultural needs
- Allows donors to contribute directly to verified farmers' projects
- Provides transparency in the flow of funds from donors to beneficiaries
- Builds reputation and trust through a verification system
- Tracks donation history and successful disbursements
- Self-registration: Farmers can register with their details including location and farm type
- Aid requests: Create specific funding requests with detailed purposes and amounts
- Verification: Get verified by the platform to build trust with donors
- Direct fund receipt: Receive funds directly to their wallet once approved
- Registration: Create a profile with name and description
- Transparent giving: View all aid requests and choose which projects to fund
- Reputation system: Build reputation through consistent, successful disbursements
- Verification: Get verified to enhance trust with farmers and other stakeholders
- Verification management: Verify both farmers and donors to ensure authenticity
- Statistics tracking: Access comprehensive statistics on platform usage
- Transparency: All transactions and activities are recorded on the blockchain
FairFund is built on Ethereum using Solidity version 0.8.17. It implements the following main components:
- Structs for Donors, Farmers, and AidRequests
- Comprehensive mapping and tracking systems for all participants
- Event emissions for key actions to enable front-end notifications
- Role-based permission system with owner, donor, and farmer modifiers
- View functions to access aggregated statistics and individual profiles
-
Clone the repository:
git clone https://github.com/Rahulhanje/FairFund.git cd fairfund -
Install dependencies:
npm install
-
Compile the smart contract:
# Using Truffle truffle compile # Using Hardhat npx hardhat compile
-
Deploy to a test network:
# Using Truffle truffle migrate --network goerli # Using Hardhat npx hardhat run scripts/deploy.js --network goerli
await fairFund.registerFarmer(
"John Doe", // Name
"Nairobi, Kenya", // Location
"Organic Vegetables" // Farm type
);await fairFund.requestAid(
"Irrigation System", // Request name
"Installing drip irrigation", // Purpose
ethers.utils.parseEther("0.5") // Amount (in ETH)
);await fairFund.registerDonor(
"ABC Foundation", // Name
"Supporting sustainable farming" // Description
);await fairFund.fundAidRequest(
1, // Request ID
{ value: ethers.utils.parseEther("0.5") } // Amount to fund
);await fairFund.verifyFarmer("0x123..."); // Farmer's addressawait fairFund.verifyDonor("0x456..."); // Donor's addressconst stats = await fairFund.getContractStats();
console.log(`Total Donors: ${stats._totalDonors}`);
console.log(`Total Beneficiaries: ${stats._totalBeneficiaries}`);
console.log(`Total Funds Distributed: ${stats._totalFundsDistributed}`);const requests = await fairFund.getAllAidRequests();
// Returns arrays of request details including IDs, farmer addresses, etc.const farmers = await fairFund.getAllFarmers();
// Returns arrays of farmer details including addresses, names, locations, etc.const donors = await fairFund.getAllDonors();
// Returns arrays of donor details including addresses, names, descriptions, etc.The contract emits the following events that can be listened to:
DonorRegistered: When a new donor registersFarmerRegistered: When a new farmer registersAidRequested: When a farmer creates a new aid requestAidFunded: When a donor funds an aid requestDonorVerified: When an administrator verifies a donorFarmerVerified: When an administrator verifies a farmerReputationUpdated: When a donor's reputation score is updated
- The contract implements access controls using modifiers
- Verification system reduces the risk of fraudulent requests
- Reputation system helps identify reliable donors
- Direct fund transfers minimize intermediaries
- Consider additional security audits before mainnet deployment
- Multi-signature approvals for large aid requests
- Integration with oracle services for farm verification
- Support for non-ETH stablecoins
- Enhanced reputation algorithms
- Governance mechanisms for community-led decisions
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request