Created
December 27, 2021 19:26
-
-
Save carloscarvallo/cfb99e33df348047664b65c321f34677 to your computer and use it in GitHub Desktop.
Crowdfunding with author verification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract CrowdFunding { | |
string public id; | |
string public name; | |
string public description; | |
address payable public author; | |
string public state = "Opened"; | |
uint public funds; | |
uint public fundraisingGoal; | |
address private owner; | |
constructor(string memory _id, string memory _name, string memory _description, uint _fundraisingGoal) { | |
id = _id; | |
name = _name; | |
description = _description; | |
fundraisingGoal = _fundraisingGoal; | |
owner = msg.sender; | |
author = payable(msg.sender); | |
} | |
modifier onlyOwner() { | |
require( | |
msg.sender == owner, | |
"Only owner can change project status" | |
); | |
_; | |
} | |
modifier notOwner() { | |
require( | |
msg.sender != owner, | |
"Owner can't fund project" | |
); | |
_; | |
} | |
function fundProject() public payable notOwner { | |
author.transfer(msg.value); | |
funds += msg.value; | |
} | |
function changeProjectState(string calldata newState) public onlyOwner { | |
state = newState; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment