Skip to main content

Verify a smart contract on Monad Explorer using Hardhat

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 Hardhat.

1. Update your hardhat.config.ts file to include the monadTestnet configuration

import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox-viem";

const config: HardhatUserConfig = {
solidity: "0.8.27",
...
networks: {
monadTestnet: {
url: "https://testnet-rpc.monad.xyz",
chainId: 10143,
},
...
},
sourcify: {
enabled: true,
apiUrl: "https://sourcify-api-monad.blockvision.org",
browserUrl: "https://testnet.monadexplorer.com/"
},
// To avoid errors from Etherscan
etherscan: {
enabled: false,
},
};

export default config;

3. Verify the smart contract

Use the following command to verify the smart contract:

npx hardhat verify <contract_address> --network monadTestnet

On successful verification of smart contract, the output should be similar to the following:

Successfully verified contract GMonad on Sourcify.
https://testnet.monadexplorer.com/contracts/full_match/10143/<contract_address>/

Using the link in the output above, you can view the verified smart contract on the explorer.

explorer

Now check the contract on Monad Explorer.