Skip to content
Latchkey

Hardhat "HardhatError: HH700: Artifact for contract not found" in CI

Hardhat looked for a compiled artifact under artifacts/ and found none matching the name you asked for. Either compilation never ran in CI, or the contract name passed to getContractFactory does not match any compiled contract.

What this error means

A test or deploy script fails with "HardhatError: HH700: Artifact for contract \"X\" not found", even though it runs locally where artifacts/ already exists.

Hardhat
HardhatError: HH700: Artifact for contract "Token" not found. Did you forget to compile?

Common causes

Compilation never ran on the runner

The artifacts/ directory is gitignored and CI ran tests before hardhat compile, so no artifact exists to load.

The contract name does not match

The string passed to getContractFactory differs from the actual contract name, or two contracts share a name and need a fully qualified file:Name reference.

How to fix it

Compile before running tests

  1. Add an explicit compile step before the test step.
  2. Confirm artifacts/ and cache/ are not stale from a previous partial build.
  3. Re-run so the artifact loader finds the contract.
Terminal
npx hardhat compile
npx hardhat test

Use the exact or fully qualified name

Match the contract name exactly, or disambiguate duplicates with the source path.

test/token.js
const F = await ethers.getContractFactory("contracts/Token.sol:Token");

How to prevent it

  • Run hardhat compile as its own CI step before tests.
  • Reference contracts by their exact compiled name.
  • Cache artifacts/ and cache/ keyed on the Solidity sources.

Frequently asked questions

What causes ""Artifact for contract ... not found""?
The artifacts/ directory is gitignored and CI ran tests before hardhat compile, so no artifact exists to load.
How do I fix "Artifact for contract ... not found"?
Compile before running tests

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card