Contract Verification

📜 TL;DR:

This guide explains how to verify smart contracts deployed on the Hemi blockchain using two methods:

  1. Manual UI-based verification via Blockscout.

  2. API-based verification using Hardhat.


🏁 Prerequisites

  • Hemi RPC URL and deployed contract address.

  • Contract source code available (flattened only if verifying manually via the Hemi Blockscout UI).


🖥️ Blockscout UI Verification

Manual verification is performed directly through the Blockscout UI. This method requires flattening the contract source code and uploading it manually.

1. Flatten the contract

Flattening a contract is necessary when verifying through the UI.

For Hardhat:

npx hardhat flatten contracts/MyContract.sol > MyContractFlattened.sol

For Foundry:


2. Access Hemi Blockscout

Go to Hemi Blockscout Explorer and navigate to the Verify & Publish Contract page.


3. Input contract information

  • Smart contract / Address: Paste the address that your smart contract was deployed to.

  • Contract license: Select 'No License' unless otherwise specified.

  • Verification method: Choose Solidity (Flattened source code).

  • Is Yul contract: Leave unchecked unless your contract is written in Yul.

  • Include nightly builds: Select only if required.

  • Compiler: Choose the exact version specified in pragma solidity X.X.X in your code.

  • EVM Version: Set to default unless you used a specific EVM version.

  • Optimization enabled: Deselect optimization.

Copy and paste the entire flattened contract code into the Contract code field and click 'Verify & publish'.


4. Submit for verification 🎉

Once all required details are entered, submit the form. BlockScout will compare the uploaded source code with the deployed bytecode. If they match, your contract will be verified.


🚧 Hardhat Verification

1. Install dependencies

If you haven't already installed Hardhat and the verification plugin (adapted for Blockscout), run the following:


2. Configure Hardhat for Hemi

In your `hardhat.config.js`, set up the Hemi network and include Blockscout API information for contract verification:


3. Verify the contract

Once deployed, you can verify the contract using Hardhat’s `verify` command. Make sure to include any constructor arguments if necessary:


4. Verification successful! 🎉

Last updated

Was this helpful?