I'm working on a contract that pays a percentage of interest of a token. The idea is to enable the fallback function only once for an address, and then it can access again to the function when it is whitelisted again. Here's an extract of my code:
contract PercDistribution {
mapping (address => uint256) balances;
mapping (address => bool) public whitelist;
Token public myToken;
address public owner;
function PercDistribution(address _tokenAddress, address _owner) {
myToken = Token(_tokenAddress);
owner = _owner;
}
function enableWhitelist(address[] _addresses) onlyOwner {
for (uint i = 0; i < _addresses.length; i++) {
whitelist[_addresses[i]] = true;
}
}
function disableWhitelist(address[] _addresses) onlyOwner {
for (uint i = 0; i < _addresses.length; i++) {
whitelist[_addresses[i]] = false;
}
}
modifier onlyWhitelist() {
require(whitelist[msg.sender] == true);
_;
}
modifier onlyOwner() {
require(owner == msg.sender);
_;
}
function () payable onlyWhitelist public {
address investor = msg.sender;
//do something
whitelist[investor] = false;
}
}
Everything works as expected; I whitelist addresses in batch and then when someone call the fallback function his address is blacklisted until I whitelist it again. My question is: is there a way to whitelist every address (and I mean every one that could be created) with a single function, without having to batch thousands of address with the enableWhitelist
function?