Contract bytecode check

$0.002 per call · USDC via x402 · GET /api/contract-code

Is this address a contract, and what code does it hold? Send GET /api/contract-code with the required field address and pay $0.002 per call over x402 or MPP (there is no free tier). It returns a JSON object with network, address, isContract, bytecodeBytes and keccak256.

Returns isContract, deployed bytecode size, and the keccak-256 hash of the bytecode (stable fingerprint for comparing deployments) on Ethereum, Base, Polygon, Arbitrum, or Optimism. Keyless multi-endpoint failover. ?address=0x…&network=base

Category: Crypto & onchain data · Tags: crypto contract bytecode code keccak verify rpc evm · Also found as: code eth_getcode

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
addressstringyesEVM address to check (0x…). Also accepted as addr, wallet, account.
networkstringnoethereum / base / polygon / arbitrum / optimism (default base).

Example request

curl -i "https://agent402.tools/api/contract-code?address=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&network=base"

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

Example response

{
  "network": "base",
  "address": "0x8335…",
  "isContract": true,
  "bytecodeBytes": 2148,
  "keccak256": "0x…"
}
FieldTypeAlways presentIn the example
networkstringyesbase
addressstringyes0x8335…
isContractbooleanyestrue
bytecodeBytesnumberyes2148
keccak256stringyes0x…

From an MCP client

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

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

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?.(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-code?address=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&network=base");

Related tools

Block info

$0.001 · GET /api/block-info

Header-level detail for one block on Ethereum, Base, Polygon, Arbitrum, or Optimism: hash, timestamp (unix + ISO), trans…

Latest block number

$0.001 · GET /api/block-number

The latest block number on Ethereum, Base, Polygon, Arbitrum, or Optimism: returns network, blockNumber (integer) and he…

Chain info snapshot

$0.001 · GET /api/chain-info

One-call chain state snapshot: chain id, latest block number, and current gas price (wei + gwei) for Ethereum, Base, Pol…

Contract storage slot

$0.001 · GET /api/chain/storage

Read one 32-byte storage slot from a contract, the raw state under whatever the source code calls it. Returns the word a…

Token price by contract address

$0.005 · GET /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 on…

Verified contract ABI (Sourcify)

$0.003 · POST /api/contract-abi

Fetch the verified ABI for a contract address from Sourcify, plus a ready-to-use list of human-readable function signatu…