Verification API Reference

Verify contracts programmatically with the verification API.

Base URL: https://xdcscan.io/api/v2

All verification endpoints accept a POST with a JSON body and return immediately with a success or validation response. Verified source appears on the contract page and in /smart-contracts/{hash} responses within seconds.


Solidity: standard JSON input

The most reliable method — submit the exact JSON input you passed to solc:

POST /api/v2/smart-contracts/{address_hash}/verification/via/standard-input
Terminal window
curl -X POST \
"https://xdcscan.io/api/v2/smart-contracts/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd/verification/via/standard-input" \
-H "Content-Type: application/json" \
-d '{
"compiler_version": "v0.8.24+commit.e11b9ed9",
"contract_name": "MyToken",
"input": "{\"language\":\"Solidity\",\"sources\":{\"contracts/MyToken.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.24; ...\"}},\"settings\":{\"optimizer\":{\"enabled\":true,\"runs\":200}}}"
}'
FieldRequiredDescription
compiler_versionyesFull version string, e.g. v0.8.24+commit.e11b9ed9
contract_nameyesContract name as declared in source
inputyesStringified standard JSON compiler input

Standard JSON input embeds optimizer settings, EVM version, remappings, and library references — when it compiles to the deployed bytecode, verification is an exact match.

Solidity: flattened source

For single-file contracts with no imports (or pre-flattened source):

POST /api/v2/smart-contracts/{address_hash}/verification/via/flattened-code
Terminal window
curl -X POST \
"https://xdcscan.io/api/v2/smart-contracts/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd/verification/via/flattened-code" \
-H "Content-Type: application/json" \
-d '{
"compiler_version": "v0.8.24+commit.e11b9ed9",
"contract_name": "MyToken",
"source_code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24; ...",
"optimization_enabled": true,
"optimization_runs": 200,
"evm_version": "cancun",
"constructor_arguments": "0000000000000000000000000000000000000000000000000000000005f5e100"
}'

Additional fields: libraries (map of library name to address) when the contract links external libraries.

Solidity: multi-part files

For projects with imports but no build tool available:

POST /api/v2/smart-contracts/{address_hash}/verification/via/multi-part-files

Body adds a files object mapping relative paths to source content, plus the same settings fields as flattened-code. Paths must reproduce the import structure the compiler saw.

Vyper

Vyper contracts verify through flattened source or standard JSON equivalents:

POST /api/v2/smart-contracts/{address_hash}/verification/via/vyper-code
POST /api/v2/smart-contracts/{address_hash}/verification/via/vyper-multi-part-files

Fields mirror the Solidity variants, with compiler_version such as v0.3.10+commit.91361694.

Constructor arguments

If the constructor takes arguments, pass them ABI-encoded (hex, no 0x required) in constructor_arguments. Extract them from the deployment transaction: they are the trailing bytes of the init code after the compiled bytecode.

Responses

Success:

{ "message": "Smart-contract verification started" }

Failure (validation or bytecode mismatch):

{ "message": "Error compiling contract: ..." }

Verification is near-instant for most contracts; poll GET /api/v2/smart-contracts/{hash} and check is_verified to confirm.

Checking verification status

Terminal window
curl https://xdcscan.io/api/v2/smart-contracts/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd

Key response fields:

  • is_verified — verified (exact or partial match)
  • is_partially_verified — matched except for metadata hash
  • is_fully_verified — exact match
  • source_code, abi, compiler_version — available when verified

Troubleshooting

  • Bytecode mismatch — wrong compiler version, optimizer runs, or EVM version. These must match deployment exactly.
  • Cannot find contract in sourcescontract_name must equal the declared contract name, not the file name.
  • Libraries unresolved — provide every linked library’s deployed address in libraries.

See Best Practices for how to capture the right settings at deploy time so verification always succeeds.