After initializing with $ npx hardhat I am having trouble when deploying using hardhat.

HardhatError: HH700: Artifact for contract "<contract_name>" not found.

I can compile my contract with no errors $ npx hardhat compile, however when I try to deploy it using the deploy script I get the error:

$nnpx hardhat run scripts/deploy.js --network rinkeb

HardhatError: HH700: Artifact for contract "<contract_name>" not found.

In my hardhat.config.js I have the paths:

        sources: "./contracts",
        artifacts: "./artifacts",
        cache: "./cache"

and in the deploy script deploy.js I have

    const NFT = await hre.ethers.getContractFactory("contract");
    const nft = await NFT.deploy();

    await nft.deployed();

and I have te contract saved in contracts/contract.sol.

I don't know which is the problem.

3 Answers 3


Well, I managed to find out what was wrong. The contract filename and the contract definition were different. I don't know if the filename of the contract and the contract definition has to be the same.

In contracts/contract.sol I have:

pragma solidity ^0.8.0;

imports ...

contract NTFContract is ERC1155, Ownable {...

After renaming contracts/contract.sol --> contracts/NTFContract.sol I don't have this problem anymore and I am able to deploy it correctly.

I still wonder which is the convention in general for solidity and for hardhat.

edit: apparently contract name matching the filename is a convention


if you compiled with a different filename previously, it could be defunct cache data causing the error. you could try rebuilding the cache to clear the problem

$ npx hardhat clean ; npx hardhat compile

quick and easy so worth a try


"After renaming contracts/contract.sol --> contracts/NTFContract.sol I have no more this problem and I am able to deploy it correctly."

Make sure that the file name is changed in the cache/solidity-files-cache.json as well, otherwise the error will persist even after renamining.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.