0

I'm writing a token contract that accepts and and issues varying ether/token amounts via conditional statements like so:

function getAirdrop() public payable {
    if (msg.value < 0.005 ether) {
       balances[msg.sender] += 4000;
    } else if ( (msg.value >= 0.005 ether) && (msg.value < 0.008 ether)) {
          balances[msg.sender] += 9000;
    } else if ( (msg.value >= 0.008 ether) && (msg.value < 0.016 ether)) {
          balances[msg.sender] += 13000;
    } else balances[msg.sender] += 25000;
}

How do I implement a blacklist in the first conditional to limit access like so:

mapping (address => bool) public blacklist;

 //  TODO:  function to clear blacklist    -----


 if (msg.value < 0.005 ether) {
       require(firstPurchaceTierAllowed);

   //  TODO:   Check if msg.sender is not blacklisted

       balances[msg.sender] += 4000;

   //  TODO:   Add msg.sender to blacklist
 } 

1 Answer 1

0

The blacklist checking is simple:

mapping (address => bool) public blacklist;

//  TODO:  function to clear blacklist    -----


 if (msg.value < 0.005 ether) {
       require(firstPurchaceTierAllowed);
       require(!blaclist[msg.sender]);
       balances[msg.sender] += 4000;
       blacklist[msg.sender] = true;
 } 

The clearing of the blacklist will be expensive you need to save in an array the blacklisted addresses and then delete the entries in the mapping. However, I can not see why is necessary to clear the blacklist. you can change the status of each subject at a time when they fulfill your criteria for being whitelisted.

Hope this help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.