I am trying to create an ABI from my Solidity smart contract.
When I run npx hardhat run --network testnet scripts/deploy.js
It gives me and HardhatError: Artifact for contract "CertData" not found.
I am pretty sure that I did not do any spelling mistakega in the smart contract name.
My deploy.js script is located in scripts/deploy.js
Content of script:
const hre = require("hardhat");
async function main() {
const CertData = await hre.ethers.getContractFactory("CertData");
const certData = await CertData.deploy();
await certData.deployed();
const txHash = certData.deployTransaction.hash;
const txReceipt = await hre.ethers.provider.waitForTransaction(txHash);
console.log(
`check your contract: https://mumbai.polygonscan.com/address/${txReceipt.contractAddress}`
);
console.log("contract address:", txReceipt.contractAddress);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
And my CertData.sol file:
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract CertData {
Cert[] private certs;
mapping(address => Cert[]) private authorToCerts;
struct Cert {
string title;
string description;
string owner;
}
function store(string memory title, string memory description, string memory owner) public {
Cert memory cert = Cert(title, description, owner);
certs.push(cert);
authorToCerts[msg.sender].push(cert);
}
function retrieveAllCerts() public view returns (Cert[] memory) {
return certs;
}
function retrieveCertsByAuthor() public view returns (Cert[] memory) {
return authorToCerts[msg.sender];
}
}
hardhat.config.js file content:
require("@nomiclabs/hardhat-waffle");
require("dotenv").config();
const privateKey = process.env.PRIVATE_KEY;
module.exports = {
networks: {
hardhat: {
chainId: 1337,
},
testnet: {
url: "https://rpc-mumbai.maticvigil.com",
accounts: [privateKey],
},
mainnet: {
url: "https://polygon-rpc.com",
accounts: [privateKey],
},
},
solidity: "0.8.4",
};
My folder structure:
Thanks to everyone