I am getting the below error on calling function setRouterAddress with router address 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 in testnet.
Gas estimation failed error Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted
this is message is coming for this line of code in the below function. IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
declarations: IUniswapV2Router02 public unswapV2Router; address public unswapV2Pair;
Function:
function setRouterAddress(address newRouter) external onlyOwner() returns(address, address){
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(newRouter);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
return (newRouter, uniswapV2Pair);
}
Could someone guide what is the problem ?