1

This is my constructor. I cant figure out why this error is ocurring as the constructor is identical to another deployed contract.

It is related to the .createpair call. If i comment this out then it deploys. But no idea why!

constructor() {
_totalSupply = 10 * _billion * _decimalPointsCalc;
_balances[msg.sender] = _totalSupply;

_isExcludedFromInterest[owner()] = true;
_isExcludedFromTax[owner()] = true;
_isExcludedFromTax[address(this)] = true;
_isExcludedFromTax[address(0x0000000000000000000000000000000000000000)] = true;

_taxStorageDestination = payable(owner());
_testPancakeswapContract = payable(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3);
_pancakeswapRouterContract = _testPancakeswapContract;  // Change this before production deployment

IUniswapV2Router02 pancakeswapV2Router = IUniswapV2Router02(_pancakeswapRouterContract);
_pancakeswapV2LiquidityPair = IUniswapV2Factory(pancakeswapV2Router.factory())
    .createPair(address(this), pancakeswapV2Router.WETH()); // WETH is WBNB on Binance Smart Chain
_pancakeswapV2Router = pancakeswapV2Router;

emit Transfer(address(0), msg.sender, _totalSupply);
}

1 Answer 1

1

The cause for this was actually because i was deploying it to the Remix local deployment, and not to the actual blockchain.

The pancakeswap initialization was failing because no such contract existed locally in remix. It worked when deployed to the test net.

Not sure how to resolve this in remix. Maybe i have to deploy a clone of the router contract locally so that the constructor doesnt fail.

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.