Verification Examples Library

Copy-paste verification examples for every major toolchain.

Each example verifies a contract on xdcscan.io. Replace the address, name, and settings with your own.


Hardhat

Add the explorer as a custom chain in hardhat.config.ts:

export default {
networks: {
xdc: {
url: "https://rpc.xdc.org",
chainId: 50,
},
},
etherscan: {
apiKey: { xdc: "no-key-required" }, // OpenScan.AI does not require a key
customChains: [
{
network: "xdc",
chainId: 50,
urls: {
apiURL: "https://xdcscan.io/api",
browserURL: "https://xdcscan.io",
},
},
],
},
};

Verify after deploying:

Terminal window
npx hardhat verify --network xdc \
0xabcdefabcdefabcdefabcdefabcdefabcdefabcd \
"ConstructorArg1" 1000000

The plugin submits standard JSON input automatically — this is the most reliable verification path for Hardhat projects.

Foundry

Terminal window
forge verify-contract \
--chain-id 50 \
--compiler-version v0.8.24+commit.e11b9ed9 \
--verifier blockscout \
--verifier-url "https://xdcscan.io/api" \
0xabcdefabcdefabcdefabcdefabcdefabcdefabcd \
src/MyToken.sol:MyToken

For contracts with constructor arguments:

Terminal window
forge verify-contract \
--chain-id 50 \
--verifier blockscout \
--verifier-url "https://xdcscan.io/api" \
--constructor-args $(cast abi-encode "constructor(string,uint256)" "MyToken" 1000000) \
0xabcdefabcdefabcdefabcdefabcdefabcdefabcd \
src/MyToken.sol:MyToken

Check status:

Terminal window
forge verify-check --chain-id 50 \
--verifier blockscout --verifier-url "https://xdcscan.io/api" \
<GUID>

Remix

  1. Compile the contract in Remix with the same compiler version and optimizer settings used at deployment.
  2. Install/enable a Blockscout verification plugin, or copy the standard JSON input from the compilation details pane.
  3. On the contract’s page at xdcscan.io, open Contract → Verify & publish, choose Via standard JSON input, and paste.

curl — flattened source

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;\n\ncontract MyToken { ... }",
"optimization_enabled": true,
"optimization_runs": 200
}'

curl — standard JSON input

Terminal window
curl -X POST \
"https://xdcscan.io/api/v2/smart-contracts/0xabcdefabcdefabcdefabcdefabcdefabcdefabcd/verification/via/standard-input" \
-H "Content-Type: application/json" \
-d @verification-payload.json

verification-payload.json:

{
"compiler_version": "v0.8.24+commit.e11b9ed9",
"contract_name": "MyToken",
"input": "{\"language\":\"Solidity\",\"sources\":{ ... },\"settings\":{ ... }}"
}

Generate the input value from your build tool — Hardhat stores it in artifacts/build-info/, Foundry in out/.

Verify in your deploy script

Foundry scripts can verify inline:

Terminal window
forge script script/Deploy.s.sol --broadcast --verify \
--verifier blockscout --verifier-url "https://xdcscan.io/api"

With Hardhat, call hre.run("verify:verify", { address, constructorArguments }) right after the deployment transaction confirms.

Next steps