Asset Chain Academy
  • Join the Asset Chain Academy
  • MODULE 1: GETTING STARTED
    • Introduction to Asset Chain
    • Environment Setup & Installation
    • Contributing
    • Asset Chain Starter Kits
  • MODULE 2: DEVELOPER RESOURCES
    • Resources Explained
    • Cyfrin Updraft
    • Learnweb3
    • Chainlink Bootcamps
    • Alchemy University
    • Smart Contract Programmer
  • MODULE 3: BEGINNER TUTORIALS
    • Create a Token
    • Write & Deploy an NFT
    • Mint an NFT
    • Asset Chain Explorers
    • Payments
    • Building with Thirdweb
    • Mobile Apps on Asset Chain
    • ⁠ Connecting to wallet
      • Wallet Connect
  • MODULE 4: INTERMEDIATE TUTORIALS
    • Smart Contract Verification
    • MultiSig Wallet
    • Setup a node
    • Staking
    • Setting up an Indexer
    • Asset Chain Telegram Mini App Demo
  • MODULE 5: ADVANCED TUTORIALS
    • EVM-Gas-Optimizations
    • Smart Contract Audit
    • Decentralized Exchanges
    • Arbitrage Bots
    • References
Powered by GitBook
On this page
  • With Advanced Explorer
  • WIth Hardhat
  1. MODULE 4: INTERMEDIATE TUTORIALS

Smart Contract Verification

Lets verify our contracts on Asset Chain.

PreviousWallet ConnectNextMultiSig Wallet

Last updated 11 months ago

Pro tip: If you deployed your contract with Hardhat, use the Hardhat guide to verify it.

With Advanced Explorer

Get Started

  1. Visit the

  1. On the Sidebar, hover on the `Other` link and click on `verify contract` link.

  1. Clicking verify contract` should open up a form similar to the one below. Proceed to enter the parameters with which you compiled your contract.

  1. If you submitted the form successfully, your contract has been verified. Visiting the contract page, you should see a page similar to the one below; with an alert showing verified, and your contract code being displayed.

Congratulations on verifying your contract with our Explorer.

WIth Hardhat

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
  1. Create a project

  1. Install plugin

npm

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

yarn

yarn add --dev @nomiclabs/hardhat-etherscan
  1. 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

Asset Chain is not directly supported by the plugin (to check run npx hardhat verify --list-networks)

But we can add it in a customChains object, to the config file. It includes:

  • chainID - 42421

  • apiURL - "https://scan-testnet.assetchain.org/api"

  • browserURL - "https://scan-testnet.assetchain.org/"

The network name in customChains must match the network name in the apiKey object.

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

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

module.exports = {
  solidity: "0.8.9",
  networks: {
    localhost: {
      url: "http://127.0.0.1:8545/",
      accounts: [secret.key],
    }
  },
  etherscan: {
    apiKey: {
      assetchain_test: "abc"
    },
    customChains: [
      {
        network: "assetchain_test",
        chainId: 42421,
        urls: {
          apiURL: "https://scan-testnet.assetchain.org/api",
          browserURL: "https://scan-testnet.assetchain.org/"
        }
      }
    ]
  }
};

Deploy and Verify

Deploy

D:\hard_hat> npx hardhat run scripts\deploy.js --network assetchain_test
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"

Example (no constructors).

D:\hard_hat>npx hardhat verify --network assetchain_test 0x263E6d3E8b98fB0393A108825E2DcE3063F66713  --constructor-args ./scripts/arguments.js 
[INFO] Sourcify Verification Skipped: Sourcify verification is currently disabled. To enable it, add the following entry to your Hardhat configuration:

sourcify: {
  enabled: true
}

Or set 'enabled' to false to hide this message.

For more information, visit https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#verifying-on-sourcify
Successfully submitted source code for contract
contracts/MultiSigWallet.sol:MultiSigWallet at 0x263E6d3E8b98fB0393A108825E2DcE3063F66713
for verification on the block explorer. Waiting for verification result...

Successfully verified contract MultiSigWallet on the block explorer.
https://scan-testnet.assetchain.org/address/0x263E6d3E8b98fB0393A108825E2DcE3063F66713#code

Confirm Verification on BlockScout

Go to our BlockScout Explorer and paste the contract address into the search bar.

Scroll down to see verified status. A green checkmark ✅ means the contract is verified.

You can now scroll down in the explorer to see and interact with the contract code.

Congratulations! Your contract is successfully verified on Asset Chain Explorer.

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

Run npx hardhat in your project folder and follow the instructions to create ().

Install the (requires v3.0.0+).

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 Asset Chain test network and a .js file.

For info on more complex constructor arguments(arrays, tuples..) please .

Hardhat
Hardhat Etherscan plugin
more info here
hardhat-etherscan plugin
More info on using typescript with hardhat available here
Hardhat config file
visit here
Asset Chain Advanced Explorer
click on the verify contract