Verify through Hardhat

Setup custom chain config

Add the following content to your hardhat.config.js file

require("@nomicfoundation/hardhat-toolbox");
// the account's private key
const PRIVATE_KEY = "<your_private_key>";

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.9",
  defaultNetwork: "<chain_name>",
  networks: {
    hardhat: {
    },
    <chain_name>: {
      url: `<rpc_endpoint>`,
      accounts: [PRIVATE_KEY],
    },
  },
  etherscan: {
    customChains: [
      {
        network: "<chain_name>",
        chainId: <chain_id>,
        urls: {
          apiURL: "<api_host>/v1/explorer/command_api/contract",
          browserURL: "<socialscan_explorer_url>",
        },
      },
    ],
    apiKey: {
      <chain_name>: "Put a random string",
    },
  }
};

Verify with Hardhat

Make sure your chain_name is consistent with your config file

# Verify with Hardhat

npx hardhat verify --network <chain_name> <contract_address>

# Expected Output
Successfully submitted source code for contract
<contract_name> at <contract_address>
for verification on the block explorer. Waiting for verification result...

Successfully verified contract Token on the block explorer.
<socialscan_explorer_url>/address/<contract_address>#code

Last updated