- this is my personal implementation of a crowfunder project (similar to kickstarter)
The purpose of this project is the following:
- Build a smart contract that allows creators to register their projects.
- Other people can contribute ETH to that project.
- Once the goal has been met, the creators can withdraw the funds.
- When someone contributes 1 ETH, they receive a contributor badge NFT, which is tradable.
npm i
npx hardhat compile
npx hardhat test
- I split the logic into 2 contracts
Project.sol
andProjectFactory.sol
. I am using factory pattern here. - Every time a new project is registered, I create a new contract in Project using ProjectFactory.
I added comments within contract where each of these features is added
- The smart contract is reusable; multiple projects can be registered and accept ETH concurrently.
- (1a) Specifically, you should use the factory contract pattern.
- The goal is a preset amount of ETH.
- (2a) This cannot be changed after a project gets created.
- Regarding contributing:
- (3a) The contribute amount must be at least 0.01 ETH.
- (3b) There is no upper limit.
- (3c) Anyone can contribute to the project, including the creator.
- (3d) One address can contribute as many times as they like.
- (3e) No one can withdraw their funds until the project either fails or gets cancelled.
- Regarding contributer badges:
- (4a) An address receives a badge if their total contribution is at least 1 ETH.
- (4b) One address can receive multiple badges, but should only receive 1 badge per 1 ETH.
- (4c) Each project should use its own NFT contract.
- If the project is not fully funded within 30 days:
- (5a) The project goal is considered to have failed.
- (5b) No one can contribute anymore.
- (5c) Supporters get their money back.
- (5d) Contributor badges are left alone. They should still be tradable.
- Once a project becomes fully funded:
- (6a) No one else can contribute (however, the last contribution can go over the goal).
- (6b) The creator can withdraw any amount of contributed funds.
- The creator can choose to cancel their project before the 30 days are over, which has the same effect as a project failing.