Verifying smart contracts plays an important role in providing security and certainty to the users of your decentralized applications. By offering full visibility of the source code of your smart contract, you provide confidence and transparency of the intention of the code that is being executed.The way smart contracts are verified is by simply uploading the source code and contract address to services such as Etherscan.Once the contract is verified, the Etherscan explorer shows a status like the following image:Luckily, Hardhat and Hardhat-deploy already contain a built-in capability to do this task easily on your behalf.This process involves the following steps:
In order to obtain an Etherscan API key, visit Etherscan and create an account.Then, go to https://etherscan.io/myapikey and create an API key by clicking the Add button:Bear in mind that different networks have other Blockchain explorers. For example:
You’ll need to go to that particular explorer and get the API Key following a similar process as mentioned previously (except for Sepolia Etherscan, where you can use the Etherscan mainnet one instead).
In this lesson, you’ve learned how to verify smart contracts using Hardhat and Hardhat-deploy. You learned how to configure Hardhat to support multiple networks and verify by using a simple command.