Common Hardhat and Solidity Errors

Summary
Common Hardhat and hardhat-deploy issues encountered during development.

Common hardhat Issues

This is a growing list of common Hardhat and Solidity errors I have run into.

hardhat-deploy: cannot find artifact “xxxx”

There are usually two possible causes:

  1. The contract really does not exist.
  2. There are duplicate contract definitions.

The first case is usually easy to spot. The second is harder to notice because the error message is misleading. If you see this error, make sure there are no duplicate contract definitions in the project.

Error: Cannot find module 'typechain/dist/TypeChain'

Cause: this happens when you are using the old hardhat-typechain package, which is no longer maintained.

Fix:

  1. Remove the hardhat-typechain dependency.
  2. Add typechain, @typechain/hardhat, and @typechain/ethers-v5.
1
yarn add -D typechain @typechain/hardhat @typechain/ethers-v5
  1. Update hardhat.config.ts:
1
2
- import 'hardhat-typechain';
+ import '@typechain/hardhat'

https://github.com/dethcrypto/TypeChain/issues/409