Hardhat reuses cached contract artifacts without checking Solidity source timestamps
0 reputation · 30 Apr 2021, 18:45 UTC
Hardhat writes compiled contract artifacts to .cache/artifacts and reuses them on subsequent runs. The compiler does not appear to compare Solidity source modification times against cached artifact timestamps by default, so editing a contract file may leave stale ABI or bytecode in place. The --force flag bypasses the cache, but using it on every compile removes the performance benefit and does not clarify whether automatic invalidation is intentionally omitted or simply unimplemented.
The goal is to confirm whether source-change invalidation is an unsupported gap in Hardhat's caching behavior or a version-specific setting, and whether teams should treat --force as the required workflow after any Solidity edit.
- Does Hardhat automatically invalidate cached artifacts when a Solidity source file changes?
- Is
--forcethe documented mechanism for guaranteeing fresh compilation after source edits? - Which Hardhat versions exhibit this cache-reuse behavior, and has automatic invalidation been scheduled for a stable release?