{"uid":"cap_NxP-VVBLa5JpFv5wI4BjD","slug":"brainiac-contract-bytecode-compare-6d3e46ae","name":"BRAINIAC Contract Bytecode Compare","description":"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.","url":"https://www.brainiac.software/api/v1/contract-security/contract-bytecode-compare?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"mode":{"enum":["exact","normalized"],"type":"string"},"candidate":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$","maxLength":262146},"reference":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$","maxLength":262146},"bytecodeKind":{"enum":["runtime","creation"],"type":"string"},"immutableRanges":{"type":"array","items":{"type":"object","required":["start","end"],"properties":{"end":{"type":"integer","maximum":131072,"exclusiveMinimum":0},"start":{"type":"integer","maximum":131072,"minimum":0}},"additionalProperties":false},"maxItems":32},"compilerMetadata":{"type":"object","properties":{"version":{"type":"string","maxLength":40,"minLength":1},"compiler":{"type":"string","maxLength":80,"minLength":1}},"additionalProperties":false},"expectedDifferences":{"type":"array","items":{"type":"object","required":["start","end"],"properties":{"end":{"type":"integer","maximum":131072,"exclusiveMinimum":0},"start":{"type":"integer","maximum":131072,"minimum":0}},"additionalProperties":false},"maxItems":32},"constructorArguments":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$","maxLength":262146}}},"responseSchema":{"type":"json","example":{"findings":[{"code":"immutable_ranges_masked","detail":"The supplied immutable ranges were masked before the byte comparison.","severity":"low"},{"code":"difference_expected","detail":"The changed bytes at 1:2 fall inside expectedDifferences.","severity":"low"},{"code":"bytecode_differs","detail":"1 unmasked byte ranges differ. A difference is not a judgment that either contract is malicious.","severity":"medium"},{"code":"metadata_differs","detail":"The identified compiler metadata differs. This is not a source-code verification.","severity":"medium"},{"code":"comparison_normalized","detail":"Normalized comparison masked only the supplied immutable ranges and a compiler metadata suffix when that suffix was identified on both bytecodes.","severity":"low"}],"similarity":"80.0000","limitations":["Hashes are keccak256 of the supplied bytes before any masking.","Similarity is the share of equal compared bytes, truncated to 4 decimal places with integer division. Masked bytes are left out of the count.","A high similarity does not mean the contracts behave the same way.","A difference is not a judgment that either bytecode is malicious.","No source code was verified. Compiler metadata in the request is not a source match.","Normalization masks only caller-supplied immutable ranges and a trailing compiler metadata suffix when bytecodeKind is not creation and the Solidity CBOR pattern is present on both bytecodes.","Other bytecode is not removed. Creation bytecode is not split into init code and runtime code.","Constructor arguments are checked as a suffix only when bytecodeKind is creation and the arguments are supplied.","No chain state was read, and neither bytecode was executed."],"candidate_hash":"0xa39f1cb59ec90edd47f46c666deb79f2aef5e485023e84f1586a677d13ff88a0","reference_hash":"0xc8a324f6d1a8d63a729defc4c20b624f17d7dae1fdf4b5eec5f7c03a54a8da45","candidate_length":60,"reference_length":60,"comparison_status":"different","difference_ranges":[{"end":2,"kind":"changed","start":1,"length":1}],"metadata_differences":[{"field":"metadata","detail":"The compiler metadata suffixes differ.","candidate":"0xa2646970667358220000000000000000000000000000000000000000000000000000000000000000000264736f6c634300081a0033","reference":"0xa2646970667358220000000000000000000000000000000000000000000000000000000000000000000164736f6c63430008180033"},{"field":"solc","detail":"The metadata suffixes encode different Solidity versions. This is not a source-code verification.","candidate":"0.8.26","reference":"0.8.24"},{"field":"compiler","detail":"compilerMetadata.version is 0.8.24. The suffixes encode 0.8.24 and 0.8.26. This was not checked against source code.","candidate":"0.8.26","reference":"0.8.24"}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","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.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_3H8mDhdcFU1Df9HTr0sYj","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Compares two EVM contract bytecodes byte-by-byte, returning a similarity score and structured difference findings with optional normalization for immutables and compiler metadata.","exampleAgentPrompt":"Compare these two contract bytecodes for me and tell me how similar they are — the reference is 0xabc123... and the candidate I want to audit is 0xdef456... ; use normalized mode on runtime bytecode and mask the immutable range from byte 10 to 20.","exampleUseCases":[{"title":"Audit deployed contract against source","prompt":"I want to verify that the contract deployed at address X matches the reference bytecode I compiled — here's the reference hex 0xREF... and the candidate runtime bytecode 0xCAND... , compare them in normalized mode and flag any unexpected differences."},{"title":"Detect contract swap or tampering","prompt":"Someone may have swapped the contract on-chain — compare the original reference bytecode 0xORIG... against what's deployed 0xDEPL... using exact mode on runtime bytecode and tell me if there are any differing byte ranges."},{"title":"Verify proxy implementation upgrade","prompt":"We just upgraded our proxy's implementation contract — take the old implementation runtime bytecode 0xOLD... as the reference and the new one 0xNEW... as the candidate, run a normalized comparison masking immutable ranges at offsets 50-70 and 200-220, and show me the similarity score and all findings."}],"resultDescription":"Returns a JSON object with: a similarity percentage (truncated to 4 decimal places), a comparison_status (e.g. 'identical' or 'different'), an array of findings (each with a code, detail, and severity), difference_ranges listing byte offsets that differ, keccak256 hashes of both inputs before masking, byte lengths of both inputs, and a limitations array explaining the caveats of the analysis.","failureModes":["Invalid hex bytecode format (must match ^0x([0-9a-fA-F]{2})*$) returns 400","Bytecode exceeding 131072 bytes (262146 hex chars) is rejected","Immutable or expected-difference ranges with end <= start or values out of bounds return validation errors","Unsupported mode or bytecodeKind enum values return 400","Payment not received or insufficient USDC causes 402 response before processing","Empty or missing candidate/reference fields cause schema validation failure"],"whenToPreferThis":"Use this endpoint when you need a programmatic, byte-level similarity and difference analysis between two EVM contract bytecodes — especially when you want to mask compiler metadata suffixes or immutable value slots for a fair comparison. It is preferable to manual diffing tools when working in an agentic pipeline that needs structured findings and severity codes. It does not perform source-code verification or fetch bytecode from chain — use it after you have already retrieved the raw hex bytecodes.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-13T18:48:25.749Z","isFirstParty":false,"canonicalSlug":"brainiac-contract-bytecode-compare-6d3e46ae"}