- Well-established standard with broad support from Ethereum wallets and exchanges.
- Allows for the creation of unique, non-fungible tokens.
- Suitable for creating digital collectibles and representing unique assets.
- Only allows for the creation of a single type of token.
- Inefficient for creating multiple types of NFTs.
- Using Hardhat
1. Write your ERC-721 contract
We'll use a contract based on the OpenZeppelin library’s [ERC-721 implementation]().
a) First, install the Open Zeppelin library in order to inherit its classes:
b) Next, create a file named NFT.sol under the contracts folder.
c) Lastly, add the following smart contract to NFT.sol file.
Note that we have named our contract NFT, this can be any name. The name will be important in the next step.
2. Install Hardhat Deploy
3. Install an Ethereum library
In this example, we will use Ether.js
4. Set environment variables with dotenv
- Install dotenv
Keep Your Private Keys Secret Private keys must be kept secret and not committed to any code repository. In the example of this tutorial, the .env file should be added to your .gitignore file and kept local. For example, see MyCrypto's Protecting Yourself and Your Funds guide.
- Create a .gitignore file
A great example of a Solidity .gitignore file can be found here
- Create an .env file n your project's root folder, and set environment variables in the file as follows
- Intro to Infura
- MetaMask Wallet Setup
5. Edit hardhat.config.js with the following text:
- You can add additional supported fields on the hardhat.config.js file.
6. Compile your Contract
To make sure everything is working so far, let’s compile our contract:
7. Write a deploy script
a) Navigate to the scripts folder and create a new file called deploy_NFT.js
b) Add the below code
8. Deploy to the target Palm network environment
- The task will execute the scripts in the scripts folder and saves the contract deployments to disk. Each deployment is saved into the deployments folder for the specific network.
9. Look Up Your Deployment on the Palm Network Block Explorer
Paste your contract address into the search bar.
Get your contract address in 2 ways:
- Console.log() output Contract deployed to address: contractNumber
- In deployments/palm_testnet/NFT.json or deployments/palm_mainnet/NFT.json where you will also find the ABI (Application Binary Interface) information.
You will see something like this upon successful deployment 👇
10. Verify via Sourcify
- Using Sourcify
Next Step 👉 Mint your NFT
Using the Smart Contract you just deployed you can now Mint NFTs with Hardhat