Skip to content

Instantly share code, notes, and snippets.

@RachBLondon
Created June 17, 2020 09:26
Show Gist options
  • Save RachBLondon/056fa18373d99e630bba67c046b0a206 to your computer and use it in GitHub Desktop.
Save RachBLondon/056fa18373d99e630bba67c046b0a206 to your computer and use it in GitHub Desktop.
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