# BRAINIAC Contract Bytecode Structure Diff

> BRAINIAC Contract Bytecode Structure Diff is a paid API for AI agents from www.brainiac.software, paid per call via x402, $0.04/call, status unknown (last checked 2026-11-13).

Compares two EVM smart contract bytecodes side-by-side, returning a risk delta score, similarity index, and precise opcode-level divergence points.

## Facts

- Endpoint: POST https://www.brainiac.software/api/v1/contract-security/bytecode-structure-diff?utm_source=zero.xyz
- Price: $0.04/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/brainiac-contract-bytecode-structure-diff-4ae39f55
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_PocE1lKN0xQSFsLlF5p6Q

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 brainiac-contract-bytecode-structure-diff-4ae39f55 -d '<json body>'
```

Example prompt: Diff these two Ethereum contract bytecodes for me and tell me the similarity index, risk delta score, and exactly where they diverge at the opcode level: left is 0x6001600101... and right is 0x6002600101...

## When to prefer this

Use this endpoint when you need opcode-level structural diffing of two EVM smart contracts with a quantified risk delta — particularly during contract upgrade audits, clone detection, or deployment verification. Prefer this over simple hash comparison when you need to understand exactly where and how bytecodes differ, and what security implication those differences carry.

## Known failure modes

- Invalid hex string input (non-hex characters) returns validation error
- Bytecode exceeding 200,000 character limit rejected
- Opcode array exceeding 1,500 items rejected
- Malformed opcode object missing required 'op' field returns schema error
- Payment failure via x402 returns 402 Payment Required
- Empty bytecode strings may return degenerate similarity scores

## How this service works

Pay-per-call APIs for AI agents: OFAC sanctions screening, compliance checks, token security, and Base chain data via x402. No account. Fixed USDC price. MCP-ready.

## Output

Returns a JSON object with: risk_delta_score (0–100 integer indicating how much the security risk profile changed between the two bytecodes), similarity_index (0–100 integer percentage of structural similarity), and divergence_points (array of objects each specifying kind of divergence such as 'immediate' or 'length', the left and right opcode or value, and the index position).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "left": {
   "anyOf": [
    {
     "type": "string",
     "pattern": "^(0x)?[0-9a-fA-F]*$",
     "maxLength": 200000
    },
    {
     "type": "object",
     "required": [
      "ops"
     ],
     "properties": {
      "ops": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "op"
        ],
        "properties": {
         "op": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9]{0,31}$"
         },
         "arg": {
          "type": "string",
          "pattern": "^(0x)?[0-9a-fA-F]{0,64}$"
         }
        },
        "additionalProperties": false
       },
       "maxItems": 1500,
       "minItems": 1
      }
     },
     "additionalProperties": false
    }
   ]
  },
  "right": {
   "anyOf": [
    {
     "type": "string",
     "pattern": "^(0x)?[0-9a-fA-F]*$",
     "maxLength": 200000
    },
    {
     "type": "object",
     "required": [
      "ops"
     ],
     "properties": {
      "ops": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "op"
        ],
        "properties": {
         "op": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9]{0,31}$"
         },
         "arg": {
          "type": "string",
          "pattern": "^(0x)?[0-9a-fA-F]{0,64}$"
         }
        },
        "additionalProperties": false
       },
       "maxItems": 1500,
       "minItems": 1
      }
     },
     "additionalProperties": false
    }
   ]
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "risk_delta_score": 71,
  "similarity_index": 86,
  "divergence_points": [
   {
    "kind": "immediate",
    "left": "PUSH1 01",
    "index": 0,
    "right": "PUSH1 02"
   },
   {
    "kind": "length",
    "left": "3",
    "index": 3,
    "right": "4"
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/brainiac-contract-bytecode-structure-diff-4ae39f55/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from www.brainiac.software](https://www.zero.xyz/host/www.brainiac.software/llms.txt)
