Skip to main content

Verify a smart contract on Monad 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 using Foundry.

If you are using foundry-monad template, you can use the commands below based on your preferred block explorer:

forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org

Example:

forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 10143 \
--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 `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet
Attempting to verify on Sourcify. Pass the --etherscan-api-key <API_KEY> to verify on Etherscan, or use the --verifier flag to verify on another provider.
Submitting verification for [Counter] "0x8fEc29BdEd7A618ab6E3CD945456A79163995769".
Contract successfully verified

Now check the contract on MonadExplorer.