Generating artifacts from npm dependencies
By default, Hardhat generates compilation artifacts for all the contracts in your project, but not for those in the project’s npm dependencies. If you want to generate artifacts for a specific file in an npm dependency, you can use the npmFilesToBuild property:
import { defineConfig } from "hardhat/config";
export default defineConfig({ // ... solidity: { version: "0.8.29", npmFilesToBuild: ["some-dependency/contracts/SomeContract.sol"], },});You can use artifacts to deploy contracts, obtain their ABIs, and more. For example, once you’ve configured Hardhat to generate artifacts for some-dependency/contracts/SomeContract.sol, you can use that contract in your tests like this:
const someContract = await viem.deployContract("SomeContract");