I just deployed a contract on mumbai and I am unable to verify it on polygonscan. Do you know if hardhat verify works for polygonscan?

Created by Sourajyoti Gupta, Modified on Fri, 28 Jul 2023 at 07:35 PM by Sourajyoti Gupta

To answer your question, Yes hardhat verify works for etherscan like a charm. All you need to do is set up your network and your etherscan API key under hardhat.config.ts folder for example:


const config: HardhatUserConfig = {

     solidity: {

          version: "your_solidity_version",

     },

     networks: {

          ethereum: {

               url: process.env.ETHEREUM_RPC_URL,

               gasPrice: "auto",

               account: process.env.YOUR_PRIVATE_KEY

          },

          mumbai: {

               url: process.env.MUMBAI_RPC_URL,

               gasPrice: "auto",

               account: process.env.YOUR_PRIVATE_KEY

          }         

     },

     etherscan: {

          apiKey: process.env.EXPLORER_API_KEY

     }

}


once your setup is done all you need to do is run the command

 

> npx hardhat verify --network <network-name-in-hardhat-config> DEPLOYED_CONTRACT_ADDRESS "Constructor arguments"


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article