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.
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
- Add an explicit compile step before the test step.
- Confirm
artifacts/andcache/are not stale from a previous partial build. - Re-run so the artifact loader finds the contract.
npx hardhat compile
npx hardhat testUse the exact or fully qualified name
Match the contract name exactly, or disambiguate duplicates with the source path.
const F = await ethers.getContractFactory("contracts/Token.sol:Token");How to prevent it
- Run
hardhat compileas its own CI step before tests. - Reference contracts by their exact compiled name.
- Cache
artifacts/andcache/keyed on the Solidity sources.