0

I'm messing around with Chainlink oracles and was running a test case with a VRF Consumer contract. I needed the LinkTokenInterface to get the LINK balance of my contract. I was completely lost and randomly tried linkToken = await ethers.getContractAt("LinkTokenInterface", LINK_ADDR); AND IT WORKED! The LinkTokenInterface is nested within the chainlink module and outside the contracts directory.

How did hardhat know what file to compile!? I thought all .sol files needed to be stored in contracts?

1
  • 1
    I think before you are using it in hardhat, you install the dependencies in your project, like the command: yarn add "@chainlink/contracts". For function getContractAt, it is a function in hardhat-ethers and can create a object with address and ABI.
    – Frank Kong
    Nov 12 at 6:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy