Gauss Docs
  • 🌐Getting Started
    • Welcome to Gauss
    • Whitepaper
      • Blockchain Providers Need to Do Better
        • Solving a Lack of Token Adoption
          • An Evolving Space With Untapped Potential
        • Security & Reliability
          • Curation & Vetting
            • Important Note For Brands
        • Token Creation
      • WHY BUILD WITH GAUSS?
      • Use Cases
        • Use Cases (Chart)
      • Roadmap
      • Technical Background and Blockchain Development
        • Why Another Blockchain?
        • Gauss 1.0: Built With Efficiency and a Strong Infrastructure to Launch Rapidly
        • Gauss 2.0: Added Functionality For a Better User Experiance
          • Noble Swap 2.0
          • NFTs in Gauss 2.0
          • Token Development Kit (TDK)
          • Gaming DAO
          • Omnipool
      • Token Economics
        • Gang Token Economics: Designed to Ensure Trust and Transparency
        • Token Locking Schedule
        • Reflections: Rewarding the Gauss Community
        • Charitable Allocations: Grants, Scholarships, & Financial Assistance
      • The Gauss Team
      • Important Definitions
      • DISCLAIMER
        • PURCHASER WARNING
        • PROMINENT STATEMENTS
        • FUTURE STATEMENTS
        • VALUE RISKS
        • NOT A SECURITY
    • How To Connect
      • Create Metamask Wallet
    • Links
  • ⚡Launching with Gauss
    • Benefits of Building with Gauss
      • Fostering an Environment for Success
      • Gauss Growth Grant Program
      • Gauss Liquidity Program
      • Ecosystem Integrity Fund
      • Client Referral Program
    • A Guide to Curation
      • Core Principles and Curation Guidelines
      • Curation Stages and Processing Fees
    • Building on Gauss
  • 🖥️Gauss Ecosystem
    • Gauss Chain
      • Polygon-Edge Overview
      • Architecture
      • Consensus
      • Client Modules
        • Blockchain
        • Minimal
        • Networking
        • State
        • TxPool
        • JSON RPC
        • Consensus
        • Storage
        • Types
        • Syncer
        • Sealer
        • Other Modules
      • Polygon-Edge Performance Reports
      • For Developers
        • Operate a Node
          • Local Install
          • Genesis Contract
          • Server Config
          • CLI Commands
          • Key Management
        • Run a Validator
          • Validator FAQ
        • Smart Contract Deployment Permissioning
        • Deploying Contracts
          • Remix
          • Truffle
          • Hardhat
          • Replit
    • Gauss Explorer
      • Features
      • Navigating the Explorer
        • Menus
        • Blocks
        • Transactions
      • Verifying a Smart Contract
        • Hardhat Plugin
        • Sourcify Plugin
        • OpenZeppelin Plugin
      • Interacting With Smart Contracts
      • Exporting Transactions
      • FAQ
      • For Developers
        • Gauss Explorer Dependencies
        • Deployment Guide
          • Smart Contract Verification
          • Cleaning an instance from the previous deployment
          • ENV Variables
          • Testing
        • APIs
          • Requests & Limits
          • GraphQL
          • ETH RPC
    • Noble Swap
      • Liquidity Boost Program
    • Tokens
    • Gauss NFTs
      • Ferro Cards
      • F.E.R.R.E.T. NFTs
    • Contests & Giveaways
    • Gauss Faucet
      • For Developers
    • Address List
  • 💡Additional Resources
    • Partnerships & Affiliates
    • Discord Channel
    • Contact Us
    • Learning Materials
      • Web3 Glossary
    • Media Kit
Powered by GitBook
On this page
  • Hardhat Verification Plugin
  • Get Started
  • Config File
  • Deploy and Verify
  • Confirm Verification on Gauss Explorer
  • Resources
  1. Gauss Ecosystem
  2. Gauss Explorer
  3. Verifying a Smart Contract

Hardhat Plugin

PreviousVerifying a Smart ContractNextSourcify Plugin

Last updated 2 years ago

Hardhat Verification Plugin

​is a full-featured development environment for contract compilation, deployment and verification. The supports contract verification on Gauss Explorer.

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 ().

3) Install plugin

Install the (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.

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

Config File

require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require('hardhat-deploy');

let secret = require("./secret");

module.exports = {
  solidity: "0.8.9",
  networks: {
    g.i.l.: {
      url: 'https://rpc.giltestnet.com/',
      accounts: [secret.key],
    }
  },
  etherscan: {
    // Your API key for Etherscan
    // Obtain one at https://etherscan.io/
    apiKey: "abc"
  }
};

Add an Unsupported Network

Some chains are not supported by the plugin (to check run npx hardhat verify --list-networks)If your chain is not in the list, you can add a customChains object to the config file. It includes:

  • chainID - Network chain ID

  • apiURL - Block explorer API URL

  • browserURL - Block explorer URL

For example, if G.I.L. were not in the default list, this is how it would be added to the config file. Note the network name in customChains must match the network name in the apiKey object.

etherscan: {
  apiKey: {
    g.i.l.: "abc"
  },
  customChains: [
    {
      network: "g.i.l/",
      chainId: 4242,
      urls: {
        apiURL: "https://explorer.giltestnet.com/api",
        browserURL: "https://explorer.giltestnet.com"
      }
    }
  ]
}

Deploy and Verify

Deploy

D:\hard_hat>npx hardhat run scripts\deploy.js --network G.I.L.
Contract deployed to: 0x8595e22825Ba499dB8C77C5c830c235D80f9C0fa

Verify

You can include constructor arguments with the verify task.

npx hardhat verify --network <network> DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"

G.I.L. example (no constructors).

D:\hard_hat>npx hardhat verify --network G.I.L. 0x8595e22825Ba499dB8C77C5c830c235D80f9C0fa 
Nothing to compile
Compiling 1 file with 0.8.0
Successfully submitted source code for contract
contracts/test.sol:Foo at 0x8595e22825Ba499dB8C77C5c830c235D80f9C0fa
for verification on Etherscan. Waiting for verification result...

Successfully verified contract Foo on Etherscan.
https://explorer.giltestnet.com/address/0x8595e22825Ba499dB8C77C5c830c235D80f9C0fa #code

Note the verify task will not be listed in the available tasks lists at npx hardhat --config but should work as expected.

If not, check you have the minimum required version of the nomiclabs-hardhat-etherscan plugin (v3.0.0+) installed

Confirm Verification on Gauss Explorer

Go to your Gauss Explorer instance and paste the contract address into the search bar. If verified, the code tab will display a green checkmark.

Selecting the Code tab will provide additional information about your contract.

Resources

If using TypeScript, add this to your hardhat.config.ts. .

Your basic (hardhat.config.js or hardhat.config.ts) will be setup to support the network you are working on. In this example we use the G.I.L. 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. .

If you prefer, you can migrate to to use a plugin bundle.

Find an extensive list of ChainIDs at

Learn more about plugin configs, troubleshooting etc. at

🖥️
Hardhat
Hardhat Etherscan plugin
more info here
hardhat-etherscan plugin
More info on using typescript with hardhat available here
Hardhat config file
More info
hardhat-toolbox
https://chainlist.org/
https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html