Verify a smart contract on Monad Explorer using Foundry
Once your contract is deployed to a live network, the next step is to verify its source code on the block explorer.
Verifying a contract means uploading its source code, along with the settings used to compile the code, to a repository (typically maintained by a block explorer). This allows anyone to compile it and compare the generated bytecode with what is deployed on chain. Doing this is extremely important in an open platform like Monad.
In this guide we'll explain how to do this on MonadExplorer using Foundry.
- Foundry Monad template (Recommended)
- Default Foundry Project
If you are using foundry-monad
template, you can simply run the below command:
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
Example:
forge verify-contract \
0x195B9401D1BF64D4D4FFbEecD10aE8c41bEBA453 \
src/Counter.sol:Counter \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
If you use foundry-monad
you can skip the configuration step
1. Update foundry.toml
with Monad Configuration
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
# Monad Configuration
eth-rpc-url="https://testnet-rpc.monad.xyz"
chain_id = 10143
2. Verify the contract using the command below:
forge verify-contract \
<contract_address> \
<contract_name> \
--verify \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
Example:
forge verify-contract \
0x195B9401D1BF64D4D4FFbEecD10aE8c41bEBA453 \
src/Counter.sol:Counter \
--verify \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
On successful verification of smart contract, you should get a similar output in your terminal:
Start verifying contract `0x195B9401D1BF64D4D4FFbEecD10aE8c41bEBA453` deployed on 10143
Submitting verification for [Counter] "0x195B9401D1BF64D4D4FFbEecD10aE8c41bEBA453".
Contract successfully verified
Now check the contract on Monad Explorer.