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.


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.


Related Articles

AWS Graviton and Arm-architecture Processors

AWS Graviton and Arm-architecture Processors

AWS launched its new batch of Arm-based processors in 2018 with AWS Graviton. It is a series of server processors designed for Amazon EC2 virtual machines. The EC2 AI instances support web servers, caching fleets, distributed data centers, and containerized microservices. Arm architecture is gradually being rolled out to handle enterprise-grade utilities at scale. Graviton instances are popular for handling intense workloads in the cloud.

What is Tiered Pricing for Software as a Service?

What is Tiered Pricing for Software as a Service?

Tiered Pricing is a method used by many companies with subscription models. SaaS companies typically offer tiered pricing plans with different services and benefits at each price point with typically increasing benefits the more a customer pays. Striking a balance between what good rates are and the price can be difficult at times.

The Most Popular Cloud Cost Optimization Tools

The Most Popular Cloud Cost Optimization Tools

Cloud environments and their pricing models can be difficult to control. Cloud computing does not offer the best visibility and it is easy to lose track of which price control factors are having an impact on your budget. Having the right tools can help put value to parts of an environment and provide guides on how to better bring budgetary issues back under control.