I'm trying to fork the UniswapV2 contracts.

I've already deployed on Mumbai testnet the core and periphery contracts, these are the addresses:

Core: 0xeBF7c7d1b9704516d7e0660BE568945D0bBb1aAc

Router: 0xbDFC84EBd535199146CEBE7D32f84d6fcd12766E

I'm running some tests with Hardhat, and I'm having trouble with the addLiquidityETH() function. I was able to add liquidity between two token with the addLiquidity() function (transaction here), but when I call the addLiquidityETH() I keep getting an error.

This is the failed transaction (here).

And here is my code for the test:

    it("should add liquidity token-eth", async function () {
      const [deployer] = await hre.ethers.getSigners();

      const SwapRouterV2 = await hre.ethers.getContractFactory("SwapRouterV2");
      const Token = await hre.ethers.getContractFactory("BasicToken");

      const router = await SwapRouterV2.attach("0xbDFC84EBd535199146CEBE7D32f84d6fcd12766E");
      const token1 = await Token.attach("0x11d7109cf229650678f922E32c1202f612141001"); 

      const blockNumber = await ethers.provider.getBlockNumber();
      const block = await ethers.provider.getBlock(blockNumber);
      const blockTimestamp = block.timestamp;
      const deadline = blockTimestamp + 60*20;

      const tx = await router.addLiquidityETH(token1.address, 2000, 1000, 1, deployer.address, BigNumber.from(deadline).toHexString(), {value: ethers.utils.parseEther("0.1")});
      console.log("TX hash",tx.hash);
      const receipt = await tx.wait();

I've already increased the allowance of the Router, but still I'm getting the transaction reverted.

The BasicToken contract is the Openzeppelin basic ERC20 contract, and the SwapRouterV2 is the UniswapRouterV2 contract, the only thing I changed was the name of the LP Token.

  • 1
    you can answer your own question, you know. this is the preferred way instead of editing the answer in the questions.
    – kfx
    Commented May 15, 2022 at 13:44
  • Answering your own question can also help you gain more reputation as well
    – Jasperan
    Commented May 27, 2022 at 4:33

1 Answer 1


[SOLVED] It turns out that the problem was with the WETH address I gave to the Router during deployment, I deployed my own WETH contract (you can find it here if you need it on Mumbai testnet) and it worked.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.