Deploy an NFT Contract - ERC721

Deploying an ERC-721 token contract for NFTs on Vanar chain is a straightforward process that is exact similar to what is explained in 'Deploy a Token Contract - ERC20'. The only difference is down to the smart contract level which is different to an ERC20 token contract.

Below are the libraries and tools used for this tutorial:

  • OpenZeppelin - used for standard ERC20 base contract that is well tested and used by many production scale projects

  • Hardhat - is a tool and an environment that helps you compile, build, deploy and test you smart contracts along many other features.


  1. Node.js and npm installed on your machine.

  2. Basic knowledge of Solidity and Ethereum development.

Step 1: Set Up a New Hardhat Project

If you don't already have a Hardhat project, you can create one by following these steps:

  • Create a new directory for your project and navigate to it in the terminal:

mkdir my-erc721-token
cd my-erc721-token
  • Initialize a new Node.js project with npm:

npm init -y
  • Install Hardhat as a development dependency:

npm install --save-dev hardhat
  • Initialize Hardhat in your project:

npx hardhat

Follow the prompts to configure your project.

Step 2: Write the ERC-721 Token Contract

Now, you'll need to create a Solidity smart contract for your ERC-721 token. Create a new file called Token721.sol in the contracts directory.

Here's a basic example of an ERC-721 contract:

// contracts/Token.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract TestNFT is ERC721, Ownable {
    constructor() ERC721("Test NFT", "NFT") {}

    function mint(address to, uint256 tokenId) public onlyOwner {
        _mint(to, tokenId);
  • Make sure to install OpenZeppelin's ERC-721 library if you haven't already:

npm install @openzeppelin/contracts

Step 3: Configure Hardhat

In your Hardhat project, configure the deployment by modifying the hardhat.config.js file. You can specify the network, account, and other settings for deployment.

Here's an example configuration:

// hardhat.config.js

module.exports = {
  networks: {
    // Add network configurations here (e.g., for local development, testnets, or mainnet).
      url: "RPC_VANAR_VANGAURD",
      accounts: ["PRIVATE_KEY_OF_THE_DEPLOYER"],
      chainId: 7860
  etherscan: {
    apiKey: "YOUR_ETHERSCAN_API_KEY", // Replace with your Etherscan API key
  vanar: {
    apiKey: "YOUR_VANAR_API_KEY", // Replace with your VANAR API key
  solidity: "0.8.0",

Step 4: Deploy the ERC-20 Token

Now, you can deploy your ERC-20 token using Hardhat. Create a deployment script in the scripts directory (e.g., deploy721.js) to deploy the contract:

mkdir my-erc721-token
// scripts/deploy721.js
const { ethers, upgrades } = require("hardhat");

async function main() {
  const [deployer] = await ethers.getSigners();

  console.log("Deploying TestNFT from account:", deployer.address);

  const TestNFT = await ethers.getContractFactory("TestNFT");
  const testNFT = await TestNFT.deploy();

  console.log("TestNFT deployed to:", testNFT.address);

  await testNFT.deployed();

  .then(() => process.exit(0))
  .catch((error) => {

Step 5: Deploy the NFT Contract

Run the deployment script using Hardhat:

npx hardhat run scripts/deploy721.js --network <network_name>

Replace <network_name> with the configured VANAR network you want to deploy the token on.

That's it! You've deployed an ERC-721 token contract using Hardhat on VANAR. Make sure to test your token and handle any additional functionalities such as transfers, approvals, and more if needed.