2

I keep getting this error when doing: npx hardhat run scripts/sample-script.js --network testnet. Edited the name of my computer for security reasons.

Compiling 10 files with 0.8.4 Compilation finished successfully HardhatError: HH700: Artifact for contract "Greeter" not found.

at Artifacts._handleWrongArtifactForContractName (/Users/secret/Documents/Code 2 - Hardhat /node_modules/hardhat/src/internal/artifacts.ts:473:11)
at Artifacts._getArtifactPathFromFiles (/Users/secret/Documents/Code 2 - Hardhat /node_modules/hardhat/src/internal/artifacts.ts:587:19)
at Artifacts._getArtifactPath (/Users/secret/Documents/Code 2 - Hardhat /node_modules/hardhat/src/internal/artifacts.ts:270:17)
at Artifacts.readArtifact (/Users/secret/Documents/Code 2 - Hardhat /node_modules/hardhat/src/internal/artifacts.ts:50:26)
at getContractFactoryByName (/Users/secret/Documents/Code 2 - Hardhat /node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:100:20)
at main (/Users/secret/Documents/Code 2 - Hardhat /scripts/sample-script.js:17:19)

secret@MacBook-Air-som-tillhor-secret Code 2 - Hardhat %

This is the view of the situation. If there's a contract you want me to upload, just say it I will upload. Thankful for every help I get.

enter image description here

1 Answer 1

2

You have named your contract 'Nikola' and not 'Greeter'. The actual file-names only matter for imports.

2
  • I changed the name of greeter.sol to nikola.sol but the problem remained, as I said before I'm very much thankful for your support, but would need a piece of extra advice on how I can fix this. There were two contracts, one Nikola and one greeter, and I deleted the greeter to then be able to fix it, but it didn't, same problem? Was I supposed to do that? Any advice on what I should do to fix it? Now I have tried it again and got this error: Error: Cannot find module '@nomiclabs/hardhat-waffle'
    – Feynman
    Commented Dec 5, 2021 at 18:18
  • the name of your contract is defined when you write contract Nikola { ... not by the .sol file
    – phaze
    Commented Dec 5, 2021 at 23:08

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.