I've got this very simple Airdrop contract below:
contract ERC20 {
function transfer(address _to, uint256 _value)public returns(bool);
function balanceOf(address tokenOwner)public view returns(uint balance);
function transferFrom(address from, address to, uint tokens)public returns(bool success);
}
contract SimpleAirdrop {
ERC20 public token;
uint256 amount = 1000 * 10**18 //18 decimals token
function SimpleAirdrop(address _tokenAddr) public {
token = ERC20(_tokenAddr);
}
function getAirdrop() public {
token.transfer(msg.sender, amount);
}
}
I can deploy the contract with a given ERC20 address so I should be able to send token to this contract and users can call the getAirdrop() method and receive 1000 tokens
How can I prevent a user from being airdrop more than 1 time ? I could check the user balance but that doesn't proove he didn't received the airdrop already. Can I store a list of address that called the airdrop method ? What would be the gaz impact ?
Thank for your help !