Uniswap – HardhatError: HH700: Artifact for Contract ‘UniswapV2Router02’ Not Found

fantomhardhatroutertestuniswap

I wanna get UniswapV2Router02 deployed on Fantom network.

UniswapRouter = await ethers.getContractAt(
      "UniswapV2Router02",
      "0xf491e7b69e4244ad4002bc14e878a34207e38c29"
);

But I get the following error.
HardhatError: HH700: Artifact for contract "UniswapV2Router02" not found.

Please help me!

Best Answer

ethers.getContractAt is not ether js native method. Instead it is the variant of hardhat-ethers.

You should use ether.js method.

First go to, fantom scan and take the contract abi and save it in router02.json file.

Then require it to the main file with

const {ABI} = require("./router02.json")

require("dotenv").config();

const { ALCHEMY_API_KEY } = process.env;

const provider = new ethers.providers.JsonRpcProvider(
`[FantomAPiURL]/${ALCHEMY_API_KEY}`
 );

const address = "0xf491e7b69e4244ad4002bc14e878a34207e38c29";

const contract = new ethers.Contract(address, ABI, provider);

That is it. You will get contract instance there and you can function as you like.

If you have any doubts regarding .env file. Look at this answer of mine, I explained it clearly here.

Comment if you don't understand anything.

Related Topic