Hardhat

These are the steps for verifying smart contracts via Hardhat. Hardhat is a comprehensive development environment that facilitates contract compilation, deployment, and authentication.

Step 1: Install Hardhat.

If creating a new npm project from scratch, navigate to an empty directory and execute the command npm init. Follow the instructions provided, and it is recommended to use npm 7 or a later version. Once the project is ready, use either the npm or yarn command below.

npm instructions:

npm install --save-dev hardhat

yarn instructions:

yarn add --dev hardhat

Step 2: Install the Hardhat plugin (requires v3.0.0+). Use either the npm or yarn commands:

npm instructions:

npm install --save-dev @nomiclabs/hardhat-etherscan

yarn instructions:

yarn add --dev @nomiclabs/hardhat-etherscan

Step 3: For hardhat.config.js, add the following statement:

require("@nomiclabs/hardhat-etherscan");

For TypeScript, add the following line to hardhat.config.ts:

Step 4: Add Cascadia to hardhat.config.js.

apiKey: Refers to the unique API key associated with the block explorer account.

network: Specifies the name of the network, which must match the name of the apiKey.

browserURL: Indicates the URL for accessing the block explorer interface.

chainID: Identifies the unique identifier for the network chain being accessed.

apiURL: Specifies the URL used for accessing the block explorer's API service.

The entire code should appear as follows:

Step 5: Check if Cascadia is successfully supported:

Step 6: To verify the contract, constructor arguments can be included with the verify task.

For example:

Step 7: Contract verification can be confirmed via the console:

Last updated