{"uid":"cap_ijxhxe1l_dYUJQeoMJzoA","slug":"brainiac-storage-slot-grade-smart-contract-upgrade-safety-analyzer-0164cbc4","name":"BRAINIAC Storage Slot Grade — Smart Contract Upgrade Safety Analyzer","description":"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.","url":"https://www.brainiac.software/api/v1/crypto-security/storage-slot-grade?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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}}},"responseSchema":{"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}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.04","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.04/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.04","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.04","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_YMhCJaAu7B2ejTLwxj6In","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.04","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Proxy upgrade safety audit","prompt":"I'm about to push a new implementation for my UUPS proxy contract. The old layout has 'owner' at slot 0, 'paused' at slot 1, and 'totalSupply' at slot 2. The new layout moves 'paused' to slot 2 and adds 'feeRate' at slot 1. Can you grade whether this upgrade is safe or will it corrupt storage?"},{"title":"New variable insertion risk check","prompt":"We're adding a new state variable 'admin' between 'owner' at slot 0 and 'balance' at slot 1 in our upgradeable contract — that pushes 'balance' to slot 2 in the new version. What's the collision probability score and what upgrade safety grade does this get?"},{"title":"Pre-deployment storage collision scan","prompt":"Before we deploy our new ERC-20 implementation, can you compare the old storage layout (token at slot 0, allowances at slot 1, name at slot 2) against the new one (token at slot 0, name at slot 1, allowances at slot 2) and tell me if any variables shifted slots and how risky the upgrade is?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-13T18:43:04.640Z","isFirstParty":false,"canonicalSlug":"brainiac-storage-slot-grade-smart-contract-upgrade-safety-analyzer-0164cbc4"}