So I try to call the open trading function in my code which is as follows:
function openTrading() external onlyOwner() {
require(!tradingOpen,"Trading is open");
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
swapEnabled = true;
tradingOpen = true;
}
And I get the following error:
Transaction has been reverted by the EVM: { "blockHash": "0xa783f5ecc7bef888cf3bcd9a2aed64063333415c8a6ca867bbd6df0fe92ffbe4", "blockNumber": 4685778, "contractAddress": null, "cumulativeGasUsed": 417578, "effectiveGasPrice": 2128223284, "from": "0x9666a65844bc5eb78cac71a3452319ab53f8ab19", "gasUsed": 78359, "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "status": false, "to": "0xf17c8c7197303d8b31cd42210aded123093e8dfc", "transactionHash": "0x10a474f1dea6dbad7a5de890f83bacea3d5e593e27924e70a6b0cfc887c5845a", "transactionIndex": 1, "type": "0x2", "events": {} }
I assume it is a gas releated problem and I tried various different gas combinations but I just can't get it to work.