2021 Fillmore Street #1128

}

24/7 solutions

Top 10 Cloud Providers

How to Verify an NFT on the Mumbai Test Network 4/4

This is part 4 in a 4 step tutorial to minting NFTs on Polygon where we'll verify an NFT using Hardhat on the Mumbai test network for Polygon.

Part 4 of 4 - Using Hardhat

Once you’ve deployed your contract to Polygon, then you’ll want to verify your smart contract in the event that someone wants to invoke some of the functions on your smart contract. To verify the contract, we’re going to install the following plugin

npm install @nomiclabs/hardhat-etherscan

In order for the code to be verified on PolygonScan, you’ll need to navigate here https://polygonscan.com/myapikey, create a new account, and provision an API key. Once you’ve provisioned your API key, you’ll take your API key, and stick it into your .env file so your javascript code can access the key as an environment variable, and the key won’t be checked into Github due to the .gitignore.

In your hardhat.config.js, you’ll add the following snippets of code. The first line will import the environment variable into a variable that we can manipulate in javascript land. The second line will import the Etherscan code that we’re going to use to do the verification.

const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY; 
require("@nomiclabs/hardhat-etherscan");

Further on down, you’ll specify the etherscan.apiKey, the apiKey will be used to invoke PolygonScan with the verified code.

etherscan: { apiKey: [ETHERSCAN_API_KEY] }

Now, you’re ready to verify your NFT contract with hardhat. Go to the terminal prompt, and type the following where the last argument is the address of your smart contract that was deployed to Mumbai.

npx hardhat verify --network matic 0xD931d7bAA004A1DA25bc6E877E6f669cB8559219
The output should read
Nothing to compile Compiling 1 file with 0.8.0 -->
contracts/AllCodeNFT.sol Successfully submitted source code for contract contracts/AllCodeNFT.sol:AllCodeNFT
 at 0xD931d7bAA004A1DA25bc6E877E6f669cB8559219
 for verification on Etherscan.
 Waiting for verification result...
 Successfully verified contract AllCodeNFT on Etherscan.

Now, navigate to contract address on PolygonScan. For me, the URL is below https://mumbai.polygonscan.com/address/0xD931d7bAA004A1DA25bc6E877E6f669cB8559219#readContract to

On PolygonScan, you should be able to not only read the source code for the contract, but you’ll also be able to invoke functions on the deployed smart contract. The Read Contract will enable your users to query the contract for certain values, e.g. tokenSupply or tokenId. The Write Contract tab will enable your users to invoke functions that write to the blockchain.

allcode_admin
allcode_admin

Related Articles

What is Tigera?

What is Tigera?

An AWS Advanced Technology Partner, Tigera delivers Calico and Calico Enterprise for security and networking on EKS, both of which are AWS Containers Competency certified.

Vezt

Vezt

Blockchain technology has the potential to be a windfall for musicians, filmmakers, and video game developers. With the advent of new technology, the way we consume entertainment is changing. Vezt assists artists in distributing their tracks on digital channels and in promoting their work.

Top Platforms for NFTs: Polygon and Flow

Top Platforms for NFTs: Polygon and Flow

As blockchain technology continues to develop, we are seeing an increase in the number of platforms, languages, and applications. Your works of art and collectables can now be presented and traded in the form of non-fungible tokens (NFTs), which are a relatively new development.

Free AWS Services List

Download this FREE list of all 200+ AWS services and ensure that you're using the optimal services for your use case to enhance efficiency and save money!

Free AWS Business Continuity Plan Template

Make sure you have the proper business continuity plan explicitly for your AWS infrastructure. Our team of experts built this template using AWS Best Practices so you can ensure it's built to scale! 

Free Cloud Migration Checklist

Without the proper cloud migration strategy, you risk losing time and money. Ensure that your migration process is running smoothly with our FREE cloud migration checklist.

Free AWS Services List

You might be optimizing with the wrong AWS services. Download this FREE list of all 200+ AWS services and ensure that you're using the optimal services for your use case to enhance efficiency and save money!

Download your FREE AWS Business Continuity Plan Template
Download Free 200+ AWS Services Checklist
Download our 10-Step Cloud Migration ChecklistYou'll get direct access to our full-length guide on Google Docs. From here, you will be able to make a copy, download the content, and share it with your team.