How do I properly call the transferTokens() function?

This first contract creates a liqudity pool for the two tokens on sepolia test net

// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

// Using npm package imports for a Hardhat or Truffle project
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";

contract createLpPool

    IUniswapV3Factory public immutable factory;
    address public immutable facaddy=0x0227628f3F023bb0B980b67D528571c95c6DaC1c;

    address public immutable WETH=0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14;
    address public immutable TESTTOKEN=0x46d8c56588aE7172701f2F20a026FCe95A06E871;

    uint24 public immutable fee=10000;


    function makePool() external returns(address pool)

        return pool;



Then in this code I try adding some tokens and eth to the liqudity pool but then whenever I call the transferTokens() I get this error:Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Error happened while trying to execute a function inside a smart contract

pragma solidity 0.8.25;

import "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract addLiq


    INonfungiblePositionManager public immutable managerAddress;
    address public managerAddy=0x1238536071E1c677A632429e3655c799b22cDA52;

    IERC20 public  WETH;
    IERC20 public  TESTTOKEN;


    uint24 public immutable Fee=10000;

    uint256 internal immutable amount0Desired=1 ether;
    uint256 internal immutable amount1Desired=50_000 ether;
    int24 internal immutable lowerTick= -887220;
    int24 internal immutable upperTick= 887220;


    function approveContract() external 
        // Check balances
        require(WETH.balanceOf(msg.sender) >= amount0Desired, "Insufficient WETH balance");
        require(TESTTOKEN.balanceOf(msg.sender) >= amount1Desired, "Insufficient ASND balance");

        // Check allowances

    function transferTokens() external 
        // Transfer tokens from the user to this contract
        require(WETH.transferFrom(msg.sender, address(this), amount0Desired), "WETH transfer failed");
        require(TESTTOKEN.transferFrom(msg.sender, address(this), amount1Desired), "ASND transfer failed");

    function approveManagerContract() external
        // Now approve Uniswap manager to use these tokens
        WETH.approve(address(managerAddress), amount0Desired);
        TESTTOKEN.approve(address(managerAddress), amount1Desired);

    function addLiquidity() external 
        // Ensure this contract already has the necessary approvals to Uniswap manager
        INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams
            token0: address(WETH),
            token1: address(TESTTOKEN),
            fee: Fee,
            tickLower: lowerTick,
            tickUpper: upperTick,
            amount0Desired: amount0Desired,
            amount1Desired: amount1Desired,
            amount0Min: 0,
            amount1Min: 0,
            recipient: msg.sender,
            deadline: block.timestamp + 15 minutes


I am trying to work off of this example adding liq example
But after sucessfully approve the contract to have access to the tokens and then I go to call transferTokens it gets the gas error.I have triple checked I have all the right contract addresses and that I have enough WETH and TESTTOKEN in my balance

1 Like