Created
December 22, 2021 22:50
-
-
Save carloscarvallo/984e3d4471887e4c3bdf700a75571210 to your computer and use it in GitHub Desktop.
Crowd funding smart contract example with optimized variables to minimize Gas
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; | |
constructor(string memory _id, string memory _name, string memory _description, uint _fundraisingGoal) { | |
id = _id; | |
name = _name; | |
description = _description; | |
fundraisingGoal = _fundraisingGoal; | |
author = payable(msg.sender); | |
} | |
function fundProject() public payable { | |
author.transfer(msg.value); | |
funds += msg.value; | |
} | |
function changeProjectState(string calldata newState) public { | |
state = newState; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment