A Hardhat plugin for verifying smart contracts on HashScan (Hedera's Sourcify-based contract verification service).
- Works for Hedera Mainnet (295), Testnet (296), Previewnet (297) and Local (298)
- No API key needed
- Direct integration with HashScan's Sourcify API
- Automatic contract verification status checking
- Clean error messages
npm i -D hashscan-verify
In your hardhat.config.ts
:
import { defineConfig } from "hardhat/config";
import hashscanVerify from "hashscan-verify";
export default defineConfig({
plugins: [hashscanVerify],
networks: {
mainnet: { url: "https://mainnet.hashio.io/api" },
testnet: { url: "https://testnet.hashio.io/api" },
previewnet: { url: "https://previewnet.hashio.io/api" },
local: { url: "http://localhost:7546" },
},
});
Note: The plugin automatically sets the correct chain IDs for Hedera networks.
npx hardhat hashscan-verify 0xYourContractAddress --contract contracts/MyContract.sol:MyContract --network testnet
The plugin checks if your contract is already verified before attempting verification:
$ npx hardhat hashscan-verify 0x... --contract contracts/Counter.sol:Counter --network testnet
Contract is already verified with perfect match.
View on HashScan: https://hashscan.io/testnet/contract/0x...
Meaningful error handling with helpful suggestions:
- Invalid contract address format
- Contract not found in artifacts
- Missing build info (suggests recompilation)
- Network connection issues
Supports both legacy hedera_*
and simplified network names:
mainnet
orhedera_mainnet
(Chain ID: 295)testnet
orhedera_testnet
(Chain ID: 296)previewnet
orhedera_previewnet
(Chain ID: 297)local
orhedera_local
(Chain ID: 298)
HASHSCAN_API_URL
orSOURCIFY_API_URL
- Override the API endpoint (defaults to HashScan's Sourcify)
npx hardhat hashscan-verify 0x7A0505Eb4af57Eefb9B69619DB3bfc26348DE73A --contract contracts/Counter.sol:Counter --network testnet
npx hardhat hashscan-verify 0x... --contract contracts/Token.sol:MyToken "My Token" "MTK" 1000000 --network mainnet
- On Hedera Testnet/Previewnet, verifications are wiped on periodic resets—just re-run verify after redeploy
- Foundry users: no wrapper needed. Use forge directly with HashScan's Sourcify:
forge verify-contract --chain-id 296 \ --verifier sourcify \ --verifier-url https://server-verify.hashscan.io \ <ADDRESS> src/MyContract.sol:ContractName
Build the plugin:
npm run build
Publish (after build):
npm publish
MIT