Verifying via Explorer

This document explains how to verify smart contracts on Somnia Mainnet using Blockscout. It replaces the old explorer-based verification flow.

How It Works

Somnia Mainnet Explorer is Blockscout-based and uses Blockscout verification endpoints.

There are 4 primary verification methods:

  1. Verification via Explorer UI

  2. Verification via Blockscout Smart Contract Verification API

  3. Verification via Hardhat plugin

  4. Verification via Foundry (forge)

Recommendation: For production contracts, use Standard JSON Input whenever possible. It includes full compiler metadata and gives the most reliable results.

1. Explorer UI

1

Go to the explorer

Go to https://explorer.somnia.network/ .

2

Open the verification page

Open Other -> Verify Contract.

3

Enter contract details

Enter your contract address and select a verification method.

4

Match compilation parameters

Match all compilation parameters exactly with your deployment settings:

  • Compiler version

  • EVM version

  • Optimizer and runs

  • Constructor args

  • License type

5

Verify and publish

Click Verify and Publish to complete the process.

Main UI verification options

  • Solidity (Flattened source code)

  • Solidity (Standard JSON input)

  • Solidity (Multi-part files)

  • Solidity (Sourcify)

  • Vyper (Single contract file)

  • Vyper (Multi-part files)

  • Vyper (Standard JSON input)

2. API Verification (Blockscout v2)

Base URL

https://mainnet.somnia.w3us.site/api/v2

Service health check

To check whether the verification service is active:

If healthy, it returns 200.

2.1 Flattened Solidity verification

2.2 Standard JSON Input verification

2.3 Multi-part Solidity verification

License values (example)

In Blockscout API, license_type is sent as a string:

  • none

  • unlicense

  • mit

  • gnu_gpl_v2

  • gnu_gpl_v3

  • gnu_lgpl_v2_1

  • gnu_lgpl_v3

  • bsd_2_clause

  • bsd_3_clause

  • mpl_2_0

  • osl_3_0

  • apache_2_0

  • gnu_agpl_v3

  • bsl_1_1

3. Hardhat Verification

For Somnia Blockscout, use the @nomicfoundation/hardhat-verify plugin.

Installation

Example hardhat.config.ts

Verification command

4. Foundry Verification

Use Blockscout verifier in Foundry as follows:

To verify at deployment time:

Troubleshooting

  • Compiler version must match exactly (0.8.24 vs 0.8.24+commit... matters).

  • Optimizer settings must exactly match deployment settings.

  • Verification fails if constructor arguments are incorrect or missing.

  • For multi-file projects, prefer Standard JSON Input or Multi-part over Flattened.

  • If errors persist, retry first via UI and then via API, and compare payload differences.

Last updated