Donation Pool
Overview
The Donation Pool is a central feature of Charity Coin, designed to accumulate and manage funds for charitable causes. It ensures transparency and community-driven allocation of resources.
Purpose
The Donation Pool contract acts as a custodian for all donated funds, managing and disbursing them according to governance directives. It handles ETH and ERC-20 tokens to maintain compatibility and security within the Ethereum ecosystem.
Key Features
Donation Tracking
- Individual Donations: Tracks donations per donor and token.
- Total Donations: Maintains the total donations received for each token.
- Token Addresses: Stores an array of unique token addresses involved in donations.
Approval and Transfer Mechanisms
- Approve Spending: Allows the multi-signature signers to approve token spending.
- Transfer to Charity: Transfers funds to specified charities, ensuring sufficient balance.
Smart Contract Summary
Functions
updatePool
- Purpose: Updates donation records and emits a Donation event.
- Parameters:
sender
,token
,amount
- Usage: Called to log new donations and update totals.
approveSpending
- Purpose: Approves the contract to spend a specified amount of tokens.
- Access Control: Restricted to the contract owners.
transferToCharity
- Purpose: Transfers funds to a specified charity.
- Parameters:
token
,recipient
,amount
- Requirements: Ensures the amount is greater than zero and that there is a sufficient balance.
Security
- Reentrancy Guard: Ensures functions are protected against reentrancy attacks.
- Owner Controls: Only the contract owners can approve and transfer funds, ensuring controlled disbursements.
Smart Contract Code
For detailed code and implementation, refer to the DonationPool.sol contract on GitHub (opens in a new tab).