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. Once your project is ready: 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).
  3. Install plugin Install the hardhat-etherscan plugin (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.
    import "@nomiclabs/hardhat-etherscan";
    

Config File

Your basic Hardhat config file (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. If you prefer, you can migrate to 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: 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

Verify Contract 04 Pn Verify Contract 05 Pn