OKLink API Integration Guide

Β·

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-code

This 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

Optional Parameters

πŸ’‘ 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-result

Request Parameters

Response Values

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-contract

Parameters

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-result

Response Interpretation

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-info

Parameters

Returned Data Includes:

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-verify

Add 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 xlayer

For proxies:

npx hardhat okverify --network xlayer --proxy

Using 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_KEY

Monitor status:

forge verify-check --chain 11155111 --verifier oklink --api-key YOUR_KEY

Using 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.