# BRAINIAC Storage Slot Grade — Smart Contract Upgrade Safety Analyzer

> BRAINIAC Storage Slot Grade — Smart Contract Upgrade Safety Analyzer 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).

Analyzes smart contract storage layout changes between two versions and grades upgrade safety, detecting slot collisions and variable shifts that could corrupt on-chain state.

## Facts

- Endpoint: POST https://www.brainiac.software/api/v1/crypto-security/storage-slot-grade?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-storage-slot-grade-smart-contract-upgrade-safety-analyzer-0164cbc4
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_ijxhxe1l_dYUJQeoMJzoA

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-storage-slot-grade-smart-contract-upgrade-safety-analyzer-0164cbc4 -d '<json body>'
```

Example prompt: Can you grade the upgrade safety of my smart contract? The previous layout has 'owner' at slot 0 (size 20), 'balance' at slot 1 (size 32), and the new layout has 'owner' at slot 1 (size 20), 'balance' at slot 2 (size 32) — I need to know if any variables shifted and what the collision risk score looks like.

## When to prefer this

Use this endpoint when you need an automated, scored safety assessment of a smart contract storage layout change before deploying an upgrade — particularly for proxy patterns (UUPS, Transparent Proxy, Beacon) where storage collisions can silently corrupt state. Prefer this over manual review when you have structured slot layout data and need a machine-readable grade and delta report. It is especially valuable in CI/CD pipelines for upgradeable contract projects. At $0.04 USDC per call with no account required, it is well-suited for one-off audits or agent-driven pre-deployment checks.

## Known failure modes

- Invalid variable name format (must match ^[A-Za-z_][A-Za-z0-9_]{0,79}$) returns validation error
- Slot index out of range (must be 0–1,000,000) returns schema error
- Size out of range (must be 1–32 bytes) returns validation error
- Offset out of range (must be 0–31) returns validation error
- Empty or missing 'previous' or 'next' arrays returns bad request
- More than 400 variables in either array returns payload too large error
- Payment failure via x402 (insufficient USDC balance on Base) returns 402 Payment Required

## How this service works

Compare two caller-supplied storage layouts by slot, offset, and size. A name that moves is a shift. Different names that occupy the same bytes are a collision. The grade and the collision score come from those counts. A variable is one slice of a single slot. No chain is queried.

## Output

Returns a JSON object with: (1) upgrade_safety_grade — a letter grade (e.g. 'F') summarizing overall upgrade safety risk; (2) collision_probability_score — an integer 0–100 representing likelihood of storage collisions; (3) slot_shift_delta — an array of objects listing each variable that changed slot or offset, including its name, from_slot, to_slot, from_offset, and to_offset.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "next": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "name",
     "slot"
    ],
    "properties": {
     "name": {
      "type": "string",
      "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,79}$"
     },
     "size": {
      "type": "integer",
      "maximum": 32,
      "minimum": 1
     },
     "slot": {
      "type": "integer",
      "maximum": 1000000,
      "minimum": 0
     },
     "offset": {
      "type": "integer",
      "maximum": 31,
      "minimum": 0
     }
    },
    "additionalProperties": false
   },
   "maxItems": 400,
   "minItems": 1
  },
  "previous": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "name",
     "slot"
    ],
    "properties": {
     "name": {
      "type": "string",
      "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,79}$"
     },
     "size": {
      "type": "integer",
      "maximum": 32,
      "minimum": 1
     },
     "slot": {
      "type": "integer",
      "maximum": 1000000,
      "minimum": 0
     },
     "offset": {
      "type": "integer",
      "maximum": 31,
      "minimum": 0
     }
    },
    "additionalProperties": false
   },
   "maxItems": 400,
   "minItems": 1
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "status": "partial",
  "result_id": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
  "received_at": "2026-11-12T12:00:00.000Z",
  "missing_items": [
   {
    "check": "chain_state_not_read",
    "detail": "No chain state was read. This response is local static analysis only.",
    "reason": "not_supported"
   }
  ],
  "slot_shift_delta": [
   {
    "name": "owner",
    "to_slot": 2,
    "from_slot": 1,
    "to_offset": 0,
    "from_offset": 0
   }
  ],
  "upgrade_safety_grade": "F",
  "collision_probability_score": 55
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/brainiac-storage-slot-grade-smart-contract-upgrade-safety-analyzer-0164cbc4/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)
