LogoLogo
WalletsEcosystemStart BuildingJoin the Community
  • Welcome to IoTeX 2.0
    • đź’ˇWhy IoTeX
    • 🪙Tokenomics
      • IOTX Utility in IoTeX 2.0
      • IOTX Emission, Deflation, and Re-Staking
    • đź“–Whitepaper
    • ⚡Get Started
  • DePIN Infra Modules (DIM)
    • DIMs Overview
    • [IoTeX L1] DePIN Blockchain
      • Core Concepts
        • Consensus Mechanism
        • Voters and Delegates
        • Ethereum Virtual Machine
        • Accounts & Identities
        • Blockchain Actions
        • ERC20 and NFT Tokens
        • Smart Contracts
        • Interoperability
        • Governance
      • The IOTX Token
        • IOTX Token Exchange Support
        • Different Formats of the IOTX Token
        • IOTX Token Contracts
      • Wallets
        • Supported Wallet Apps
          • ioPay Mobile
          • IoTeX Web Wallet
          • OKX Wallet
          • Rabby Wallet
          • Metamask Desktop
          • Ledger Nano S & X
            • Use Ledger with Metamask
            • Use Ledger with Rabby Walet
            • Use Ledger with IoTeX Hub Portal
            • Migrate to the Ethereum Ledger App
          • IoTeX Desktop Wallet
          • 👩‍💻IoTeX HD Derivation Path
        • Buy IOTX Tokens
        • Execute Transactions
          • Transfer IOTX Tokens
          • Transfer ERC20 Tokens
          • Interact with Dapps
          • Explore transactions
        • Migrate Assets to a different wallet
      • Staking & Governance
        • About IoTeX Staking
        • IoTeX Staking Guide
          • Native staking
          • Staking as NFT
        • Join the Governance
          • Marshall DAO
          • Improvement Proposals
      • Exchange Integration
      • 👨‍💻Deploy Dapps on IoTeX
    • [ioID] DePIN Identities
      • ioID Specification
      • Overview of ioID
      • Registering Identities
      • 👩‍💻Integration Guide
        • Register a DePIN Project
        • Bind your Device NFT
        • Reserve Device ioIDs
        • Query Project Status
        • Register a Device
        • ioID Smart contracts quick reference
    • [W3bstream] DePIN Verification
      • Overview of W3bstream
      • Multi-Prover Architecture
      • 👨‍💻Build with W3bstream
        • Get Started
          • Sequencer Options
        • Build the Prover Code
          • Risc Zero
          • Halo2
          • zkWASM
        • Deploy to W3bstream
          • Create the Project File
          • W3bstream Outputs
          • Deploying Projects
          • Interacting with Projects
        • On-chain integration
          • Verify Risc0 Proofs
          • Verify Halo2 Proofs
          • Verify zkWASM profs
        • Sending Messages
      • 👩‍💻Node Operators
        • Configure a ZK Prover Node
        • Register your Node
    • [ioID-SDK] Hardware SDK
      • ioID-SDK Overview
      • Layered Architecture
      • Compatibility
      • Current Development Status
    • [MSP] Modular Security Pool
    • Third-Party DIMs
      • Data Sequencer Infras
      • Data Availability Infras
      • 👨‍💻W3bstream Tasks
  • Ecosystem
    • Assets on IoTeX
      • Mainstream Assets
      • IOTX and Derivatives
      • DePIN Tokens
      • MEME Coins
    • iotube Bridge
    • iotexscan Explorer
    • Ecosystem Apps
      • DePINScan
      • mimo DEX
      • ecosystem.iotex.io
    • "Powered by IoTeX" Devices
      • Pebble Tracker
        • Quick Start
        • Device Registration
        • Online Firmware Update
        • USB Firmware Update
        • Migrating to Pebble v2.0
          • 1.0 Device Registration
        • Tech Specs
        • Network Selection
        • Pebble Configuration
        • Query Pebble Data
        • Troubleshooting
        • Firmware Development
          • Hardware Setup
          • Build the Firmware
          • Flash the firmware
      • SenseCAP Indicator
      • UCam Home Camera
  • Builders
    • IoTeX Developer Portal
    • Dev Chat on Discord
    • Web3 Development
      • RPC Endpoints
      • Set up your Environment
      • Get Testnet IOTX Tokens
      • ioctl CLI
        • Installation
        • Create Accounts
        • Blockchain interaction
          • ioctl command reference
      • Chain Indexing
        • The Graph
        • SubQuery
        • IoTeX Analytics API
      • IoTeXscan API
      • Deterministic Deployment
      • Account Abstraction
        • Components of AA
        • 👩‍💻Creating new Accounts
        • 👨‍💻P256Account Example
      • Blob Transactions (EIP-4844)
      • Multicall3
      • EVM Precompiled Contracts
    • Building DePINs
      • ioID Step by Step Tutorial
        • Integrate ioID in the Device Firmware
        • Integrate ioID in your cloud
      • Decentralized WiFi Connectivity (DeWi)
        • Project Specification
        • The choice of Hardware
        • The Data API Service
        • DePIN Incentives Contract
    • Building DeFi
      • Deploy Tokens
        • Deploy an ERC20 Token
        • Deploy an NFT Token
      • Price Oracles
        • Chainlink Relayer
        • SupraOracles
      • Integrate IoTeX Staking
      • Liquid staking Dapps
    • Launch Dapps on IoTeX
      • Submit Tokens to the IoTeX Ecosystem
      • Submit tokens to the iotube bridge
      • Verify Smart Contracts
      • Audit your Contracts
      • Submit your Dapp to Portals
      • Useful tools
    • Node Operators
      • Fastblocks (Node as a Service)
      • Setup an IoTeX RPC Node
      • Run a Delegate Node
      • Rosetta API
    • Reference Docs
      • ioctl client
        • Accounts
        • HD Wallets
        • Aliases
        • Actions
        • Queries
        • Smart Contracts
        • Staking & Voting
        • Tokens
        • ioID Identities
        • W3bstream
        • Decentralized Identifiers (DID)
        • JWT Auth Tokens
      • Native IoTeX Development
        • IoTeX gRPC API
        • Account Cryptography
        • Address Conversion
        • Create Accounts
        • Estimate Gas Price
        • Make IOTX Transfers
        • Manage ERC20 Tokens
        • Smart Contract Interactions
        • ioPay Desktop
        • DID JWT Tokens
        • Calling any RPC method
      • Embedded Blockchain Clients
        • Arduino IDE
        • Linux Systems
        • PlatformIO
        • Examples
        • Tutorials
  • Participate
    • Crypto's Got Talent (CGT)
      • IoTeX x Polygon DePIN Grant
    • Governance
      • IoTeX Improvement Proposals
      • The Marshall DAO
    • Join the Community
    • Get in Touch
Powered by GitBook
LogoLogo

This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.

  • .

2025 | IoTeX

On this page
  • Overview
  • Verify using a UI
  • Verify using Hardhat
  • Setting Up a Hardhat Project
  • Coding the Contract
  • Preparing for Deployment
  • Verifying the Contract

Was this helpful?

Export as PDF
  1. Builders
  2. Launch Dapps on IoTeX

Verify Smart Contracts

PreviousSubmit tokens to the iotube bridgeNextAudit your Contracts

Last updated 8 months ago

Was this helpful?

Overview

Smart contracts aim to be trustless, requiring users to trust the contract execution without depending on third parties. This is ensured through source code verification, allowing users to confirm that some source code matches the code executed on the IoTeX blockchain.

Source code verification differs from formal verification, which checks if the contract behaves as intended. Typically, "contract verification" refers to the former, focusing on the match between high-level source code and the blockchain's bytecode.

Verify using a UI

If you are the contract owner and would like to verify your contract using a UI, please go to the following page and follow the requested steps:

Follow the guide below to verify multiple contracts using Hardhat:

Verify using Hardhat

In this tutorial, we will guide you through the entire process of verifying a smart contract using . Starting with contract creation, we'll then deploy it to the IoTeX testnet, and conclude by verifying the contract through .

Or you can refer this repository

Setting Up a Hardhat Project

  1. Install NodeJS: Ensure NodeJS is installed on your system.

  2. Install Hardhat: Execute the following command to install Hardhat:

    npm install --save-dev hardhat
  3. Initialize a Hardhat Project: To start a new Hardhat project, run:

    npx hardhat init

    For further details on creating smart contracts with Hardhat, refer to the official tutorial.

Coding the Contract

  1. Create the Contract File: Inside your Hardhat project directory, navigate to the contracts subfolder and create a file named greeter.sol. Insert the following code:

    // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; 
    import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; 
    
    contract NFT is ERC1155 { 
      constructor() ERC1155("URL") { 
        _mint(msg.sender, 0, 1, ""); 
      } 
    }
  2. Install OpenZeppelin Contracts: Run the following command to include the OpenZeppelin contracts package:

    npm install @openzeppelin/contracts
  3. Compile Your Contract: Compile the smart contract with:

    npx hardhat compile

Preparing for Deployment

  1. Setup IoTeX Testnet Account: Ensure you have a developer account on the IoTeX testnet with a balance of test IOTX tokens. Visit the IoTeX documentation for instructions on account creation and funding.

  2. Configure Hardhat: Modify hardhat.config.js to add the IoTeX network configurations, including your IoTeX Developer account private key:

    ...
    networks: {
        hardhat: {
        },
        mainnet: {
          url: 'https://babel-api.mainnet.IoTeX.io',
          accounts: [ PRIVATE_KEY ],
          chainId: 4689,
          gas: 8500000,
          gasPrice: 1000000000000
        },
        testnet: {
          url: 'https://babel-api.testnet.IoTeX.io',
          accounts: [ PRIVATE_KEY ],
          chainId: 4690,
          gas: 8500000,
          gasPrice: 1000000000000
        }
      },
      ...
  3. Deploy Script: Edit scripts/deploy.js with the following code to deploy your contract:

    const hre = require("hardhat");
    
    async function main() {
      const NFT = await hre.ethers.deployContract("NFT");
      await NFT.waitForDeployment();
      console.log("NFT deployed to:", NFT.target);
    }
    
    main().catch((error) => {
      console.error(error);
      process.exitCode = 1;
    });
  4. Deploy the Contract: Deploy your contract to the IoTeX testnet by running:

    npx hardhat run scripts/deploy.js --network testnet

  5. Note the contract address provided in the deployment log.

Verifying the Contract

  1. Install hardhat-verify Plugin: To enable contract verification, install the hardhat-verify plugin:

    npm install --save-dev @nomicfoundation/hardhat-verify
    or
    npm install --save-dev @nomicfoundation/hardhat-toolbox
  2. Update Hardhat Configuration: Edit hardhat.config.js by adding the configuration for contract verification, make sure you use your API key:

    ```typescript
    import 'dotenv/config'
    import { HardhatUserConfig } from "hardhat/config";
    import "@nomicfoundation/hardhat-toolbox";
    
    const config: HardhatUserConfig = {
      solidity: "0.8.20",
      networks: {
        iotex: {
          chainId: 4689,
          url: 'https://babel-api.mainnet.iotex.io',
          accounts: [
            process.env.PRIVATE_KEY!
          ]
        }
      },
      etherscan: {
        apiKey: "arbitrary value",// It's here just for hardhat arguments validation
        //It  can be set as arbitrary value
        customChains: [
          {
            network: "mainnet",
            chainId: 4689,
            urls: {
              apiURL: "https://iotexscout.io/api",
              browserURL: "https://iotexscan.io"
            }
          },
          {
            network: "testnet",
            chainId: 4690,
            urls: {
              apiURL: "https://testnet.iotexscout.io/api",
              browserURL: "https://testnet.iotexscan.io"
            }
          }
        ],
      },
    };
    
    export default config;
    
    ```
  3. Verify the Contract: Execute the following command, replacing <address> with your contract's address:

    npx hardhat verify --network testnet YOUR_CONTRACT_ADDRESS [...arguments in constructor]
  4. Upon successful execution, you'll receive a link to your contract's verified code on IoTeXscan.

→ IoTeX Contract Verification UI
IoTeXscan
Hardhat
https://github.com/iotexproject/hardhat-verify-smaple