BEP20 How to exclude the burn wallet from the maxlimit function

373 Views Asked by At

Am trying to create a project and new to solidity. I added a max limit to prevent whale wallets. The limit is 150m tokens and i would like to burn a higher amount, how can i exclude the burn adress 0x0000000000000000000000000000000000000000 from this function.

Codes:

@ function _transfer(

 uint256 contractBalanceRecepient = balanceOf(to);
 require(contractBalanceRecepient + amount <= _maxWalletToken, "Exceeds maximum wallet token amount (150,000,000)");

kind regards Kevin!

1

There are 1 best solutions below

0
On

You can extend the condition in require() so that it only applies for addresses that are not 0x0.

require(
    (
        contractBalanceRecepient + amount <= _maxWalletToken
        && to != address(0x0)
    ),
    "Exceeds maximum wallet token amount (150,000,000)"
);

Note: Most burn implementations do not transfer the tokens to 0x0. Instead, they just lower the total supply, lower the sender balance and emit the Transfer() event as if they were transfering to 0x0 - without performing the actual transfer... But your way (actual transfer to 0x0) is possible as well.