current position:Home>Uniswap docking addliquidity displays false transaction mined but execution failed

Uniswap docking addliquidity displays false transaction mined but execution failed

2022-02-03 22:48:33 Q & A of Denglian community

I'm writing a sol file , It has been imported uniswapfactroy and uniswapexchange Interface file of , Next, create a new one util File complete addLiquidity , The code is as follows :

pragma solidity 0.6.0;import "./UniswapInterface.sol";import "./IERC20.sol";/** * @title The Utils of Uniswap * @author Tao */contract UniswapUtils {    // ropsten testnet    address public constant UNISWAP_FACTORY_ADDRESS = 0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351;    // TAO address    address public constant DAI_ADDRESS = 0x6DFEcD45BbAA2b0032B25F91Ee8D48C8FBbFB4b1;    /**     * @dev Get UniswapExchange     * @param _tokenAddress the address token contract     * @return the address of UniswapExchange     */     function getUniswapExchange(address _tokenAddress)        public        view        returns (address)    {        return            IUniswapFactory(UNISWAP_FACTORY_ADDRESS).getExchange(_tokenAddress);    }    function test0() public returns(address)    {        return IUniswapFactory(UNISWAP_FACTORY_ADDRESS).createExchange(DAI_ADDRESS);    }    function test1()public view returns(address)    {        IUniswapExchange uniswapExchange=IUniswapExchange(getUniswapExchange(DAI_ADDRESS));        return uniswapExchange.tokenAddress();    }    function test2() public payable returns(uint256)    {        IUniswapExchange uniswapExchange=IUniswapExchange(getUniswapExchange(DAI_ADDRESS));        IERC20(DAI_ADDRESS).approve(address(uniswapExchange), 100);        IERC20(DAI_ADDRESS).transferFrom(msg.sender, address(this), 100);        uniswapExchange.addLiquidity.value(msg.value)(            100,            100,            now + 120            );}

But it has been unable to add liquidity , The error information is as follows :https://ropsten.etherscan.io/tx/0x4a8f3840075889fe3f5cdd0fdb05085cc177fe879b99ab77fa8c8fd221bf9fc8






Other answers 1:


Other answers 2:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032248312510.html

Random recommended