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! :)
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityI 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! :)
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);