Ive been launching degen play contracts and it is being botted by a certain address because he knows that I burn the LP everytime. Is there a way to blacklist this address? Ive seen his wallet and it contains most of the tokens I made. He is also the top holder of almost all of the tokens I made, hence the botting speculation. Keep in mind that he often get 25% of the supply at a low price most of the time.

What should I add in the solidity contract to blacklist this user?


While writing the contract; you can use a mapping to blacklist addresses.

contract BlackLkisted is Ownerhip {
    mapping(address=>bool) isBlacklisted;

    function blackList(address _user) public onlyOwner {
        require(!isBlacklisted[_user], "user already blacklisted");
        isBlacklisted[_user] = true;
        // emit events as well
    function removeFromBlacklist(address _user) public onlyOwner {
        require(isBlacklisted[_user], "user already whitelisted");
        isBlacklisted[_user] = false;
        // emit events as well
    function transfer(address _to, uint256 _value) public {
        require(!isBlacklisted[_to], "Recipient is backlisted");
        // remaining transfer logic
  • Hi! Thanks. At what part of the contract should I place this code segment and how do I interact with it? THANK YOU!
    – YawaMan
    May 17 '21 at 14:09
  • Is there anyway i can contact you sir? I really dont have any idea about coding in solidity. I am just forking a code, thats why i dont know where to place that code segment
    – YawaMan
    May 17 '21 at 14:26
  • Hi; you can reach out to me on skype: prashant23061 May 17 '21 at 16:24
  • 1
    Hey, slight mistake in your code, this will allow only blacklisted addresses to recieve tokens, i believe the intended result is the exact opposite ( require(!isBlacklisted[_to], "Recipient is backlisted" , ). Other than that everything works fine, although a modifier would probably be better than just adding a require to the transfer function (and would allow you to make it more custom, such as being able to turn the blacklist on or off...) @YawaMan did you manage to solve your problem?
    – Foxxxey
    Aug 19 '21 at 15:18
  • (oops didnt realise this topic was 3 months old lol, sorry)
    – Foxxxey
    Aug 19 '21 at 15:25

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.