When you deploy a smart contract on the Monad network, it’s best practice to verify and publish your source code so others can inspect and interact with it transparently.
This guide describes three verification methods:
- Via Explorer UI
- Via Foundry CLI
- Via Hardhat Plugin
🔗 Sourcify API Endpoint
All verification methods ultimately interact with BlockVision's Sourcify verification service. Both mainnet and testnet use the same Sourficy URL. The network will be detected automatically based on the RPC.
SOURCIFY API URL:
https://sourcify-api-monad.blockvision.org/
🖥️ 1. Verify via Explorer UI
The simplest way to verify your contract is through the Monad Explorer website.
Steps
- Visit the verification page: Mainnet and Testnet
- Select the correct network (Mainnet or Testnet).
- Enter your contract address.
- Upload or paste your:
metadata.json(compiler metadata)- Contract source file(s) or flattened source
- Click “Verify”. The explorer will match the uploaded bytecode against the on-chain deployed contract.
- Once successful, your contract will display as “Verified” in the explorer.
- You can then view the verified source code, ABI, and other details on the contract’s page.
Tip: If verification fails, check compiler version, optimization settings, and metadata consistency.
🛠️ 2. Verify via Foundry
If you use Foundry for development, you can verify directly through the CLI.
📘 Example Repository
For a complete self-check example, you can use this repository:
👉 https://github.com/block-vision/simple-contract-test
This sample project demonstrates:
- Deploying a simple Solidity contract using Foundry
- Verifying it on the Monad
- Testing the Sourcify verification pipeline end-to-end
Prerequisites
- Foundry installed (
forge) - Properly configured
foundry.toml
Example configuration:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
metadata = true
metadata_hash = "none"
use_literal_content = true
# Verification Command
```bash
forge verify-contract \
--rpc-url https://rpc.monad.xyz \
--verifier sourcify \
--verifier-url 'https://sourcify-api-monad.blockvision.org/' \
--chainid 143 \
<address> \
[contractFile]:[contractName]Example:
forge verify-contract \
--rpc-url https://rpc.monad.xyz \
--verifier sourcify \
--verifier-url 'https://sourcify-api-monad.blockvision.org/' \
--chainid 143 \
0xBA01C22bf93984B79fda58144abc384afb9bC1fd \
src/Counter.sol:CounterTroubleshooting API Deserialization Errors
When running contract verification commands, if you encounter this error:
ERROR etherscan: Failed to deserialize response: expected value at line 1 column 1
ERROR etherscan: Failed to deserialize ABI response err=Serde { error: Error("expected value", line: 1, column: 1)
Error: Provided URL https://sourcify-api-monad.blockvision.org/ is host only. Did you mean to use the API endpoint `https://sourcify-api-monad.blockvision.org//api` ?Solution 1: Double Check Verifier URL
Make sure your --verifier-url is https://sourcify-api-monad.blockvision.org/ (with trailing slash), not https://sourcify-api-monad.blockvision.org (without trailing slash)
Solution 2: Remove Etherscan API Key Configuration
Step 1: Check Your Configuration
Run the following command to view your current Foundry configuration:
forge configStep 2: Locate the Problem
Look through the output for any etherscan_api_key entries. The configuration might appear in different sections depending on your setup.
Step 3: Remove the Conflicting Configuration
If you find etherscan_api_key in your configuration, remove it from your foundry.toml file. The configuration file is typically located in your project root directory.
Step 4: Confirm Configuration Change
Run forge config again to confirm that etherscan_api_key has been successfully removed:
forge config
Check the output to ensure there are no etherscan_api_key entries remaining in your configuration.
Step 5: Retry Contract Verification
Notes
- Ensure the compiler version and optimization flags are identical to those used during deployment.
- On success, your contract will automatically appear as verified on Monad Explorer.
- If verification fails, inspect your metadata or recompile with the same settings.
⚙️ 3. Verify via Hardhat
For projects built with Hardhat, you can enable Sourcify-based verification with minimal setup.
1. Install the verification plugin
npm install --save-dev @nomicfoundation/hardhat-verify2. Configure your hardhat.config.js
hardhat.config.jsrequire("@nomicfoundation/hardhat-verify");
module.exports = {
networks: {
monad: {
chainId: 143,
url: "https://rpc.monad.xyz"
},
},
etherscan: {
enabled: false
},
sourcify: {
enabled: true,
apiUrl: "https://sourcify-api-monad.blockvision.org/"
},
solidity: {
version: "0.8.x",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
};3. Run the verification command
npx hardhat verify --network monad --contract [contractFile]:[contractName] <address> \
[...constructorArgs]Example:
npx hardhat verify -- network monad \
--contract src/Counter.sol:Counter \
0x60511f775dD4287a78d338a0727DF49363db5B33
Hardhat will automatically submit your compiled metadata and sources to the Sourcify API and display the verification status.
🧩 Troubleshooting
- Bytecode mismatch → Confirm same compiler version & optimization settings.
- Metadata errors → Ensure
metadata.jsonmatches deployed build. - Multiple files → Use flattened source or include full project folder for Sourcify.
- Network errors → Verify the correct RPC URL and chain ID.
