I'm following this tutorial for creating and deploying a smart contract (https://docs.alchemy.com/alchemy/tutorials/how-to-create-an-nft), but instead of deploying it on the ropstein test network I wanted to deploy it on the polygon mainnet. The only change I made to the steps in the tutorial is changing the alchemy app from ropstein to polygon and using it's URL. The issue that i have is when I'm trying to compile the hardhat config file i get the output "Nothing to compile". Even if I try to run the deploy script I get the output "HardhatError: HH700: Artifact for contract "MyNFT" not found". I've tried different times remaking the project but i still get the same errors.
Smart contract file: MyNFT.sol
//Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyNFT is ERC721, {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() public ERC721("Metablooms", "MTBS") {}
function mintNFT(address recipient, string memory tokenURI)
public
returns (uint256)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}
}
Hardhat config file:
require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
module.exports = {
defaultNetwork: "matic",
networks: {
hardhat: {},
matic: {
url: "https://polygon-mainnet.g.alchemy.com/v2/...the rest of the url",
accounts: ["my private key"]
}
},
solidity: {
version: "0.8.0",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
}
Cmd output when I'm tryng to compile :
C:\Users\Filippo\my-nft>npx hardhat compile
Nothing to compile
Cmd output when I try to run deploy.js :
C:\Users\Filippo\my-nft>npx hardhat run scripts/deploy.js --network matic
HardhatError: HH700: Artifact for contract "MyNFT" not found.
at Artifacts._handleWrongArtifactForContractName (C:\Users\Filippo\my-nft\node_modules\hardhat\src\internal\artifacts.ts:478:11)
at Artifacts._getArtifactPathFromFiles (C:\Users\Filippo\my-nft\node_modules\hardhat\src\internal\artifacts.ts:592:19)
at Artifacts._getArtifactPath (C:\Users\Filippo\my-nft\node_modules\hardhat\src\internal\artifacts.ts:275:17)
at Artifacts.readArtifact (C:\Users\Filippo\my-nft\node_modules\hardhat\src\internal\artifacts.ts:58:26)
at getContractFactory (C:\Users\Filippo\my-nft\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:91:22)
at main (C:\Users\Filippo\my-nft\scripts\deploy.js:3:19)