pragma solidity^0.6.2;
interface ERC20Interface {
function balanceOf(address whom) external view returns (uint256);
}
contract GratitudeDispenser {
address private gratitudeTokenAddress;
// sets up the gratitude token addressthat can be checked on later
constructor(address _gratitudeTokenAddress) public {
gratitudeTokenAddress = _gratitudeTokenAddress;
}
function claim() external {
uint256 callerGratitudeTokenBalance = ERC20Interface(gratitudeTokenAddress).balanceOf(msg.sender);
if (callerGratitudeTokenBalance >= 1e18) {
msg.sender.transfer(address(this).balance);
}
}
fallback () external payable {
}
}
/*
[
{
"inputs": [],
"name": "claim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gratitudeTokenAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"stateMutability": "payable",
"type": "fallback"
}
]
*/
{
"compilationTarget": {
"browser/GratitudeDispenser.sol": "GratitudeDispenser"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_gratitudeTokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"}]