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 the Sourcify verification service.
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:
👉 https://testnet.monadexplorer.com/verify-contract - Select the correct network (Testnet or Mainnet).
- 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 testnet
- 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://testnet-rpc.monad.xyz \
--verifier sourcify \
--verifier-url 'https://sourcify-api-monad.blockvision.org' \
<address> \
[contractFile]:[contractName]Example:
forge verify-contract \
--rpc-url https://testnet-rpc.monad.xyz \
--verifier sourcify \
--verifier-url 'https://sourcify-api-monad.blockvision.org' \
0xBA01C22bf93984B79fda58144abc384afb9bC1fd \
src/Counter.sol:CounterNotes
- 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: {
monadTestnet: {
chainId: 10143,
url: "https://rpc-testnet.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 monadTestnet <CONTRACT_ADDRESS>Example:
npx hardhat verify --network monadTestnet 0xYourContractAddressHardhat 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.
