[Ethereum] HardhatError: HH700: Artifact for contract “Greeter” not found – clarification [Hardhat, openzeppelin]

binance-smart-chaincontract-developmenthardhatopenzeppelinsolidity

I keep getting this error when doing: npx hardhat run scripts/sample-script.js –network testnet.

I got an answer "You have named your contract 'Nikola' and not 'Greeter'. The actual file-names only matter for imports." to this issue: HardhatError: HH700: Artifact for contract "Greeter" not found.

But I have trouble fixing it, I deleted the contract greeter and edited greeter.sol to Nikola.sol but the problem remains.

Could someone give a piece of advice on what to do to fix this issue, would really appreciate it. At least clarify, would be great. What should I do to fix it?

enter image description here

An updated picture with sample-script.js on it.

enter image description here

secret@MacBook-Air-som-tillhor-secret Code 2 – Hardhat % npx hardhat run scripts/sample-script.js –network testnet

Compiling 1 file 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)

Best Answer

Keep in mind that your solidity contract's name has to match, too.

If you try to deploy with

const License = await ethers.getContractFactory('License');

this works

contract License {...}

this doesn't

contract MyLicense {...}