Integrating your blockchain projects with reliable tools is essential for transparency, security, and developer efficiency. The OKLink API offers a powerful suite of features for verifying smart contracts, checking proxy implementations, retrieving verified contract data, and more β all through a seamless, developer-friendly interface.
Whether you're building on Ethereum, BSC, Polygon, Arbitrum, or emerging chains like Base and Scroll, OKLink supports a wide range of public blockchains including mainnets and testnets. This guide walks you through the core functionalities of the OKLink API, best practices for integration, and how to streamline verification using popular development frameworks such as Hardhat, Foundry, and Truffle.
π Smart Contract Source Code Verification
Verifying smart contract source code enhances transparency by allowing users to review the actual code behind on-chain contracts. The OKLink API enables developers to submit contract source code for verification, where it is compiled and matched against the deployed bytecode on the blockchain.
Once verified, the contractβs source code and ABI are publicly displayed on the OKLink explorer, increasing trust among users and auditors.
API Endpoint: Verify Contract Source Code
POST /api/v5/explorer/contract/verify-source-codeThis endpoint supports Solidity single-file contracts, standard JSON input format, and Vyper contracts. The average processing time for verification is 30β60 seconds, and each request consumes 0 API points, making it cost-efficient.
Required Parameters
chainShortName(String) β Chain identifier (e.g.,ETH,BSC)contractAddress(String) β Address of the deployed contractcontractName(String) β Name of the contractsourceCode(String) β Full source code; must be flattened if imports are usedcodeFormat(String) β Format type:solidity-single-file,solidity-standard-json-input, orVyper
Optional Parameters
compilerVersionβ Compiler version used (e.g.,v0.8.20+commit...)optimizationβ Whether optimization was enabled (0or1)optimizationRunsβ Number of optimization runscontractAbiβ JSON string of the contract ABIevmVersionβ Target EVM version (e.g.,paris,london)viaIrβ Whether IR-based compilation was used (true/false)libraryInfoβ Array of linked libraries with names and addresses (up to 10)
π‘ Tip: Use tools like SolidityFlattery to flatten multi-file contracts before submission.
π Speed up your contract deployment workflow with automated verification tools.
Example Request
{
"chainShortName": "ETH",
"contractAddress": "0x9Dca580D2c8B8e19e9d77345a5b4C2820B25b386",
"contractName": "HelloWorld",
"sourceCode": "pragma solidity ^0.7.6; contract HelloWorld { string public greet = 'Hello World!'; }",
"codeFormat": "solidity-single-file",
"compilerVersion": "v0.7.6+commit.7338295f",
"optimization": "1"
}Response
{
"code": "0",
"msg": "",
"data": ["eb5c06099d3841359d398541166343fe"]
}A successful submission returns a unique GUID, which can be used to check the verification status.
π Check Contract Verification Status
After submitting a contract for verification, use the returned GUID to query its status.
API Endpoint: Check Verification Result
POST /api/v5/explorer/contract/check-verify-resultRequest Parameters
chainShortName(String) β Chain identifierguid(String) β Unique identifier from the initial verification request
Response Values
Successβ Contract verified successfullyFailβ Verification failedPendingβ Still processing
This allows for asynchronous tracking of verification progress without blocking your deployment pipeline.
π§© Proxy Contract Verification
Proxy patterns are widely used in upgradeable smart contracts. OKLink supports verification of proxy contracts to ensure they correctly delegate calls to expected implementation contracts.
API Endpoint: Verify Proxy Contract
POST /api/v5/explorer/contract/verify-proxy-contractParameters
chainShortName(String) β Target chainproxyContractAddress(String) β Address of the proxy contractexpectedImplementation(String, optional) β Expected implementation address
Submitting this request initiates a background check on whether the proxy correctly points to the intended logic contract.
The response includes a GUID for tracking results.
π Ensure your upgradeable contracts are transparent and secure β verify them instantly.
π Query Proxy Verification Result
Use the GUID from the previous step to retrieve the outcome of the proxy verification.
API Endpoint: Check Proxy Verification Result
POST /api/v5/explorer/contract/check-proxy-verify-resultResponse Interpretation
- If successful: Returns the detected implementation contract address
- If failed: Message indicates no valid implementation was found
This provides immediate feedback on proxy integrity, crucial for audits and security reviews.
π Retrieve Verified Contract Information
Access verified contract details such as source code, ABI, compiler settings, and license type directly via API.
API Endpoint: Get Verified Contract Info
GET /api/v5/explorer/contract/verify-contract-infoParameters
chainShortName(String) β Chain identifiercontractAddress(String) β Contract address to query
Returned Data Includes:
sourceCode: Full verified source codecontractAbi: JSON ABI arraycompilerVersion,optimization,evmVersion: Compilation metadataproxy: Indicates if it's a proxy (1) or not (0)implementation: Implementation address (if applicable)swarmSource: Swarm hash of the source
This endpoint is ideal for dApps that need to dynamically load contract interfaces or perform automated analysis.
β Supported Public Chains
OKLink supports contract verification across major EVM-compatible networks:
Mainnets:
Ethereum (ETH), BSC, Polygon, Avalanche C-Chain (AVAXC), Fantom (FTM), Optimism (OP), Arbitrum, Linea, Manta, Canto, Base, Scroll, opBNB, Polygon zkEVM
Testnets:
Sepolia, Goerli, Amoy, Mumbai, Polygon zkEVM Testnet, XLayer Testnet
Support for both production and testing environments ensures smooth development cycles.
βοΈ Integration with Development Tools
Streamline your workflow by integrating OKLink directly into your build environment.
Using Hardhat for Contract Verification
Method 1: Official Plugin (Recommended)
Install:
npm install @okxweb3/hardhat-explorer-verifyAdd to hardhat.config.js:
require('@okxweb3/hardhat-explorer-verify');
module.exports = {
solidity: '0.8.24',
networks: { /* your config */ },
okxweb3explorer: {
apiKey: 'YOUR_API_KEY',
customChains: [
{
network: 'eth',
chainId: 1,
urls: {
apiURL: 'https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/eth',
browserURL: 'https://www.oklink.com'
}
}
]
}
};Verify after deployment:
npx hardhat okverify --network xlayerFor proxies:
npx hardhat okverify --network xlayer --proxyUsing Foundry
Use the forge verify-contract command with OKLinkβs verifier URL.
Example:
forge verify-contract \
src/MyToken.sol:MyToken \
--verifier oklink \
--verifier-url https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/eth \
--api-key YOUR_OKLINK_API_KEYMonitor status:
forge verify-check --chain 11155111 --verifier oklink --api-key YOUR_KEYUsing Truffle
Add plugin and configure:
plugins: ['truffle-plugin-verify'],
oklinkVerify: {
verify: {
apiUrl: 'https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/eth@truffle',
apiKey: 'YOUR_API_KEY',
explorerUrl: 'https://www.oklink.com/'
}
}Run:
truffle run verify ContractName --network ethπ Core Keywords
Smart contract verification, OKLink API, blockchain explorer, EVM contract validation, proxy contract verification, Hardhat integration, Foundry verification, Truffle plugin
β Frequently Asked Questions (FAQ)
Q: Is there a cost to use the OKLink contract verification API?
A: No. All verification-related API calls consume 0 points, making it completely free to verify contracts and retrieve verified data.
Q: What should I do if my contract fails verification?
A: Common causes include mismatched compiler versions, incorrect optimization settings, or unflattened multi-file code. Double-check your deployment configuration and ensure all library addresses match exactly.
Q: Can I verify upgradeable (proxy) contracts?
A: Yes. Use the /verify-proxy-contract endpoint to confirm that your proxy correctly delegates to the intended implementation contract.
Q: Does OKLink support non-Solidity languages?
A: Yes. In addition to Solidity, OKLink supports Vyper contracts. Support for other languages may be added in future updates.
Q: How long does verification take?
A: Most verifications complete within 30β60 seconds. You can poll the result using the returned GUID until the status changes from Pending.
Q: Can I automate verification in CI/CD pipelines?
A: Absolutely. By integrating with Hardhat, Foundry, or Truffle, you can automate verification right after deployment β ensuring every release is transparent and auditable.
π Automate your smart contract verification today β integrate with OKLink now.