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
.env
file 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
.env
file to.gitignore
to avoid putting private information to github. -
Install
npm i dotenv
package to use the environment variables from.env
file -
If using openzeppelin then
npm install @openzeppelin/contracts
command 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.