How do i use hardhat-verify excludes etherscan or sourcify

32 views Asked by At

I would like to create a functionality to verify code on the Klaytn chain (similar to Ethereum side chain).

I am attempting to verify code using Hardhat without relying on an explorer like Etherscan. Is there a way to verify the code using only RPC and contract information, without going through an explorer? The process of uploading to an explorer, similar to Etherscan, is unnecessary for my use case.

Additionally, is there a way to include contractSource when verifying? Currently, in my code, specifying the contract path in the contract field or providing contractSource doesn't seem to work.

import "@nomicfoundation/hardhat-verify";
import * as hardhat from "hardhat";
...

public static async run(contractInfo: ContractInfo) {
    let hre: HardhatRuntimeEnvironment = hardhat;

    const contractAddress = CommonUtils.buffer2HexAddress(contractInfo.contractAddress); 
    const constructorArgs = [];

    const contractSource = contractInfo.contractSource;

    const taskArgs = {
      network: process.env.HARDHAT_NETWORK, // klaytn
      address: contractAddress,
      // constructorArguments: constructorArgs,
      // contract: contractSource,
      contract: "contracts/MultiBalanceChecker.sol:MultiBalanceChecker",
      // libraries: {},
    };

    try {
      const result = await hre.run("verify:verify", taskArgs);

      if (result) {
        console.log("Verification successful!");
      } else {
        console.error("Verification failed.");
      }
    } catch (err) {
      console.error("ERROR", err);
    }
  }
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-verify";
import { HardhatUserConfig } from "hardhat/config";

/** @type import('hardhat/config').HardhatUserConfig */
const config: HardhatUserConfig = {
  solidity: "0.8.24",
  sourcify: {
    enabled: false,
  },
  networks: {
    klaytn: {
      url: "https://public-en-cypress.klaytn.net",
      chainId: 8217,
    },
  },
  etherscan: {
    apiKey: {
      klaytn: process.env.API_KEY,
    },
    customChains: [
      {
        network: "klaytn",
        chainId: 8217,
        urls: {
          apiURL: "https://api.etherscan.io/api",
          browserURL: "https://klaytnscope.com",
        },
      },
    ],
  },
};

export default config;

error message

{
  parent: undefined,
  name: "ContractNotFoundError",
  _stack: "ContractNotFoundError: The contract contracts/MultiBalanceChecker.sol:MultiBalanceChecker is not present in your project.\n    at SimpleTaskDefinition.action (/Users/me/Project/hardhat-verify-project/node_modules/@nomicfoundation/hardhat-verify/src/index.ts:209:17)\n    at async Environment._runTaskDefinition (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)\n    at async Environment.run (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)\n    at async SimpleTaskDefinition.action (/Users/me/Project/hardhat-verify-project/node_modules/@nomicfoundation/hardhat-verify/src/internal/tasks/etherscan.ts:129:62)\n    at async Environment._runTaskDefinition (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)\n    at async Environment.run (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)\n    at async SimpleTaskDefinition.action (/Users/me/Project/hardhat-verify-project/node_modules/@nomicfoundation/hardhat-verify/src/index.ts:284:9)\n    at async Environment._runTaskDefinition (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)\n    at async Environment.run (/Users/me/Project/hardhat-verify-project/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)\n    at async 

...

I read hardhat docs and referred to them. (https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#using-programmatically)

0

There are 0 answers