This guide outlines the engineering standards and conventions to keep the codebase idiomatic, secure, and maintainable.
- Simplicity Over Inheritance: Prefer explicit composition and simple contract structures. Keep validation targets decoupled from application logic.
- Gas Optimization: Enable optimizer with
via_ir: truein production. - State Identifiers: Store session keys associated with
address(this). When executed viadelegatecallin an EIP-7702 context,address(this)represents the calling EOA, giving independent storage profiles to each delegator.
- Follow the official Solidity Style Guide.
- Standard layout for contract contents:
- Types & Structs
- Errors
- Events
- Mappings & State Variables
- Modifiers
- External Functions
- Public/Internal Functions
- Next.js App Router: Leverage Server Components for static/explanatory pages (
/and/explain), and use"use client"exclusively for interactive client elements (/demopage and UI controls). - TypeScript Strictness: Keep strict type safety. Avoid using
anytype casts. Use explicit type guards where appropriate. - Clean State Hooks: Consolidate state changes in components rather than threading state deeply across unrelated child containers.
- Aesthetic Consistency: Maintain a modern, dark-mode-first or theme-switching layout with clean typography and standardized spacing.
- shadcn/ui Guidelines: Keep UI primitives (like dialogs, alerts, progress bars) as neutral wrapper components, modifying their properties safely using class utilities like
cn(...). - CSS Formatting: Use Tailwind CSS utility classes inline. Do not mix with arbitrary styled-components or complex global overrides unless absolutely necessary.
- Zero-Friction User Flow: To eliminate browser extension dependency during testing, the interactive demo utilizes a preset private key configuration (
NEXT_PUBLIC_DEMO_PRIVATE_KEYin.env) with viem'sprivateKeyToAccountutility. - Educational UI Elements: Always display original byte formats alongside descriptive text to make cryptography and binary protocols clear for developers.