A decentralized crowdfunding platform that allows users to create and manage fundraising campaigns with multiple reward tiers. Built with gas optimization in mind using OpenZeppelin's Clones library.
This system uses the minimal proxy pattern (EIP-1167) through OpenZeppelin's Clones library to significantly reduce gas costs when deploying new campaigns. Instead of deploying the entire contract code for each new campaign, it deploys a minimal proxy that delegates all calls to an implementation contract.
- Uses only ~45 bytes of bytecode per deployment compared to full contract deployment
- Each new campaign costs approximately 10x less gas to deploy
- All campaigns share the same implementation logic while maintaining separate storage
- Enables cheap deployment of unlimited campaign instances
The system consists of two main contracts:
Crowdfunding.sol
: The implementation contract for individual campaignsCrowdfundingFactory.sol
: Factory contract that deploys campaign clones using minimal proxy pattern
- Optimized Deployment: Uses minimal proxy pattern for gas-efficient campaign creation
- Multiple Reward Tiers: Set up different funding levels with unique rewards
- Campaign Management: Tools for campaign owners
- Automatic Refunds: Built-in refund mechanism for failed campaigns
- Flexible Control: Pause/unpause functionality and deadline extensions
- Solidity ^0.8.17
- OpenZeppelin Contracts (for Clones library)
- thirdweb deployment tools
- Install thirdweb CLI:
npm install -g @thirdweb-dev/cli
- Initialize your project:
npx thirdweb create contract
- Deploy using thirdweb:
npx thirdweb deploy
1. Deploy implementation contract (Crowdfunding.sol)
2. Deploy factory with implementation address
3. Factory creates clones using Clones.clone()
4. Each clone is initialized with unique campaign parameters
// Creates a new campaign using minimal proxy pattern
function createCampaign(
string memory _name,
string memory _description,
uint256 _goal,
uint256 _durationInDays
)
// Get all campaigns by a specific user
function getUserCampaigns(address _user)
// Get all created campaigns
function getAllCampaigns()
// Initialize clone with campaign details
function initialize(
address _owner,
string memory _name,
string memory _description,
uint256 _goal,
uint256 _durationInDays
)
// Contribute to a specific tier
function fund(uint256 _tierIndex)
// Manage campaign tiers
function addTier(string memory _name, uint256 _amount)
function removeTier(uint256 _index)
Active
: Accepting contributionsSuccessful
: Reached goalFailed
: Ended without reaching goal
- Deploy through thirdweb dashboard
- Connect your wallet
- Deploy implementation contract
- Deploy factory contract with implementation address
// Using thirdweb SDK
const contractAddress = await deployPublishedContract({
client: client,
chain: sepolia, // your network
account: account!,
contractId: "Crowdfunding",
contractParams: {
_name: campaignName,
_description: campaignDescription,
_goal: campaignGoal,
_durationInDays: campaignDeadline,
},
publisher: "0x...",
version: "1.0.0",
});
- Protected initialization
- Owner-only access control
- Pausable functionality
- State-based guards
- Safe math operations (Solidity ^0.8.17)
# Build contracts
npx thirdweb build
# Deploy to your chosen network
npx thirdweb deploy
npx hardhat test
This project is licensed under the MIT License.
For security concerns, please open an issue or contact the repository maintainers.