0

I am somewhat new to solidity and I am trying to create an ERC20 contract myself.

I would like to know how could I create a whitelist in order for the addresses on the list to receive a 10% bonus when buying.

Thank you! :)

1

how could I create a whitelist in order for the addresses

Create a mapping in which addresses are mapped to boolean (true or false). This boolean value represents the presence of the address.

mapping(address => bool) whiteList;

function addToWhiteList(address user){
     whiteList[address] = true;
}

Or, hard code address in the contract

whiteList[address1] = true;
whiteList[address2] = true;

Now, when user buys your token, check if the address is in whiteList or not.

if(whiteList[user]) transfer(normal plus 10% extra); else transfer(normal);

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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