OKLink API Integration Guide: Smart Contract Verification & Deployment

·

Introduction to OKLink's Contract Verification Tools

OKLink provides comprehensive API solutions for blockchain developers, including:

👉 Explore OKLink's full API suite

Why Verify Smart Contract Source Code?

Contract verification is crucial for:

OKLink's verification module supports:

  1. Source code submission for contract validation
  2. Proxy contract verification
  3. Retrieval of verified contract ABI and source code

Contract Source Code Verification

How It Works

Upload your Solidity/Vyper source code to OKLink's browser. Our system:

  1. Compiles your code
  2. Matches the bytecode with blockchain-stored bytecode
  3. Displays verified code on the contract page

Average processing time: 30-60 seconds

API Endpoint

POST /api/v5/explorer/contract/verify-source-code

Request Parameters

ParameterTypeRequiredDescription
chainShortNameStringYesBlockchain identifier (e.g., "ETH")
contractAddressStringYesTarget contract address
contractNameStringYesName of contract
sourceCodeStringYesFlattened source code
codeFormatStringYessolidity-single-file / solidity-standard-json-input / Vyper
compilerVersionStringConditionalCompiler version string
optimizationStringConditional0 (none) or 1 (enabled)

Example Request

{
 "chainShortName": "ETH",
 "contractAddress": "0x9Dca580D2c8B8e19e9d77345a5b4C2820B25b386",
 "contractName": "HelloWorld",
 "sourceCode": "pragma solidity ^0.7.6;↵contract HelloWorl {↵ string public greet = 'Hello Worl!';↵}",
 "codeFormat": "solidity-single-file",
 "compilerVersion": "v0.7.6+commit.7338295f",
 "optimization": "1"
}

Response

{"data": ["eb5c06099d3841359d398541166343fe"]}

Checking Verification Status

Use the returned GUID to check verification results.

API Endpoint

POST /api/v5/explorer/contract/check-verify-result

Status Responses


Proxy Contract Verification

Verify proxy contracts and their implementation addresses.

API Endpoint

POST /api/v5/explorer/contract/verify-proxy-contract

Successful Verification Response

Returns implementation contract address


Retrieving Verified Contract Information

Access ABI, source code, and metadata for verified contracts.

API Endpoint

GET /api/v5/explorer/contract/verify-contract-info

Returned Data Includes:


Third-Party Tool Integration

Hardhat Verification (Recommended)

  1. Install plugin:

    npm install @okxweb3/hardhat-explorer-verify

👉 Complete Hardhat setup guide

  1. Sample configuration:

    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"
     }
      }]
    }

Foundry Verification

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_API_KEY

Truffle Verification

oklinkVerify: {
  apiUrl: 'https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/eth@truffle',
  apiKey: 'YOUR_API_KEY',
  explorerUrl: 'https://www.oklink.com/'
}

Supported Blockchains

OKLink supports verification on 20+ chains including:


FAQ

Q: How long does contract verification take?

A: Typically 30-60 seconds for standard contracts.

Q: Can I verify proxy contracts?

A: Yes, OKLink supports full proxy contract verification.

Q: What if my contract uses imports?

A: Flatten your contract first using tools like Solidity Flattery.

Q: Is there a cost for API usage?

A: Basic verification endpoints currently consume 0 points.

Q: How do I get an API key?

A: Request one in your OKLink account dashboard.

Q: Can I verify Vyper contracts?

A: Yes, set codeFormat to "Vyper" in your request.