A decentralized fundraising platform allowing users to create and manage fundraising campaigns with ERC20 token contributions.
fundraising/
├── src/
│ ├── interface/
│ │ ├── IFundraisingCampaign.sol # Campaign interface
│ │ └── IFundraisingFactory.sol # Factory interface
│ ├── FundraisingFactory.sol # Main factory contract
│ ├── FundraisingCampaign.sol # Individual campaign contract
├── test/
│ ├─ mock/
│ │ └── MockERC20.sol # Mock ERC20 for testing
│ ├── FundraisingFactory.t.sol # Factory tests
│ └── FundraisingCampaign.t.sol # Campaign tests
├── script/
│ ├── Deploy.s.sol # Deployment scripts
│ └── Interactions.s.sol # Interaction scripts
└── lib/
└── openzeppelin-contracts/ # Dependencies
- Campaign request submission
- Owner approval/rejection system
- Campaign deployment management
- Request status tracking
- Campaign registry
- Multi-token contribution support
- Min/Max amount enforcement
- Timeline management
- Claim/Refund system
- Campaign status tracking
- Solidity 0.8.28
- Foundry Framework
- OpenZeppelin 5.x.x
- Ownable
- SafeERC20
- ReentrancyGuard
| File | % Lines | % Statements | % Branches | % Funcs |
|-----------------------------|-----------------|-----------------|-----------------|----------------|
| src/FundraisingCampaign.sol | 100.00% (38/38) | 100.00% (42/42) | 100.00% (32/32) | 100.00% (5/5) |
| src/FundraisingFactory.sol | 100.00% (24/24) | 100.00% (24/24) | 100.00% (16/16) | 100.00% (5/5) |
- Clone the repository
git clone https://github.com/Ronfflex/Fundraising.git
cd fundraising
- Install dependencies
forge install
- Build the project
forge build
Run the complete test suite:
forge test
Run with verbosity:
forge test -vvv
Generate coverage report:
forge coverage --report lcov
- Set up your environment variables in
.env
:
PRIVATE_KEY=your_private_key
RPC_URL=your_rpc_url
ETHERSCAN_API_KEY=your_etherscan_api_key
- Deploy the contracts:
forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast --verify
The project includes scripts for common interactions:
- Create a new campaign:
forge script script/Interactions.s.sol:InteractionsScript --sig "createCampaign()" --rpc-url $RPC_URL --broadcast
- Review a campaign:
forge script script/Interactions.s.sol:InteractionsScript --sig "reviewCampaign(uint256,bool)" <request_id> true --rpc-url $RPC_URL --broadcast
- Contribute to a campaign:
forge script script/Interactions.s.sol:InteractionsScript --sig "contributeToCampaign(address,uint256,address)" <campaign_address> <amount> <token_address> --rpc-url $RPC_URL --broadcast
graph TD
A[FundraisingFactory] -->|deploys| B[FundraisingCampaign]
A -->|manages| C[Campaign Requests]
B -->|accepts| D[ERC20 Contributions]
B -->|manages| E[Fund Distribution]
stateDiagram-v2
[*] --> Pending: Request Submitted
Pending --> Accepted: Owner Approves
Pending --> Rejected: Owner Rejects
Accepted --> Active: Campaign Started
Active --> Successful: Target Reached
Active --> Failed: Target Not Reached
Successful --> [*]: Funds Claimed
Failed --> [*]: Funds Refunded
-
Access Control
- Ownable pattern for factory management
- Creator-only access for campaign management
-
Safety Measures
- ReentrancyGuard for all fund operations
- SafeERC20 for token transfers
- Checks-Effects-Interactions pattern
-
Timeline Enforcement
- Start/End date validation
- Status-based operation control
-
Amount Controls
- Minimum/Maximum target validation
- Contribution limit checks
MIT