The Launchpad contract is a crowdfunding platform that enables project owners to raise funds for their projects.
-
Project Creation: The contract allows project owners to create crowdfunding projects. Each project has a project owner, a title, a description, a funding goal amount, and a deadline. -
Contribution: Contributors can contribute funds to the projects by specifying the project ID and sending the desired amount of Ether. -
Milestone-based Withdrawal: If a project is successfully completed, meaning it reaches its funding goal within the specified deadline, the project creator can create a milestone-based withdraw request. This request includes the amount required and an objective that specifies how the requested funds will be used. -
Voting on Withdraw Requests: Once a withdraw request is created, contributors can vote on the request. If more than 50% of the contributors vote in favor of the request, it is approved. -
Withdrawal of Approved Funds: Upon successful approval of a withdraw request, the project creator can withdraw the requested amount of funds. This transfer is made to the project creator's address. -
Refunds for Failed Projects: If a project fails to reach its funding goal within the deadline, the project funding is considered as failed. In this case, contributors can claim a refund and withdraw the amount they have contributed. The refund is sent to the contributor's address.
-
The
Statusenum represents the status of a project. It has three possible values:Active: The project is currently accepting contributions.Successful: The project has reached its funding goal.Failed: The project did not reach its funding goal within the specified deadline.
-
The
Projectstruct represents a crowdfunding project. It contains the following properties:projectId: The ID of the project.creator: The address of the project creator.title: The title of the project.description: The description of the project.goalAmount: The funding goal amount for the project.deadline: The deadline for the project.raisedAmount: The total amount raised for the project.withdrawnAmount: The total amount withdrawn from the project.contributorsCount: The number of contributors to the project.projectStatus: The status of the project.
-
The
WithdrawRequeststruct represents a withdraw request for a project. It contains the following properties:projectId: The ID of the project.creator: The address of the withdraw request creator.description: The description of the withdraw request, including milestones.amount: The amount requested for withdrawal.voteCount: The total number of votes received for the withdraw request.isWithdrawn: A boolean indicating whether the requested amount has been withdrawn.
-
The
projectCountvariable stores the total number of projects created. -
The
withdrawRequestCountvariable stores the total number of withdraw requests created. -
The
withdrawRequestsmapping stores withdraw requests by their ID. Given a withdraw request ID, it returns the correspondingWithdrawRequeststruct. -
The
projectsarray contains all the crowdfunding projects created. -
The
contributionsmapping stores contributions to projects. It maps a project index to a contributor address and their corresponding contribution amount. -
The
votersmapping stores the voting status of contributors for withdraw requests. It maps a withdraw request index to a voter address and their corresponding voting status.
-
The
ProjectCreatedevent is emitted when a new project is created. It includes the project ID, title, and creator's address. -
The
Contributedevent is emitted when a contribution is made to a project. It includes the project ID, contributor's address, and the contribution amount. -
The
WithdrawRequestCreatedevent is emitted when a withdraw request is created. It includes the withdraw request count, project ID, creator's address, description, and the requested amount. -
The
Votedevent is emitted when a contributor votes for a withdraw request. It includes the withdraw request index, voter's address, and the number of votes. -
The
Withdrawedevent is emitted when funds are withdrawn from a project. It includes the project ID, the project creator's address, and the amount withdrawn. -
The
Refundedevent is emitted when a refund is claimed by a contributor. It includes the project ID, contributor's address, and the refunded amount.
The contract provides the following functions:
-
The
createProjectfunction allows a user to create a new crowdfunding project. It takes the title, description, funding goal amount, and duration as parameters. -
The
contributefunction allows a user to contribute funds to a project. It takes the project ID as a parameter. -
The
createWithdrawRequestfunction allows the project creator to create a withdraw request. It takes the project ID, creator's address, description, and requested amount as parameters. -
The
voteWithdrawRequestfunction allows contributors to vote for a withdraw request. It takes the withdraw request ID as a parameter. -
The
withdrawFundsfunction allows the project creator to withdraw funds from a successful project. It takes the withdraw request ID as a parameter. -
The
claimRefundfunction allows contributors to claim a refund for a failed project. It takes the project ID as a parameter. -
The
getProjectDetailsfunction retrieves the details of a project. It takes the project ID as a parameter and returns the project details. -
The
computeStatusfunction is an internal function that computes the status of a project based on its raised amount and deadline. It takes the project index as a parameter and updates the project status accordingly.
These functions provide the necessary functionality to create projects, contribute to projects, create withdraw requests, vote for withdraw requests, and withdraw funds or claim refunds based on the project status.