Join our community of builders on Discord!

Verify a Contract

Verifying your contract publishes the source code on the block explorer, allowing anyone to read, audit, and interact with it through the explorer UI. Verification builds trust and makes your contract accessible to the community.
[!NOTE] Verification matches your compiled bytecode against the deployed bytecode.
The compiler version, optimization settings, and source code must match exactly.

Why Verify?

  • Transparency — Users and auditors can review the actual code running on-chain.
  • Explorer interaction — Enables the "Read Contract" and "Write Contract" tabs on the explorer.
  • Credibility — Verified contracts signal professionalism and trustworthiness.
  • Composability — Other developers can easily integrate with your contract.

Option A: Verify with Hardhat

Step 1 — Install the Verify Plugin

CodeBASH

Step 2 — Configure the Explorer

Update
CodeHTML
:
CodeJAVASCRIPT

Step 3 — Run Verification

CodeBASH
The last argument(s) are the constructor arguments you passed during deployment. They must match exactly. Expected output:
CodeHTML

Option B: Verify with Foundry

CodeBASH
[!TIP] If you deployed via
CodeHTML
with
CodeHTML
flag, verification happens automatically:
CodeBASH

Option C: Verify via the Explorer UI

For manual verification without CLI tools:
  1. Go to the Lightchain AI Testnet Explorer.
  2. Search for your contract address.
  3. Click the "Contract" tab, then "Verify & Publish".
  4. Select the verification method:
    • Solidity (Single file) — For simple contracts with no imports.
    • Solidity (Standard JSON Input) — For projects with dependencies and imports.
    • Solidity (Flattened) — For flattened source files.
  5. Fill in the details:
    • Compiler version (e.g.,
      CodeHTML
      )
    • Optimization (enabled/disabled and number of runs)
    • Source code
    • Constructor arguments (ABI-encoded)
  6. Submit and wait for confirmation.

Flattening Your Contract

If using the flattened method, generate a single file:
CodeBASH
Remove duplicate SPDX license identifiers from the flattened file before submitting. Multiple // SPDX-License-Identifier lines will cause verification to fail.

Verify with Constructor Arguments

If your contract's constructor accepts arguments, you must provide them ABI-encoded during verification.

Encode Constructor Arguments

CodeBASH
Pass this hex string as the constructor arguments in whichever verification method you use.

Confirming Verification

After successful verification:
  1. Visit your contract on the explorer.
  2. The "Contract" tab will display a green checkmark.
  3. Two new interactive tabs will appear:
    • Read Contract — Call view/pure functions directly.
    • Write Contract — Connect your wallet and send transactions.
Your contract source code is now publicly verified and fully interactive on the explorer.

Troubleshooting

IssueSolution
"Bytecode does not match"Ensure the compiler version and optimization settings match your deployment.
"Constructor arguments mismatch"Double-check that constructor args are ABI-encoded and match exactly.
Verification times outThe explorer may be processing. Wait a few minutes and check the contract page.
Imports not resolvedUse Standard JSON Input or flatten your source before submitting.

Next Steps

Your contract is now deployed, interactive, and verified. Explore more:
Last updated: February 2026