Verifying smart contracts proves that the deployed bytecode matches the source files you publish. On Hedera, verification is handled by Sourcify, which natively supports Hedera Mainnet (chain IDDocumentation Index
Fetch the complete documentation index at: https://hedera-0c6e0218-update-sourcify-migration-issue-508-luke.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
295) and Testnet (chain ID 296). Once a contract is verified on Sourcify, HashScan automatically picks up the verified status and displays the source code on the contract page.
Prerequisites
- Solidity source code file of the deployed smart contract.
- Solidity JSON (metadata) file of the deployed smart contract.
- EVM address of the smart contract deployed on the Hedera network.
Table of Contents
- Verify on Sourcify
- Confirm on HashScan
- Bundled Metadata for Complex Contracts
- Recommended: Programmatic Verification
- Additional Resources
Step 1: Verify on Sourcify
- Open sourcify.dev in your browser.
- Choose the network that matches your deployment: Hedera Mainnet (chain ID
295) or Hedera Testnet (chain ID296). - Paste the deployed contract’s EVM address.
- Upload your Solidity source files (
.sol) and the metadata file (.json). The metadata file is generated when you compile the contract; for example, with Hardhat it lives underartifacts/build-info/, and with Foundry the metadata is included in the per-contract JSON underout/. - Submit the verification request. Sourcify will recompile your sources and compare them against the deployed bytecode.
- Full Match: the bytecode and metadata are an exact match. Source code, comments, and variable names line up with the deployed contract.
- Partial Match: the bytecode mostly matches, but the metadata hash differs (typically due to comments or variable names). This is sufficient for most verification purposes.
📣 Different compiling tools require specific source files. Here's a brief outline of what's needed for popular tools:
📣 Different compiling tools require specific source files. Here's a brief outline of what's needed for popular tools:
- Remix:
- Required for Full Match Verification: Both the metadata file found in the
contracts/artifacts/folder and the smart contract’s Solidity file. More details here.
- Required for Full Match Verification: Both the metadata file found in the
- Hardhat:
- Required for Full Match Verification: Only the output of the compilation JSON file found in the
/artifacts/build-info/folder. More details here.
- Required for Full Match Verification: Only the output of the compilation JSON file found in the
- Solidity Compiler (solc):
- Required for Full Match Verification: Both the metadata file (generated by
solc --metadata) and the smart contract’s Solidity file. More details here.
- Required for Full Match Verification: Both the metadata file (generated by
- Foundry:
- Required for Full Match Verification: Both the metadata file (generated by
forge build) and the smart contract’s Solidity file.
- Required for Full Match Verification: Both the metadata file (generated by
Step 2: Confirm on HashScan
Open the contract on HashScan, making sure you’re on the same network you verified against. The contract’s source code, ABI, and verification badge will appear on the Contract tab once HashScan picks up the verified status from Sourcify. To learn more about each verification match status, head over to the official Sourcify documentation here. Congratulations! 🎉 You have successfully verified a smart contract on Hedera. Feel free to reach out on Discord if you have any questions!Bundled Metadata for Complex Contracts
For projects with multiple dependencies (such as OpenZeppelin libraries) or upgradeable proxy contracts, manually uploading individual source files can be extremely difficult and error-prone. Each dependency must be uploaded separately, and ensuring all imports resolve correctly is challenging. A more robust manual approach is to generate a single, self-containedmetadata.json file that includes all source code dependencies inline. This single file can then be uploaded to Sourcify in place of dozens of individual files.
Why Use This Approach?
When a contract imports many external libraries and files, the standard manual upload requires you to provide:- The main contract
.solfile - The metadata
.jsonfile - Every imported dependency file
Generating the Single Metadata File
Both Hardhat and Foundry projects can be configured to generate this single file using community-developed scripts that leverage the Sourcify standard.-
Download the metadata generation script from Generate Hedera SC Metadata Repo:
-
Run the script to generate the bundles:
-
This produces a directory (e.g.,
verify-bundles/) containing a singlemetadata.jsonfile for each contract. -
On sourcify.dev, select the Hedera network, enter the contract address, and upload the corresponding single
metadata.jsonfile.