Somnia Explorer Smart Contract Verification
This documentation provides complete guidance for verifying your smart contracts using our web interface, API endpoints, Hardhat, and Foundry.
How It Works
Somnia Explorer operates a comprehensive API server that includes all stable Solidity compiler versions (excluding nightly builds). Our verification system supports multiple methods to accommodate different development workflows:
Single File Verification: For simple contracts contained in one source file
Multi-Part File Verification: For complex contracts with multiple dependencies
Standard JSON Input: The recommended method with complete compilation metadata
API Verification: Submit verification requests programmatically through REST endpoints
Hardhat Verification: Verify contracts directly from your Hardhat environment using the Somnia Explorer API
Foundry Verification: Verify contracts from the command line with Foundry’s
forge verify-contract
command
Verification Process
Input Processing: We receive your contract information through web interface or API
Compilation: Our system compiles your source code using the specified compiler version
Response Generation: Verification results are returned with contract details
1. Explorer UI
The Somnia Explorer web interface provides an intuitive way to verify your smart contracts. The verification process is designed to be user-friendly while maintaining technical accuracy.
Getting Started

Navigate to the Verify Contract page on Somnia Explorer
Enter the contract address you want to verify
Select the appropriate compiler type from the available options
Solidity (Single File)
Perfect for simple contracts that don't have external dependencies or complex import structures.

Single-file verification — Steps
Contract Code: Copy and paste your complete smart contract source code into the text area
Compiler version: Choose the Solidity compiler version used during development
Optimization Settings:
Enable optimization if it was used during compilation (default: disabled)
Set the optimization runs value (default: 200)
EVM Version: Select the appropriate EVM version (default: Prague)
License Type: Specify the open source license type for your contract
Constructor Arguments: Enter constructor parameters if your contract was deployed with initialization arguments
Submit: Click "Verify and Publish" to complete verification
Solidity (Multi-Part Files)
Ideal for complex contracts with multiple source files, libraries, and dependencies.

Multi-file verification — Steps
File Upload: Upload all source files required for compilation
Supported formats:
.sol
,.json
Include all imported contracts and dependencies
Compiler version: Choose the Solidity compiler version used during development
Optimization Settings:
Enable optimization if it was used during compilation (default: disabled)
Set the optimization runs value (default: 200)
EVM Version: Select the appropriate EVM version (default: Prague)
License Type: Specify the open source license type for your contract
Constructor Arguments: Enter constructor parameters if your contract was deployed with initialization arguments
Submit: Click "Verify and Publish" to complete verification
Solidity (Standard-JSON-Input)
The most comprehensive verification method, recommended for production contracts.

Standard JSON input — Steps
JSON File Upload: Upload your complete Standard JSON input file
Supported formats:
.json
Should include all compilation settings, optimizer configuration, and source mappings
Compiler version: Choose the Solidity compiler version used during development
License Type: Specify the open source license type for your contract
Constructor Arguments: Enter constructor parameters if your contract was deployed with initialization arguments
Submit: Click "Verify and Publish" to complete verification
2. API Verification
Base Configuration
API Base URL https://explorer-somnia.api.xangle.io
Required Header
X-Chain: SOMNIA
Endpoints
Single File Contract Verification
POST /api/contract/verify/single-file
Content Type: application/json
Description: Verify a smart contract using a single Solidity source file.
Request Body
{
"mainNetType": "SOMNIA",
"evmVersion": "string",
"contractAddress": "string",
"solcVersion": "string",
"optimizationEnabled": boolean,
"runs": number,
"viaIR": boolean,
"constructorArgs": "string",
"sourceCode": "string"
}
Response
{
"STS": "Y",
"CTRTADDR": "string",
"MSG": "string",
"VA": number,
"NM": "string",
"BTCD": "string",
"ABI": "string"
}
Multi-File Contract Verification
POST /api/contract/verify/multi-file
Content Type: multipart/form-data
Description: Verify a smart contract using multiple source files.
Request Body
{
"mainNetType": "SOMNIA",
"evmVersion": "string",
"contractAddress": "string",
"solcVersion": "string",
"optimizationEnabled": boolean,
"runs": number,
"viaIR": boolean,
"constructorArgs": "string",
"sourceFileList": [
"string($binary)"
]
}
Response
{
"STS": "Y",
"CTRTADDR": "string",
"MSG": "string",
"VA": number,
"NM": "string",
"BTCD": "string",
"ABI": "string"
}
JSON Input Contract Verification
POST /api/contract/verify/json
Content Type: multipart/form-data
Description: Verify a smart contract using multiple source files (Standard JSON input).
Request Body
{
"mainNetType": "SOMNIA",
"evmVersion": "string",
"contractAddress": "string",
"solcVersion": "string",
"optimizationEnabled": boolean,
"runs": number,
"viaIR": boolean,
"constructorArgs": "string",
"sourceFileList": [
"string($binary)"
]
}
Response
{
"STS": "Y",
"CTRTADDR": "string",
"MSG": "string",
"VA": number,
"NM": "string",
"BTCD": "string",
"ABI": "string"
}
3. Hardhat Verification
Hardhat provides a convenient way to verify smart contracts directly from your development environment. By integrating with the Somnia Explorer API, you can submit your contract source code and metadata without leaving your workflow.
Base Configuration
In your hardhat.config.js
(or hardhat.config.ts
), configure the Somnia mainnet settings:
const config: HardhatUserConfig = {
solidity: "v0.8.30", // replace if necessary
networks: {
'somnia-mainnet': {
url: {public rpc or your own rpc url}
},
},
etherscan: {
apiKey: {
'somnia-mainnet': 'empty'
},
customChains: [
{
network: "somnia-mainnet",
chainId: 5031,
urls: {
apiURL: "https://verify-contract.xangle.io/somnia/api",
browserURL: "https://somnia-explorer.xangle.io"
}
}
]
}
};
networks
: Use public RPC or a private RPC you manage for Somnia mainnetetherscan.apiKey
: Normally used for Etherscan, but for Somnia an empty value is sufficientcustomChains
: Points Hardhat to the Somnia Explorer API and browser endpoints
Verification Command
npx hardhat verify \
--network somnia-mainnet \
<address> \
[...constructorArgs]
<contractAddress>
: The address of your deployed contract[constructorArgs...]
: Any constructor parameters passed during deployment
4. Foundry Verification
Foundry offers a streamlined way to verify your smart contracts directly from the command line. By using the built-in forge verify-contract
command, you can connect to Somnia Explorer and publish your contract’s source code automatically.
Verification Command
forge verify-contract \
--rpc-url {public rpc or your own rpc url} \
--verifier etherscan \
--verifier-url ‘https://verify-contract.xangle.io/somnia/api’ \
<address> \
[contractFile]:[contractName]
-rpc-url
: Use public RPC or a private RPC you manage for Somnia mainnet-verifier
: Use Etherscan-verifier-url
: API endpoint of Somnia Explorer contract verification<address>
: The deployed contract address[contractFile]:[contractName]
: The Solidity file and the specific contract name to verify
Foundry example workflow
Deploy your contract to Somnia mainnet using Foundry or another deployment method
Copy the deployed address from the deployment output
Run the verify command with the contract address, source file, and contract name
Once complete, your verified source code will be visible on Somnia Explorer
Last updated