Verify with Hardhat
Hardhat is a smart contracts development tool, perfect if you're familiar with Javascript/Typescript.
If you've yet to setup Hardhat, here's the official guide, the following steps are to setup the verification plugin.
Install
Via npm
npm i @nomicfoundation/hardhat-verify
Config
In hardhat.config.ts
, import the plugin
import "@nomicfoundation/hardhat-verify";
Add your Etherscan key
config: HardhatUserConfig = {
solidity: "0.8.28",
networks: {
sepolia: {
url: `https://1rpc.io/sepolia`,
accounts: [SEPOLIA_PRIVATE_KEY],
},
},
etherscan: {
apiKey: "YourEtherscanApiKey"
}
};
Deploy and Verify
npx hardhat ignition deploy ./ignition/modules/Lock.ts --network sepolia --verify
Verify an Existing Contract
npx hardhat verify --network sepolia 0xdCBdBAA8404554502B433106e62728B659aCfE3b
Custom Chains
For super new Etherscan based explorers that are not supported by Hardhat yet, you can add them as a customChain
in hardhat.config.ts
✨
etherscan: {
apiKey: "YourEtherscanApiKey",
customChains: [
{
network: "sonic",
chainId: 146,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://sonicscan.org"
}
},
{
network: "katana",
chainId: 146,
urls: {
apiURL: "https://api.etherscan.io/v2/api",
browserURL: "https://sonicscan.org"
}
}
]
}
Migrating from V1
API keys from any other explorer (such as BscScan/Basescan/Arbiscan) have been deprecated ⚠️
This change largely affects the hardhat.config.ts
file — good riddance to the long customChains
entries for each explorer.
Update your config to a single Etherscan apiKey
entry as per above.
This open source integration was shipped by @antico5 and the Hardhat team 🙌
Last updated