Diamond Pattern Contract Explainer
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Diamond Pattern Contract Explainer is a read-only tool that analyzes diamond pattern contracts (EIP-2535), generating AI-powered plain-language explanations of their structure and risks. It reads diamond proxy contract address, facet addresses, function selectors, facet mapping, diamond storage layout, diamond loupe functions, implementation bytecode, contract cut events, upgrade history, diamond ownership, privileged function signatures, contract creation block, transaction history, event logs, and immutable state variables. The tool then presents this data alongside an AI-generated analysis of the diamond's structure including facets, function selectors, and storage layout, identifying potential risks such as selector conflicts, missing facets, or storage collisions, and recommending best practices — helping you understand the contract's architecture before interacting with or relying on it.
HOW TO USE
Connect your wallet using the BGWallet bridge and select your target network. Enter the diamond proxy contract address you want to analyze. Click "Analyze diamond pattern" to read on-chain contract data. The tool displays the diamond address, owner, number of facets, total selectors, and upgrade risk level (Low/Medium/High). Detailed information includes facet list, function selectors, selector conflicts, missing facets, storage layout, diamond loupe availability, upgrade history, privileged functions, and immutable state. A recommended best practices box provides specific guidance. An AI explanation appears below the on-chain data, analyzing the diamond pattern contract structure including facets, function selectors, and storage layout, identifying potential risks such as selector conflicts, missing facets, or storage collisions, and recommending best practices before you interact with or rely on the diamond contract. The wallet's own signature step still protects you — this explanation is informational only and does not replace reviewing what you approve in your wallet.
TECHNICAL MECHANISM
The tool uses ethers.js v5.7.2 with the provider from the BGWallet bridge to read on-chain contract data. No hardcoded contract addresses are used — you are always in control of which contract you trust. When analyzing diamond pattern contracts, the tool reads the diamond proxy contract address from the user input, reads facet addresses via the diamond's facet loupe functions (e.g., facets(), facetAddresses()), reads function selectors via the diamond loupe (e.g., facetFunctionSelectors()), reads facet mapping by analyzing the diamond's storage, reads diamond storage layout by analyzing the contract's storage slots, reads diamond loupe functions by checking for standard loupe interfaces (IDiamondLoupe), reads implementation bytecode via provider.getCode(facet), reads contract cut events via event logs (e.g., DiamondCut), reads upgrade history by scanning event logs, reads diamond ownership via the diamond's owner() function or storage slot, reads privileged function signatures by analyzing function selectors, reads contract creation block via provider.getTransactionReceipt(diamond), reads transaction history via provider.getTransactionCount(diamond), reads event logs by scanning for diamond-related events, and reads immutable state variables by analyzing storage. The tool fetches event logs by walking backwards in chunks and halving chunk size on failure, ensuring logs are properly read despite varying RPC limitations. The data is formatted and passed to the AI bridge via BGAI.generate() with a structured prompt that includes all the on-chain data read. The AI is instructed to analyze the diamond pattern contract structure including facets, function selectors, and storage layout, identify potential risks such as selector conflicts, missing facets, or storage collisions, and recommend best practices — while stating plainly that it cannot detect facet conflicts or selector collisions that exist in off-chain code but are not yet deployed, cannot guarantee that the diamond's storage layout will remain compatible across future facet upgrades, and cannot detect malicious intent in facet implementations beyond bytecode analysis. The AI response is capped at 1,024 tokens to ensure concise, focused diamond pattern assessments. All computed values are guarded against negative numbers — if a facet count or selector count appears invalid, the tool flags it rather than displaying nonsensical values.
WHAT IT CANNOT SEE
This tool cannot detect facet conflicts or selector collisions that exist in off-chain code but are not yet deployed. It cannot guarantee that the diamond's storage layout will remain compatible across future facet upgrades. It cannot detect malicious intent in facet implementations beyond bytecode analysis. It cannot detect off-chain social engineering attacks or governance manipulation. The AI explanation is generated from on-chain data only and cannot detect off-chain facet code, hidden selector conflicts, or social engineering attacks. It cannot predict whether a future facet upgrade will introduce storage collisions. The tool does not continuously monitor diamond contracts; each analysis is a snapshot at the time of the lookup. It cannot detect delayed upgrades, hidden facets, or off-chain factors. The tool does not store any data persistently; all state is in-memory and resets on reload. The AI explanation is informational and does not constitute financial advice, legal advice, or a guarantee of contract safety or diamond pattern correctness.
PLEASE NOTE
Diamond Pattern Contract Explainer works exclusively with EVM-compatible chains. It requires a Web3 wallet (MetaMask or similar) and the BGWallet bridge. Explanations are AI-generated from data the app reads on-chain — always review what you are actually signing in your wallet before approving it. Diamond pattern contracts carry significant risk including selector conflicts, storage collisions, and malicious facet upgrades. Use this tool as a guide only; always cross-check with independent sources and contract audits for critical decisions. This is experimental software; use at your own risk.