Created
March 2, 2022 16:44
-
-
Save Scofield-Idehen/53e56cd1aa47a421861953a2650baacf to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&runs=200&gist=
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: MIT | |
pragma solidity ^0.4.17; | |
contract Campaign{ | |
//class day 2 | |
struct Request{ | |
string description; | |
uint value; | |
address recipient; | |
bool complete; | |
} | |
//day 2 | |
Request[] public requests; | |
address public manager; | |
uint public minimumcontribute; | |
//used to explain gas and why it is not functional | |
//address[] public approval; | |
mapping (address => bool) public approval; | |
//modifier created to restrict day 2 | |
modifier restricted(){ | |
require(msg.sender == manager); | |
_; | |
} | |
//constructor created to retrict the caller of the contract to the manager only and set | |
//min value | |
constructor(uint min) public { | |
manager = msg.sender; | |
minimumcontribute = min; | |
} | |
//contribute value must be greater than the amount called by the manager | |
function contribute() public payable{ | |
require(msg.value > minimumcontribute); | |
//who evers contribute address is saved in the approval file//keep for leaning 2 | |
//approval.push(msg.sender); | |
approval[msg.sender] = true; | |
} | |
//create request into the struct and restrict it to manager3 | |
//explain memory | |
function createRequest(string description, uint value, address recipient) public restricted { | |
Request memory NewManagerRequest = Request({ | |
description: description, | |
value: value, | |
recipient: recipient, | |
complete: false | |
}); | |
requests.push(NewManagerRequest); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment