> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seitrace.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Hardhat verification plugin

> Hardhat is a full-featured development environment for contract compilation, deployment and verification. The Hardhat Verification Plugin supports contract verification on Seitrace.

## **Get started**

1. **Install Hardhat**

   If you are starting from scratch, create an npm project by going to an empty folder, running `npm init`, and following the instructions. Recommend npm 7 or higher.

   **<u>Once your project is ready:</u>**

   **npm instructions**

   ```
   npm install --save-dev hardhat
   ```

   **yarn instructions**

   ```
   yarn add --dev hardhat
   ```
2. **Create a project**

   Run `npx hardhat` in your project folder and follow the instructions to create ([more info here](https://hardhat.org/getting-started/#quick-start)).
3. **Install plugin**

   Install the [hardhat-etherscan plugin](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) (requires **v3.0.0+).**

   **npm**

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

   **yarn**

   ```
   yarn add --dev @nomiclabs/hardhat-etherscan
   ```
4. **Add plugin reference to config file**

   Add the following statement to your `hardhat.config.js`.

   Copy

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

   If using TypeScript, add this to your `hardhat.config.ts.` [More info on using typescript with hardhat available here](https://hardhat.org/guides/typescript.html#typescript-support).

   ```
   import "@nomiclabs/hardhat-etherscan";
   ```

## **Config File**

Your basic [Hardhat config file](https://hardhat.org/config/) (`hardhat.config.js` or `hardhat.config.ts`) will be setup to support the network you are working on. In this example we use the Sokol test network and a `.js` file.

Here we add an RPC url without an API key, however some value is still required. You can use any arbitrary string. [More info](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html#multiple-api-keys-and-alternative-block-explorers).

If you prefer, you can migrate to [hardhat-toolbox](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox) to use a plugin bundle.

```
import dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "tsconfig-paths/register";
import "@openzeppelin/hardhat-upgrades";

/**
 * Config dotenv first
 */
dotenv.config();

/**
 * Default hardhat configs
 */
const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.8.20",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200,
          },
        },
      },
    ],
  },
};

/**
 * Extract env vars
 */
const privateKey = process.env.PRIVATE_KEY || "";

/**
 * If private key is available, attach network configs
 */
if (privateKey) {
  config.networks = {
    sei_arctic_1: {
      url: "https://evm-rpc.arctic-1.seinetwork.io/",
      chainId: 713715,
      accounts: [privateKey],
      gas: "auto",
      gasPrice: "auto",
    },
  };
}

/**
 * Load etherscan key
 */
const seitraceKey = process.env.SEITRACE_KEY || "";

if (seitraceKey) {
  config.etherscan = {
    apiKey: {
      sei_arctic_1: seitraceKey,
    },
    customChains: [
      {
        network: "sei_arctic_1",
        chainId: 713715,
        urls: {
          apiURL: "https://seitrace.com/arctic-1/api",
          browserURL: "https://seitrace.com"
        }
      },
    ],
  };
}

export default config;
```

apiURL:

* arctic-1: [https://seitrace.com/arctic-1/api](https://seitrace.com/arctic-1/api)
* pacific-1: [https://seitrace.com/pacific-1/api](https://seitrace.com/pacific-1/api)
* atlantic-2: [https://seitrace.com/atlantic-2/api](https://seitrace.com/atlantic-2/api)

Set up env. file

```
PRIVATE_KEY="4c1a9ffd2dce9ed5b5f464c6b6a38efceb051855d123c9e6aeec751c35762d91"
SEITRACE_KEY="can-be-any-string"
```

* PRIVATE\_KEY: Wallet private key
* SEITRACE\_KEY: You can also use a random string

## **Deploy and Verify**

**Deploy**

```
npx hardhat run .\scripts\<path>\deploy.multicall.ts --network sei_arctic_1
```

**Verify**

```
npx hardhat verify --network sei_arctic_1 <contract_address> "Constructor argument"
```

**Example**

```
PS D:\verify-contract> npx hardhat verify --network sei_arctic_1 0xaa338AbfB92e7476596D4cCb98b29700BDcA2a6E "0xc99259dE8f9ec4cd443C0CF5D45D547c513E03be"
Successfully submitted source code for contract
contracts/VuNFT721.sol:VuSEI721 at 0xaa338AbfB92e7476596D4cCb98b29700BDcA2a6E
for verification on the block explorer. Waiting for verification result...

Successfully verified contract VuSEI721 on the block explorer.
https://seitrace.com/address/0xaa338AbfB92e7476596D4cCb98b29700BDcA2a6E#code
```

## **Confirm Verification on Seitrace**

<img src="https://mintcdn.com/cavies/tyGf0hOCLo1nrz0w/images/verify-contract-04.png?fit=max&auto=format&n=tyGf0hOCLo1nrz0w&q=85&s=5296970f2ed644efeb8e66d1601110b4" alt="Verify Contract 04 Pn" width="1404" height="1284" data-path="images/verify-contract-04.png" />

<img src="https://mintcdn.com/cavies/tyGf0hOCLo1nrz0w/images/verify-contract-05.png?fit=max&auto=format&n=tyGf0hOCLo1nrz0w&q=85&s=db85d0048c6ba44bbeef9c455cc0faa2" alt="Verify Contract 05 Pn" width="1404" height="1284" data-path="images/verify-contract-05.png" />
