# 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](/builders/for-developers/tutorials/deploy-a-token-contract-erc20.md)'. The only difference is down to the smart contract level which is different to an ERC20 token contract.&#x20;

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.

#### Prerequisites:

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:

{% code overflow="wrap" %}

```bash
mkdir my-erc721-token
cd my-erc721-token
```

{% endcode %}

* Initialize a new Node.js project with npm:

```bash
npm init -y
```

* Install Hardhat as a development dependency:

{% code overflow="wrap" %}

```bash
npm install --save-dev hardhat
```

{% endcode %}

* Initialize Hardhat in your project:

{% code overflow="wrap" %}

```bash
npx hardhat
```

{% endcode %}

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:

{% code overflow="wrap" %}

```solidity
// 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);
    }
}
```

{% endcode %}

* Make sure to install OpenZeppelin's ERC-721 library if you haven't already:

{% code overflow="wrap" %}

```bash
npm install @openzeppelin/contracts
```

{% endcode %}

#### 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:

{% code overflow="wrap" %}

```javascript
// hardhat.config.js
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");

module.exports = {
  networks: {
    // Add network configurations here (e.g., for local development, testnets, or mainnet).
    VANAR_TESTNET:{
      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",
};
```

{% endcode %}

**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:

{% code overflow="wrap" %}

```javascript
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();
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

```

{% endcode %}

#### Step 5: Deploy the NFT Contract

Run the deployment script using Hardhat:

{% code overflow="wrap" %}

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

{% endcode %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vanarchain.com/builders/for-developers/tutorials/deploy-an-nft-contract-erc721.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
