I've been learning how Solidity and Uniswap works.
I found a smart contract that appeals to me enough to want to use it to learn more Solidity with.
https://etherscan.io/address/0xa1fc6d28b2fc00ff0ff93b2da3f2b3c8ae85ad64#code
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_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);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 4250000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
looks simple enough? merely running openTrading() should work, right?
Instead I get an error of "Warning! Error encountered during contract execution [Reverted]". It's a bit baffling. I've commented out each line to see what could be causing that blocker and it seems to do everything else when it doesn't call uniswapV2Router.addLiquidityETH(). I've looked at the documentation for Uniswap, checked the syntax, balances and they all seem fine.
So, for a noob, in the context of Solidity, how to debug this properly and efficiently? I've used Remix to deploy this. For Uniswap, any ideas?
The etherscan transaction is at https://kovan.etherscan.io/tx/0x85772a6da056371fdbc797498dcb2fd3fc3cbca52375698bc6d9f9787928e2e2