Verify Contracts
Last updated
Last updated
Verifying your smart contract makes its source code publicly visible and auditable on the block explorer, creating transparency and trust. Here are the recommended methods to verify contracts on the and the .
— — — — —
The most streamlined way to verify contracts is using Hardhat with hardhat-toolbox:
Install Hardhat toolbox:
Configure hardhat.config.js
:
Store your SonicScan API key in a .env
file:
Verify your contract:
For automated deployments, you can verify contracts programmatically in your deployment scripts:
If automated methods fail, you can verify manually through the explorer interface:
Navigate to your contract address
Click the Contract tab and Verify & Publish
Fill in the verification details:
Contract address
Compiler type (single file recommended)
Compiler version (must match deployment)
Open-source license
Optimization settings (if used during deployment)
If your contract has constructor arguments:
Paste them in the Constructor Arguments field
Complete the captcha and submit
For contracts with complex dependencies that fail standard verification:
Install Hardhat flattener:
Flatten your contract:
Clean up the flattened file:
Keep only one SPDX license identifier
Keep only one pragma statement
Use this file for manual verification
Common verification issues to check:
Compiler version must match deployment exactly
Optimization settings must match deployment
Constructor arguments must be correctly ABI-encoded
Library addresses must be provided if used
Source code must match deployed bytecode exactly
Flattened files should not have duplicate SPDX/pragma statements
Go to the (or the )
Generate ABI-encoded arguments at e.g.