Verified contract source (Sourcify)
POST /api/contract-sourceFetch the verified Solidity source files and compiler metadata for a contract address from Sourcify's open verification 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 4 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.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
address | string | yes | 0x-prefixed 40-char contract address. Also accepted as addr, wallet, account. |
network | string | no | ethereum / base / polygon / arbitrum / optimism / bsc / gnosis / celo (default 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.
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 …"
}
}
| Field | Type | Always present | In the example |
|---|---|---|---|
address | string | yes | 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 |
network | string | yes | base |
chainId | number | yes | 8453 |
verified | boolean | yes | true |
match | string | yes | exact_match |
verifiedAt | string | yes | 2024-08-08T13:59:29Z |
compiler | object | yes | 2 fields: language, version |
sourceCount | number | yes | 2 |
sources | object | yes | 1 field: contracts/FiatTokenProxy.sol |
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 AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
addressis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/contract-source returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
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?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(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"
}),
});
Part of these workflows
Verified contract source (Sourcify) is one step in this skill pack, each sold as a single call:
- Contract audit - Triage a smart contract before an agent interacts with it: verified Solidity source, heuristic vulnerability scan, known-address check, function-selector resolution, and a read-only dry-run of the exact call you plan to make.
Related tools
Solidity heuristic pattern scan
POST /api/solidity-scanDeterministic static pattern scan of Solidity smart-contract source text - a fixed ruleset flagging tx.origin authentica…
Verified contract ABI (Sourcify)
POST /api/contract-abiFetch the verified ABI for a contract address from Sourcify, plus a ready-to-use list of human-readable function signatu…
Function selector / event topic lookup
POST /api/selector-lookupResolve a 4-byte function selector or a 32-byte event topic hash to its known human-readable Solidity signatures, via th…
Calldata decoder (ABI or selector DB)
POST /api/calldata-decodeDecode EVM smart-contract transaction calldata into the function name and typed parameters. Supply an ABI (from /api/con…
Token price by contract address
GET /api/coin-price-by-contractLive price, market cap, 24h volume and 24h change for ERC-20 / SPL / other chain tokens looked up by CONTRACT ADDRESS on…
Contract bytecode check
GET /api/contract-codeIs this address a contract, and what code does it hold? Returns isContract, deployed bytecode size, and the keccak-256 h…