Skip to content

Verified contract source

$0.005 per callUSDC via x402POST /api/contract-source

Fetch the verified Solidity source files and compiler metadata for a contract address from an open verified-contract repository. Send POST /api/contract-source with the required field address and pay $0.005 per call over x402 or MPP (there is no free tier). It returns a JSON object with address, network, chainId, verified, match and 7 more.

Covers 8 EVM mainnets (ethereum, base, polygon, arbitrum, optimism, bsc, gnosis, celo). Contracts that were never verified return a structured {verified:false} miss, not an error. Feed the returned source into /api/solidity-scan for a heuristic pattern check.

Category: Crypto & onchain dataTags: crypto contract smart-contract solidity source verified-source evm verificationAlso found as: source

Try in playground →

Parameters

NameTypeRequiredDescription
addressstringyes0x-prefixed 40-char contract address. Also accepted as addr, wallet, account. The example sends 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.
networkstringnoethereum / base / polygon / arbitrum / optimism / bsc / gnosis / celo (default base). The example sends base.

Example request

curl -i -X POST https://agent402.tools/api/contract-source \
  -H "Content-Type: application/json" \
  -d '{"address":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","network":"base"}'

Without payment this returns HTTP 402 Payment Required with the exact price for contract-source; any x402 v2 or MPP client pays it and retries.

Watch a call get paid

RequestPOST /api/contract-source
402$0.005 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example response

{
  "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
  "network": "base",
  "chainId": 8453,
  "verified": true,
  "match": "exact_match",
  "verifiedAt": "2024-08-08T13:59:29Z",
  "compiler": {
    "language": "Solidity",
    "version": "0.6.12"
  },
  "sourceCount": 2,
  "sources": {
    "contracts/FiatTokenProxy.sol": "// SPDX-License-Identifier: MIT …"
  },
  "licenses": {
    "contracts/FiatTokenProxy.sol": "MIT"
  },
  "licenseNote": "Each file is its authors' work, under the license its SPDX-License-Identifier states (licenses, by file; null where a file states none). Reuse of a file follows its license.",
  "credit": "Verified source from Sourcify (https://sourcify.dev)."
}
FieldTypeAlways presentIn the example
addressstringyes0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
networkstringyesbase
chainIdnumberyes8453
verifiedbooleanyestrue
matchstringyesexact_match
verifiedAtstringyes2024-08-08T13:59:29Z
compilerobjectyes2 fields: language, version
sourceCountnumberyes2
sourcesobjectyes1 field: contracts/FiatTokenProxy.sol
licensesobjectyes1 field: contracts/FiatTokenProxy.sol
licenseNotestringyesEach file is its authors' work, under the license its SPDX-License-Identifier...
creditstringyesVerified source from Sourcify (https://sourcify.dev).

From an MCP client

catalog.call {
  "slug": "contract-source",
  "params": {
    "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "network": "base"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for contract-source; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.17.1.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.005" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/contract-source", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "network": "base"
  }),
});

No wallet yet? Fund a first one with USDC on Base, no ETH needed, or run npx -y agent402-mcp@0.17.1 wallet new to make one on this computer: it stores the key and prints the address and the config, never the key.

The quote (Python)

Standard library only: the 402 and the price its PAYMENT-REQUIRED header quotes on each chain. To pay from Python, sign it with any x402 client.

import base64, json, urllib.error, urllib.request

req = urllib.request.Request("https://agent402.tools/api/contract-source", method="POST", data="{\"address\":\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\"network\":\"base\"}".encode(), headers={"Content-Type": "application/json"})
try:
    urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
    quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
    print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]])  # the price, per chain, in base units

Part of these workflows

Verified contract source is one step in this skill pack, each sold as a single call:

Related tools

Solidity heuristic pattern scan

FREE w/ computeor $0.01POST /api/solidity-scan

Deterministic static pattern scan of Solidity smart-contract source text - a fixed ruleset flagging tx.origin.

Verified contract ABI

$0.003POST /api/contract-abi

Fetch the verified ABI for a contract address from an open verified-contract repository, plus a ready-to-use list.

Function selector / event topic lookup

$0.002POST /api/selector-lookup

Resolve a 4-byte function selector or a 32-byte event topic hash to its known human-readable Solidity signatures.

Calldata decoder (ABI or selector DB)

$0.002POST /api/calldata-decode

Decode EVM smart-contract transaction calldata into the function name and typed parameters.

Token price by contract address

$0.005GET /api/coin-price-by-contract

Live price, market cap, 24h volume and 24h change for ERC-20 / SPL / other chain tokens looked up by CONTRACT ADDRESS.

Contract bytecode check

$0.002GET /api/contract-code

Is this address a contract, and what code does it hold?