Contract Verification on XOS
After successfully deploying your smart contract to the XOS network, verifying your contract's source code is a crucial next step. Verification makes your contract's source code publicly visible on the block explorer, enhancing transparency and allowing users to interact with your contract directly through the explorer interface.
This guide outlines the verification process using both Remix IDE and Hardhat, with emphasis on the recommended Standard JSON Input method for reliable verification results.
Step 1: Navigate to the XOS Explorer
- Open your web browser and go to the XOS Explorer
- Enter your contract's address in the search field
- On the contract page, locate and select the Code tab
- Click the Verify & Publish button to begin the verification process
Step 2: Choose a Verification Method
The XOS Explorer supports multiple verification approaches. For the most reliable results, we strongly recommend using the Standard JSON Input method.
Benefits of Standard JSON Input
- Captures all compiler settings exactly as used during deployment
- Includes all necessary metadata and dependencies
- Minimizes verification failures due to configuration mismatches
Step 3: Verification Using Remix IDE
Generating the Standard JSON Input
Open your project in Remix IDE at remix.ethereum.org
Navigate to the Solidity Compiler panel
Ensure your compiler settings match those used during deployment:
- Select the exact compiler version
- Set optimization settings to match deployment configuration
- Click the Compile button
Access the JSON data:
- Expand the Compilation Details section
- Locate and copy the Standard JSON Input data
- Save this data to a local file with a
.json
extension
Submitting for Verification
- Return to the XOS Explorer verification page
- Select Standard JSON Input as your verification method
- Upload the JSON file you saved from Remix
- Select the appropriate license type for your contract
- Click Verify & Publish to submit
The explorer will process your submission and display a success message when verification is complete.
Step 4: Verification Using Hardhat
Generating Standard JSON Input with Hardhat
- Navigate to your Hardhat project directory in the terminal
- Run the compilation command:bash
npx hardhat compile
- Locate the
artifacts
folder in your project directory - Find the
build-info
subfolder which contains compilation artifacts - Inside this folder, you'll find JSON files containing the Standard Input format
Submitting for Verification
- Go to the XOS Explorer verification page
- Select Standard JSON Input as your verification method
- Upload the JSON file from your Hardhat artifacts
- Select the appropriate license type
- Submit the verification request
Verification Troubleshooting
Common Issues
Compiler Version Mismatch
- Ensure the compiler version in your verification matches exactly what was used for deployment
- Even minor version differences can cause verification to fail
Optimization Settings
- If you enabled optimization during compilation, the same settings must be used for verification
- Check both the optimization flag and the number of optimization runs
Constructor Arguments
- For contracts with constructor parameters, ensure these are correctly provided during verification
- ABI-encoded constructor arguments may be required for some verification methods
Importance of Contract Verification
- User Trust: Verified contracts allow users to review the code before interacting with it
- Transparency: Makes your contract's functionality publicly visible and auditable
- Usability: Enables direct interaction with your contract through the explorer interface
- Discoverability: Improves your contract's visibility in the ecosystem
By completing the verification process, you've taken an important step toward building a transparent and trustworthy application on the XOS network. Your verified contract is now ready for users to interact with confidently.