An Nft example using Hardhat, Polygon blockchain and OpenZeppelin.
Commands to create a new project using Hardhat
-
mkdir hardhat_polygon_nft -
cd hardhat_polygon_nft -
npm init --yes -
npm install --save-dev hardhat -
npx hardhat -
Create an
.envfile and add the private-key and rpc api-key in this file. we require these keys for configuring hardhat.config.js file. -
Please add this
.envfile to.gitignoreto avoid putting private information to github. -
Install
npm i dotenvpackage to use the environment variables from.envfile -
If using openzeppelin then
npm install @openzeppelin/contractscommand to add the packages.
Compile Project
npx hardhat compile
Test Project
npx hardhat test
Deploy Project
npx hardhat run scripts/deploy.js --network <network_name from hardhat.config.js file>
Example: npx hardhat run scripts/deploy.js --network polygon_test
References:
Hardhat docs
OpenZeppelin docs v4.x
Medium Article
Credits
Special thanks to Justin Hunter for creating a detailed medium article.