I want to use a contract in node_modules in my tests, but I'm getting:
HardhatError: HH700: Artifact for contract "SomeContract" not found.
This is probably because it's not used by any files under /contracts
directory, hence not generating the artifact. Is there a way to compile these contracts inside node_module?
Best Answer
There are two solutions.
1. Imports Contract
This is what I'm doing in my personal contracts library
As you can see, all this is doing is importing the external contract from an npm package, such that Hardhat will pick it up and generate an artifact for it.
2. Use hardhat-dependency-compiler
It's a Hardhat plugin developed by Nick Barry. Install it:
And add the following to your Hardhat config file:
For what it's worth, I prefer the first solution. It's less verbose in that I don't add yet-another-node-package to my
package.json
file.