[Ethereum] Use contract from outside contract folder in hardhat test

hardhatmocha

When I try to import a contract from other artifacts folders or node modules into the dapp test using

this.LinkToken = await ethers.getContractFactory('@chainlink/contracts/src/v0.4/LinkToken.sol')

it generates an error saying that it could not be found, I've gessed that it just looks in the artifacts/contracts folder.

I've also tried getContractAt and it generates the same result

Is it possible to import a contract outside of it?, thanks

The specific error is HardhatError: HH700: Artifact for contract "@chainlink/contracts/src/v0.4/LinkToken.sol" not found.

Best Answer

In you hardhat.config.js add this:

paths: {
   sources: "./<YOUR_CONTRACT_FOLDER>",
}