The ChainFund contract is a crowdfunding smart contract that allows users to create and manage fundraising campaigns with different tiers of contributions. The contract includes functionalities for funding, withdrawing, refunding, and managing campaign tiers.
- name: The name of the campaign.
- description: The description of the campaign.
- goal: The funding goal of the campaign.
- deadline: The deadline for the campaign.
- owner: The owner of the campaign.
- paused: A boolean indicating if the contract is paused.
- image: The image URL of the campaign.
- state: The current state of the campaign (Active, Successful, Failed).
- tiers: An array of
Tierstructs representing different funding tiers. - backers: A mapping of addresses to
Backerstructs representing the backers of the campaign.
Represents a funding tier with the following properties:
- name: The name of the tier.
- amount: The amount required to fund the tier.
- backers: The number of backers for the tier.
Represents a backer with the following properties:
- totalContribution: The total contribution made by the backer.
- fundedTiers: A mapping of tier indices to booleans indicating if the backer has funded the tier.
- onlyOwner: Ensures that only the owner can call the function.
- campaignOpen: Ensures that the campaign is active.
- notPaused: Ensures that the contract is not paused.
The constructor initializes the campaign with the provided parameters and sets the initial state to Active.
- Internal function to check and update the campaign state based on the current balance and deadline.
- Allows users to fund a specific tier by sending the required amount.
- Allows the owner to add a new funding tier.
- Allows the owner to remove an existing funding tier.
- Allows the owner to withdraw the funds if the campaign is successful.
- Returns the current balance of the contract.
- Allows backers to get a refund if the campaign has failed.
- Checks if a backer has funded a specific tier.
- Returns the list of funding tiers.
- Allows the owner to toggle the pause state of the contract.
- Returns the current status of the campaign.
- Allows the owner to extend the campaign deadline.
- Deploy the ChainFund contract with the desired campaign details.
- Use the
addTierfunction to add different funding tiers.
- Users can fund specific tiers using the
fundfunction.
- If the campaign is successful, the owner can withdraw the funds using the
withdrawfunction.
- If the campaign fails, backers can get a refund using the
refundfunction.
- The owner can add or remove tiers as needed.
- The owner can pause or unpause the contract using the
togglePausefunction.
- The owner can extend the campaign deadline using the
extendDeadlinefunction.
This project is licensed under the MIT License.