Put tokens in PanCakeSwap liquidity pool with a limit on number of tokens per address

I created a BEP20 Smart contract using

There are 10 billion tokens and there is a limit of 300 million tokens per address. This is the line of code I added in the _transfer() function to set the limit. (300 million + 18 zeros for 18 decimal places)

        require(_balances[recipient] + amount <= 300000000000000000000000000, "ERC20: transfer 
        amount exceeds address limit"); // to limit number of tokens on address

The problem is, I am trying to put 9.7 billion tokens in the PanCakeSwap liquidity pool but it doesn’t let me. I presume this is because of the limit I have set per address. It lets me add 300 million tokens to the liquidity pool but nothing more than that.

:computer: Environment

solidity v0.8.0

:memo:Details

I am using the Remix IDE. Is there a function I can call to increase/remove the limit for the pancakeswap address? Will the allowance function help me here?

:1234: Code to reproduce

    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");

    _beforeTokenTransfer(sender, recipient, amount);

    uint256 senderBalance = _balances[sender];
    require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
    require(_balances[recipient] + amount <= 300000000000000000000000000, "ERC20: transfer amount exceeds address limit"); // to limit number of tokens on address
    _balances[sender] = senderBalance - amount;
    _balances[recipient] += amount;

    emit Transfer(sender, recipient, amount);
}

I would really appreciate your help here. Thank you!

Hi, welcome! :wave:

Sorry, I am not familiar with the BSC-Chain, maybe you should ask for help in their forum: Home | Binance Chain Forum

I think you can add an extra logic in the _transfer:

if (msg.sender == owner) {
  // transfer directly
} else {
  require(_balances[recipient] + amount <= 300000000000000000000000000, "ERC20: transfer amount exceeds address limit");
}

Thank you for the solution. As per my best knowledge, ERC20 and BEP20 tokens are similar. Do you think there is any way that I can just increase the allowance for pancakeswap?

Sorry, I am not familiar with the BSC-Chain, maybe you should ask for help in their forum: Home | Binance Chain Forum

I think just like what you will do for the ERC20 contract.

Alright, I will do that, thank you!

You can also exclude Pancake from the “require” condition

Wow, that sounds promising.
I think this is the address for PanCakeSwap - 0x10ED43C718714eb63d5aA57B78B54704E256024E ,
I found it from this transaction and I hope it is right. https://bscscan.com/tx/0x16a76bc669b05f136f279cc5a41a24a1fb3d5daa723bb34846ac6e88fe561901

Should I create a whitelist function as well, or just use logical operators to check the balance and whether or not it is the pancakeswap address?

Whitelist can ne useful if you have many addresses to exclude. It should be an array so if you don’t need it, then it is useless