Contract Verification
🏁 Prerequisites
Hemi RPC URL and deployed contract address.
Contract source code available (flattened only if verifying manually via the Hemi Blockscout UI).
API key from Hemi Blockscout (only needed for API-based verification).
🚧 API-Based Contract Verification
API-based verification is the preferred method since it automates the process using development tools like Hardhat or Foundry/Forge.
Hardhat Verification
1. Install dependencies
If you haven't already installed Hardhat and the Etherscan 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 key information for contract verification:
3. Deploy your contract
Deploy your contract using Hardhat (assuming it hasn’t already been deployed):
4. Verify the contract 🎉
Once deployed, you can verify the contract using Hardhat’s `verify
` command. Make sure to include any constructor arguments if necessary:
Foundry / Forge Verification
1. Install Foundry
If you haven’t installed Foundry, you can do so by running:
2. Set Up Forge Project
To set up a Forge project, initialize the project:
3. Deploy your contract
Deploy your contract to Hemi using Forge:
4. Verify the contract 🎉
Use the following command to verify the contract using the Blockscout API:
Make sure to replace YOUR_BLOCKSCOUT_API_KEY
and CONTRACT_ADDRESS
with your actual values.
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:
For Foundry:
2. Access Hemi Blockscout
Go to Hemi Blockscout Explorer and navigate to the Verify & Publish Contract page.
3. Input contract information
Input your deployed contract address, contract license, and contract verification method.
4. Submit for verification 🎉
Once the required details are entered, submit the form. Blockscout will match the uploaded source code with the deployed bytecode, and if they match, your contract will be verified.
Last updated