---
updatedAt: 2025-12-08T06:11:46.000Z
agentTools:
  projectIndex: https://docs.blockvision.org/llms.txt
---

# Smart Contract Verification on Monad Explorer

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**:

1. **Via Explorer UI**
2. **Via Foundry CLI**
3. **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/

```

> For the verifier URL, please make sure to use <https://sourcify-api-monad.blockvision.org/>
>
> — including '/' at the end of url
>
> — instead of <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

1. Visit the verification page: <Anchor label="Mainnet" target="_blank" href="https://monadvision.com/verify-contract">Mainnet</Anchor>  and <Anchor label="Testnet" target="_blank" href="https://testnet.monadvision.com/verify-contract">Testnet</Anchor>
2. Select the correct **network** (Mainnet or Testnet).
3. Enter your **contract address**.
4. Upload or paste your:
   * `metadata.json` (compiler metadata)
   * Contract source file(s) or flattened source
5. Click **“Verify”**. The explorer will match the uploaded bytecode against the on-chain deployed contract.
6. Once successful, your contract will display as **“Verified”** in the explorer.
7. You can then view the verified source code, ABI, and other details on the contract’s page.

<Callout icon="💡" theme="default">
  ### Tip: If verification fails, check compiler version, optimization settings, and metadata consistency.
</Callout>

***

## 🛠️ 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:

````toml
[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:**

```bash
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:Counter
```

### Troubleshooting API Deserialization Errors

#### When running contract verification commands, if you encounter this error:

```javascript
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)

<br />

#### Solution 2: Remove Etherscan API Key Configuration

**Step 1: Check Your Configuration**

Run the following command to view your current Foundry configuration:

```javascript
forge config
```

**Step 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**

<br />

### 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

```bash
npm install --save-dev @nomicfoundation/hardhat-verify
```

### 2. Configure your `hardhat.config.js`

```js
require("@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

```bash
npx hardhat verify --network monad --contract [contractFile]:[contractName] <address> \
  [...constructorArgs]
```

**Example:**

```bash
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.json` matches deployed build.
* **Multiple files** → Use flattened source or include full project folder for Sourcify.
* **Network errors** → Verify the correct RPC URL and chain ID.