there is a contract on github. I need to inherit it/ So how can I do it? Using import isn't available how I unnderstand..
https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol
there is a contract on github. I need to inherit it/ So how can I do it? Using import isn't available how I unnderstand..
https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol
You could just import from the GitHub link, but in your case there is an nom package containing that contract already so you could:
npm i @uniswap/v2-periphery
on your project.import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol';
Good Day
One Can Do the Following below your pragma statement
Add The Following
import "./interfaces/IUniswapV2Router01.sol";
Or
import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol';
above your constructor declare the following
address public routerContract;
in the Constructor you can do the following
constructor(address routerContractAddr){
routerContract= routerContractAddr;
}
in order to use the interface functions one can do the following
IUniswapV2Router01(routerContract).swapExactTokensForTokens(....);
remember to deploy your contract with the correct Uniswap
Router Address
an example of a deploy script using hardhat is illustrated below
module.exports = async ({ ethers, getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
await deploy("YourContract", {
from: deployer,
args: ["UNISWAP_CONTRACT_ADDRESS"],
deterministicDeployment: false,
log: true,
});
};
module.exports.tags = ["YourContract"];
I Really Hope That My Answer Provides Clarity
Thank You