# OneSource Ethereum Contract Bytecode Retrieval

> OneSource Ethereum Contract Bytecode Retrieval is a paid API for AI agents from api.onesource.io, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-12).

Fetches the deployed bytecode and contract metadata for an Ethereum address on mainnet or Sepolia testnet

## Facts

- Endpoint: GET https://api.onesource.io/api/chain/code/%7Baddress%7D
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onesource-ethereum-contract-bytecode-retrieval-0f4a7263
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_X5eucPkVQNMy8yaBdRS50

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability onesource-ethereum-contract-bytecode-retrieval-0f4a7263
```

Example prompt: Can you fetch the deployed bytecode for the contract at 0xdAC17F958D2ee523a2206206994597C13D831ec7 on Ethereum mainnet and tell me the bytecode size and whether it's actually a contract?

## When to prefer this

Use this endpoint when you need to retrieve raw EVM bytecode or confirm whether an Ethereum address has code deployed (is a smart contract vs. an EOA). Prefer this over full RPC node calls when you want a simple pay-per-call REST interface without managing API keys or node infrastructure. Ideal for agents performing contract analysis, decompilation prep, or quick contract-vs-wallet checks on mainnet or Sepolia.

## Known failure modes

- Invalid address format (non-0x or wrong length) returns a 400 validation error
- Address is an EOA with no deployed code — returns is_contract: false and empty bytecode
- Unsupported network value returns a 400 error
- Payment not provided or insufficient — returns HTTP 402 requiring USDC payment via x402 or MPP
- Node unavailable or chain congestion may result in 503 or timeout
- Sepolia testnet address queried against mainnet returns empty bytecode

## How this service works

Two data families for AI agents: live Ethereum mainnet, Sepolia testnet, and Robinhood Chain RPC reads, plus Deepstate on-chain market data (order books, trades, candles, and analytics). Pay per call or use batch/session mode: USDC on Base via x402, or pathUSD/USDC.e on Tempo via MPP. No API key required to start; a flat-rate monthly subscription is also available.

## Output

Returns a JSON object with the full hex bytecode string, the queried address, a boolean indicating whether the address is a smart contract, and the bytecode size in bytes

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "pathParams": {
     "type": "object",
     "required": [
      "address"
     ],
     "properties": {
      "address": {
       "type": "string",
       "pattern": "^0x[a-fA-F0-9]{40}$"
      }
     }
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "network": {
       "enum": [
        "ethereum",
        "sepolia",
        "robinhood"
       ],
       "type": "string",
       "default": "ethereum"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "required": [
      "data",
      "meta"
     ],
     "properties": {
      "data": {
       "type": "object",
       "properties": {
        "code": {
         "type": "string"
        },
        "address": {
         "type": "string"
        },
        "code_length": {
         "type": "integer"
        },
        "is_contract": {
         "type": "boolean"
        }
       },
       "description": "Endpoint-specific response payload"
      },
      "meta": {
       "type": "object",
       "required": [
        "endpoint",
        "request_id"
       ],
       "properties": {
        "endpoint": {
         "type": "string"
        },
        "cost_usdc": {
         "type": "string"
        },
        "request_id": {
         "type": "string"
        },
        "payment_chain": {
         "type": "string"
        },
        "payment_token": {
         "type": "string"
        }
       }
      },
      "error": {
       "type": [
        "object",
        "null"
       ],
       "properties": {
        "code": {
         "type": "integer"
        },
        "message": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": {
   "code": "0x6080604052600436106101...",
   "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
   "code_length": 10234,
   "is_contract": true
  },
  "meta": {
   "endpoint": "/api/chain/code/{address}",
   "cost_usdc": "0.001",
   "request_id": "00000000abcdef01",
   "payment_chain": "base",
   "payment_token": "USDC"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onesource-ethereum-contract-bytecode-retrieval-0f4a7263/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.onesource.io](https://www.zero.xyz/host/api.onesource.io/llms.txt)
