Skip to content

Instantly share code, notes, and snippets.

@Swader
Created July 22, 2019 22:10
Show Gist options
  • Save Swader/409d83e20aa5f782575438aa82076a12 to your computer and use it in GitHub Desktop.
Save Swader/409d83e20aa5f782575438aa82076a12 to your computer and use it in GitHub Desktop.
HumanRewarder
pragma solidity 0.5.1;
contract HasVoted {
mapping (address => bool) public voted;
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
}
contract HumanRewarder {
HasVoted humanHasVoted;
address public thatRichDude;
IERC20 rewardToken;
uint256 public startTime;
mapping (address => bool) public claimed;
constructor() public {
humanHasVoted = HasVoted(0x43FCedE3571C10aCa1d3C12339bF01423b118e81);
rewardToken = IERC20(0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359);
thatRichDude = address(0x2566190503393b80bdEd55228C61A175f40E4D42);
}
modifier _hasVoted() {
require(humanHasVoted.voted(msg.sender), "Tut tut! You didn't vote!");
_;
}
function getPotBack() public {
require(address(msg.sender) == thatRichDude, "Only Rich can withdraw the money");
require(startTime + 7 days > now, "7 days need to have passed");
rewardToken.transfer(address(msg.sender), rewardToken.balanceOf(address(this)));
}
function grabReward() _hasVoted public {
require(rewardToken.balanceOf(address(this)) >= 1 ether, "No funds in the reward contract");
require(!claimed[msg.sender], "You already got your DOLLAH");
rewardToken.transfer(address(msg.sender), 1 ether);
}
function remainingDai() view public returns(uint256){
return rewardToken.balanceOf(address(this));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment