0

I have a contract called Token.sol

Inside there is an interface:

interface TokenInterface {
}

followed by the contract with constructor having that interface


contract Token {

  TokenInterface public tokenInterface;

  constructor(TokenInterface _tokenInterface) {
    tokenInterface = _tokenInterface;
  }

How do I deploy this in hardhat test? Right now I have

    Token = await ethers.getContractFactory("Token");
    [owner, addr1, addr2, ...addrs] = await ethers.getSigners();

    token = await Token.deploy();

1 Answer 1

1

try this:

const Test = await hre.ethers.getContractFactory("TestInterface");
const test = await Test.deploy();

const Token = await hre.ethers.getContractFactory("Token");
const token = await Token.deploy(test.address);

once you deploy the constract that implements the interface you can get the address and pass it as a parameter to the deploy function as you can see in the example

enter image description here

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.