Created
June 17, 2020 09:26
-
-
Save RachBLondon/056fa18373d99e630bba67c046b0a206 to your computer and use it in GitHub Desktop.
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
contract PeriodicPayments { | |
uint public mostRecentSegmentTimeStamp; | |
uint public mostRecentSegmentPaid; | |
uint public lastSegment; | |
uint public moneyPot; | |
constructor() public { | |
mostRecentSegmentTimeStamp = block.timestamp; | |
mostRecentSegmentPaid = 0; | |
lastSegment = 3; | |
moneyPot = 0; | |
} | |
function checkSegment( uint timeSince) public { | |
if (now > (timeSince + 1 minutes) && (mostRecentSegmentPaid<= lastSegment)) { | |
fakePay(); | |
return; | |
} else { | |
return; | |
} | |
} | |
function fakePay () internal { | |
moneyPot = moneyPot + 1; | |
mostRecentSegmentPaid = mostRecentSegmentPaid + 1; | |
mostRecentSegmentTimeStamp = block.timestamp; | |
} | |
function makeDeposit() public { | |
checkSegment(mostRecentSegmentTimeStamp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment