3

My smart contract runs in bsc normally on local ganache and the public test network, but in the private chain built by myself, it always prompts gas required exceeds allowance (8000000).I can not find the solution to solve the problem at all.help me

Source code:

IERC20 diamond;

function upgradePre(
        uint256 recordNo,
        uint256 tokenType,
        uint256 tokenId,
        uint256 expireTime,
        uint256 diamondquantity
    ) public payable {
        //is it timed out
        require(expireTime >= block.timestamp, "request expired");
        //Check for duplicate submissions
        require(!orders[recordNo].isCompletePre, "repeat transaction");
        //Ownership of the token
        require(
            msg.sender == _getOwnerByTokenIdAndTokenType(tokenId, tokenType),
            "owner exception"
        );
        //token's current level
        uint256 currentLevel = _getLevelByTokenIdAndTokenType(
            tokenId,
            tokenType
        );

        UpgradeConfItem memory upgradeConfItem = _getUpradeConf(tokenId, tokenType, currentLevel + 1);
        //start transfer
        require(upgradeConfItem.diamondquantity > 0 && diamondquantity >= upgradeConfItem.diamondquantity, "diamondquantity too small");
        require(
            diamond.balanceOf(msg.sender) >= diamondquantity,
            "Insufficient balance"
        );
        require(
            (diamond.allowance(msg.sender, address(this)) >= (diamondquantity)),
            "0xSUB: Allowance required"
        );
        require(
            diamond.transferFrom(msg.sender, receiveAddress, diamondquantity),
            "payment failed"
        );

        //init upgrade order
        _initUpgradeOrder(recordNo, tokenId, tokenType, currentLevel);
        //request random number
        logService.requestRandomNum(1, recordNo);
        //print biz log
        _logUpgradePre(
            recordNo,
            tokenId,
            tokenType,
            diamondquantity,
            currentLevel
        );
    }
robert
  • 31
  • 1
  • 4

2 Answers2

2

I met this problem because network problem.

just change to another server which has better network ( or which network is not blocked from rpc server)

Siwei
  • 19,858
  • 7
  • 75
  • 95
1

As this run successfully in BSC and Ganache. Then please check whether you have enough native token of your private chain in the wallet.

PySoL
  • 566
  • 3
  • 9