Cascadia
  • Welcome to Cascadia
    • Brand Guidelines
    • Official Links
  • Artificial Intelligence
    • Incentives
  • Developers
    • Addresses
    • CosmWasm
      • Smart Contracts
      • Install Requirements
      • Set your Environment
      • Optimization
      • Deployment
      • Multi-Chain Contracts
        • The Actor Model
      • CW1 Subkeys Contract
        • Guide
      • CW20 Base Contract
        • Guide
      • C721 Base Contract
        • Guide
      • Upload Contract
        • Create a WASM File
      • Sign and Verify
        • Guide
    • Solidity
      • Deployment
      • Verification
        • Block Explorer
        • Hardhat
  • Directory
    • Address
    • API
    • Applications
    • Explorer
    • Faucet
    • Genesis
    • Governance
    • GRPC
    • Guide
    • Peers
    • RPC
    • Snapshot
    • State Sync
    • Website
    • Websocket
  • Governance
    • Align
      • Cooldown Period
      • Functions
    • Off-Chain
    • On-Chain
      • Voting
    • Proposals
      • On-Chain Voting via CLI
      • Proposal (Example)
    • VeTokenomics
      • Model
      • Voting Power Calculation
    • Analytics
  • Network
    • ChainID & Address Prefix
    • Configuration
    • Consensus
    • Denomination
    • Distribution
      • Block Rewards
      • Gas Fees
    • ESG
    • Faucet
    • Modules
    • Parameters
    • Peers
  • Security
    • Disclosure Policy
    • Multisignature
  • Staking
    • Claim
    • Delegate
    • Manual
    • Redelegate
    • Undelegate
  • Use Cases
    • Business Development and Marketing
    • Consumer Relationship Management
  • Node
    • Cloud Platforms
      • Amazon Web Services
      • Google Cloud Platform
    • Snapshot
    • State-Sync
    • Upgrade
      • Automated
      • Manual
  • Validators
    • System Requirements
    • Installation
    • Reference
      • Customization
  • Community
    • Discord
    • Telegram
    • Twitter
  • Legal
    • Privacy Policy
    • Terms & Conditions
Powered by GitBook
On this page
Edit on GitHub
  1. Developers
  2. Solidity
  3. Verification

Hardhat

PreviousBlock ExplorerNextDirectory

Last updated 1 year ago

These are the steps for verifying smart contracts via . Hardhat is a comprehensive development environment that facilitates contract compilation, deployment, and authentication.

Step 1: Install Hardhat.

If creating a new npm project from scratch, navigate to an empty directory and execute the command npm init. Follow the instructions provided, and it is recommended to use npm 7 or a later version. Once the project is ready, use either the npm or yarn command below.

npm instructions:

npm install --save-dev hardhat

yarn instructions:

yarn add --dev hardhat

Step 2: Install the (requires v3.0.0+). Use either the npm or yarn commands:

npm instructions:

npm install --save-dev @nomiclabs/hardhat-etherscan

yarn instructions:

yarn add --dev @nomiclabs/hardhat-etherscan

Step 3: For hardhat.config.js, add the following statement:

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

For TypeScript, add the following line to hardhat.config.ts:

import "@nomiclabs/hardhat-etherscan";

Step 4: Add Cascadia to hardhat.config.js.

etherscan: {
  apiKey: {
    cascadia: "abc"
  },
  customChains: [
    {
      network: "cascadia",
      chainId: 6102,
      urls: {
        apiURL: "https://explorer.cascadia.foundation/api",
        browserURL: "https://explorer.cascadia.foundation",
      }
    }
  ]
}

apiKey: Refers to the unique API key associated with the block explorer account.

network: Specifies the name of the network, which must match the name of the apiKey.

browserURL: Indicates the URL for accessing the block explorer interface.

chainID: Identifies the unique identifier for the network chain being accessed.

apiURL: Specifies the URL used for accessing the block explorer's API service.

The entire code should appear as follows:

require("@nomicfoundation/hardhat-toolbox");
require("@nomiclabs/hardhat-etherscan");
require('dotenv').config()
const private_key = process.env.PRIVATE_KEY
module.exports = {
  solidity: "0.8.17",
  networks: {
    cascadia: {
      url: "https://testnet.cascadia.foundation",
      accounts: [private_key]
    }
  },
  etherscan: {
    apiKey: {
      cascadia: "abc"
    },
    customChains: [
      {
        network: "cascadia",
        chainId: 6102,
        urls: {
          apiURL: "https://explorer.cascadia.foundation/api",
          browserURL: "https://explorer.cascadia.foundation",
        }
      }
    ]
  }
};

Step 5: Check if Cascadia is successfully supported:

npx hardhat verify --list-networks

Step 6: To verify the contract, constructor arguments can be included with the verify task.

npx hardhat verify --network <network_name> DEPLOYED_CONTRACT_ADDRESS “Constructor argument 1”

For example:

npx hardhat verify –network Cascadia 0x856C336cD8eBDCE7B5Bb3F2DEB1bf3160B176880 31536000

Step 7: Contract verification can be confirmed via the console:

Hardhat
Hardhat plugin