0

Can you tell me, why addLiquidityETH is not working? I'm trying to call her through etherscan.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
   
    address public uniswapV2Pair;

    uint256 public amountToken;
    uint256 public amountETH;
    uint256 public liquidity;


    IUniswapV2Router public uniswapV2Router;
    IUniswapV2Factory public uniswapFactory;
    address router = 0x10ED43C718714eb63d5aA57B78B54704E256024E; // panceswap Router

    constructor() ERC20("test", "TEST") {
        uint256 initialSupply = 100000000000000000000;

        _mint(msg.sender, initialSupply);
        owner = msg.sender;
        IUniswapV2Router _uniswapV2Router = IUniswapV2Router(router);
        uniswapV2Router = _uniswapV2Router;
        IUniswapV2Factory _uniswapFactory = IUniswapV2Factory(
            uniswapV2Router.factory()
        );
        uniswapFactory = _uniswapFactory;


        
    }


    function addLiqETH2() external payable {
        (amountToken, amountETH, liquidity) = uniswapV2Router.addLiquidityETH{
            value: msg.value
        }(
            address(this),
            totalSupply(),
            0,
            0,
            address(<myAddress>),
            block.timestamp
        );
    }
2
  • 1
    Check if you have the right approvals.
    – kfx
    Commented Oct 23, 2023 at 16:46
  • Also please add the code as text to the post, not as image. I'm voting to close this as the little information that's present about the problem is in the image, so can't be searched.
    – kfx
    Commented Oct 23, 2023 at 16:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.