Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
API Endpoints
Contract Verification

Verify with Hardhat

Make sure you’ve updated to@nomicfoundation/hardhat-verify@^2.0.14, see migrating notes if you have an existing project.
Hardhat is a smart contracts development tool, perfect if you’re familiar with Javascript/Typescript.If you’ve yet to setup Hardhat, here’s theofficial guide, the following steps are to setup the verification plugin.

Install

Via npm.
npm i @nomicfoundation/hardhat-verify

Config

Inhardhat.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 acustomChain inhardhat.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 thehardhat.config.ts file — good riddance to the longcustomChains entries for each explorer.Update your config to a single EtherscanapiKey entry as per above.
This open source integration was shipped by@antico5and the Hardhat team.
⌘I

[8]ページ先頭

©2009-2025 Movatter.jp