npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@okxweb3/hardhat-explorer-verify

v1.6.5

Published

Hardhat plugin for verifying contracts on OKExChain

Downloads

176

Readme

@okxweb3/hardhat-explorer-verify

English Chinese

Background

The @okxweb3/hardhat-explorer-verify plugin is designed for the Hardhat framework to verify smart contracts deployed on the EVM chains including X Layer. This plugin focuses on verifying that the deployed contract code matches the original source code, thus enhancing the transparency and trustworthiness of smart contracts. Users can utilize this plugin to verify their contracts on the OKX Chain blockchain explorer without the need for manual submissions.

Features

  • Automated Verification: Simplifies the verification process by automatically extracting contract information from the Hardhat project and submitting it to the OKX Chain explorer.
  • Security: Ensures that the deployed contracts are identical to the source code, enhancing contract security.
  • Ease of Use: The integration is straightforward, requiring minimal configuration to get started.

Installation

To install this plugin in your Hardhat project, use the following command:

npm install @okxweb3/hardhat-explorer-verify

Usage

  1. Install the Plugin: As described in the installation section, first install the @okxweb3/hardhat-explorer-verify plugin in your project.

  2. Configure Hardhat: In your Hardhat configuration file (usually hardhat.config.js or hardhat.config.ts), import and configure the plugin. Ensure your network configuration and API keys are correctly set.

    Here is a sample configuration:

    import { HardhatUserConfig } from "hardhat/config";
    import "@nomicfoundation/hardhat-toolbox";
    import '@okxweb3/hardhat-explorer-verify';  // Import the plugin
    
    const config: HardhatUserConfig = {
      solidity: "0.8.24",
      sourcify: {
        enabled: true,
      },
      networks: {
        xlayer: {
          url: "https://xlayerrpc.example.com",
          accounts: ["<Your Wallet Private Key>"],
        },
      },
      etherscan: {
         apiKey: '...'
      },
      okxweb3explorer: {
        apiKey: "<Your API Key>",
      }
    };
    
    export default config;
  3. Verify Contracts: After deploying the contracts, use Hardhat to run the verification script. This typically involves running a specific Hardhat task that automatically fetches contract data and submits it to the OKX Chain explorer for verification.

Example command:

npx hardhat okverify --network xlayer <Your Contract Address>
  1. View Verification Results: Once verification is successful, you can view the verification status and the contract code on the OKX Chain blockchain explorer.

deploy

  1. Verify TransparentUpgradeableProxy Contract

Example command:

npx hardhat okverify --network xlayer --contract <Contract>:<Name> --proxy <address>
  • --proxy: mention it's a proxy contract address.
  1. Veirify Multiple Contracts Simultaneously

To simutaneously verify multiple contracts, you will need to creata a verification script where you include the deployed contract address and their constructor parameters. See the example below for reference:

// scripts/batchVerify.js
async function main() {
  const contractsToVerify = [
    {
      name: "ContractA",
      address: "0x1234567890abcdef1234567890abcdef12345678", // replace to real address
      args: [42], // replace to real constructor
    },
    {
      name: "ContractB",
      address: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
      args: ["Hello, Hardhat!"],
    },
    {
      name: "ContractC",
      address: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
      args: ["0xAbcdefabcdefabcdefabcdefabcdefabcdefAbc"],
    },
    // More
    ...
  ];

  for (const contract of contractsToVerify) {
    try {
      await hre.run("verify:verify", {
        address: contract.address,
        constructorArguments: contract.args,
      });
      console.log(`${contract.name} verified at ${contract.address}`);
    } catch (error) {
      console.error(`Failed to verify ${contract.name} at ${contract.address}:`, error);
    }
  }
}
main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Then run the verification script:

npx hardhat run --network <network-name> scripts/batchVerify.js

Note:

  • If using 897 Contract, don't add --proxy. Directly use npx hardhat okverify --network xlayer --contract <Contract>:<Name>

This document is designed to help developers effectively use the @okxweb3/hardhat-explorer-verify plugin. If you have questions or need further assistance, feel free to submit issues to the project's GitHub repository.