i have been using my 1st testnet token for 2 months+, all works great, but suddenly in mid August error as per title starts popping up.

So now i cant send this token using metamask to other wallet. What i've tried but failed:

  • increase gas limit
  • refresh browser, reset laptop, reset metamask
  • create new very basic token (MTK), test sending, works fine.

error with sending 1st testnet token, but transfer of 2nd token works fine.

error sending PEPE2. only 26% gas limit used, and tx failed. https://testnet.bscscan.com/tx/0xa6a7e7064fd4cf1b0775bc0e8aca1c04d56fa0b19b0a46993a68d68494323515

Ok sending MTK. https://testnet.bscscan.com/tx/0x5b74d096097cb4da1d29db81ad0dac0db492d40fbe5bca3fac6bc91a132b785e

what is the issue here? how do i fix this? this dont make sense to me. can somebody try to reproduce this and let me know what is wrong?

1st test token (PEPE2):

pragma solidity ^0.8.0;

contract PepeToken is Ownable, ERC20 {
    bool public limited;
    uint256 public maxHoldingAmount;
    uint256 public minHoldingAmount;
    address public uniswapV2Pair;
    mapping(address => bool) public blacklists;

    constructor(uint256 _totalSupply) ERC20("Pepe", "PEPE") {
        _mint(msg.sender, _totalSupply);

    function blacklist(address _address, bool _isBlacklisting) external onlyOwner {
        blacklists[_address] = _isBlacklisting;

    function setRule(bool _limited, address _uniswapV2Pair, uint256 _maxHoldingAmount, uint256 _minHoldingAmount) external onlyOwner {
        limited = _limited;
        uniswapV2Pair = _uniswapV2Pair;
        maxHoldingAmount = _maxHoldingAmount;
        minHoldingAmount = _minHoldingAmount;

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) override internal virtual {
        require(!blacklists[to] && !blacklists[from], "Blacklisted");

        if (uniswapV2Pair == address(0)) {
            require(from == owner() || to == owner(), "trading is not started");

        if (limited && from == uniswapV2Pair) {
            require(super.balanceOf(to) + amount <= maxHoldingAmount && super.balanceOf(to) + amount >= minHoldingAmount, "Forbid");

    function burn(uint256 value) external {
        _burn(msg.sender, value);

2nd test token contract (MTK):

pragma solidity ^0.8.9;

contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 1000000000000 * 10 ** decimals());

1 Answer 1


i just realized that in my PEPE2 contract has this check:

if (uniswapV2Pair == address(0)) {
    require(from == owner() || to == owner(), "trading is not started");

so after i use the setRule() function, i can now transfer token to other addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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