AI-Powered Smart Contract Security Platform — Multi-agent analysis pipeline using Xiaomi MiMo
ChainSentinel is a production-grade smart contract security audit platform that uses multiple specialized AI agents to perform comprehensive code analysis. Built on top of Xiaomi MiMo's reasoning models, it orchestrates a 4-stage analysis pipeline that naturally consumes millions of API tokens per day.
┌─────────────────────────────────────────────────────────┐
│ ChainSentinel │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ Vuln │ │ Gas │ │ Logic │ │ Report │ │
│ │ Scanner │ │ Optimizer│ │ Auditor │ │ Writer │ │
│ │ (Agent 1)│ │ (Agent 2)│ │ (Agent 3)│ │(Agent 4)│ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └───┬────┘ │
│ │ │ │ │ │
│ └──────────────┼──────────────┘ │ │
│ │ │ │
│ ┌──────▼──────┐ ┌──────▼────┐ │
│ │ Preprocess │ │ Synthesis │ │
│ │ & Chunking │ │ & Report │ │
│ └─────────────┘ └───────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐│
│ │ MiMo API (OpenAI-compatible) ││
│ │ Token Tracking & Budget Management ││
│ └─────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────┘
Each contract audit runs 4 specialized agents in sequence:
- Vulnerability Scanner: Reentrancy, overflow, access control, oracle manipulation
- Gas Optimizer: Storage layout, loop optimization, assembly opportunities
- Logic Auditor: MEV vectors, price manipulation, governance attacks
- Report Generator: Professional audit report with severity ratings
Contracts over 200 lines are split into overlapping chunks, analyzed independently by each agent, then synthesized. A 1000-line contract = 5 chunks × 4 agents = 20 API calls minimum.
The batch scanner processes multiple contracts in parallel, with configurable concurrency. Audit firms processing 10+ contracts daily easily hit 5M+ tokens.
The built-in AI assistant answers security questions with deep context, consuming tokens on every interaction.
| Scenario | Contracts | Chunks | Agents | Tokens/Day |
|---|---|---|---|---|
| Single audit | 1 | 2-3 | 4 | ~50K |
| Daily monitoring | 5 | 10-15 | 4 | ~300K |
| Audit firm workload | 10+ | 30+ | 4 | ~1.5M |
| Full pipeline (batch + QA) | 20+ | 60+ | 4+chat | ~5M+ |
cd backend
pip install -r requirements.txt
cp .env.example .env # Add your MiMo API key
uvicorn app.main:app --reload --port 8000cd frontend
# Serve with any static server
python -m http.server 3000
# Or deploy to Netlify/VercelMIMO_API_KEY=your_xiaomi_mimo_api_key
MIMO_BASE_URL=https://api.xiaomimimo.com/v1
MIMO_MODEL=mimo-v2.5-pro| Method | Endpoint | Description |
|---|---|---|
| POST | /api/analyze |
Single contract analysis |
| POST | /api/batch-analyze |
Batch contract scanning |
| POST | /api/upload |
Upload .sol file |
| POST | /api/chat |
Security Q&A |
| GET | /api/stats |
Token usage statistics |
| GET | /api/stats/history |
Usage history |
| GET | /api/stats/trend |
Daily usage trend |
- AI Model: Xiaomi MiMo v2.5 Pro (1.6B reasoning model)
- Backend: Python, FastAPI, OpenAI SDK
- Frontend: Vanilla JS, CSS3, Dark Theme
- API Protocol: OpenAI-compatible (works with Claude Code, Cursor, etc.)
- Token Management: Real-time tracking, budget enforcement, per-agent breakdown
ChainSentinel is designed to consume 5-10 million tokens daily through:
- Continuous contract monitoring — watching for new deployments on-chain
- Batch audit processing — parallel analysis of multiple contracts
- Deep analysis pipeline — 4 agents × multiple code chunks
- Interactive Q&A — developer security consultations
- Report generation — professional PDF-ready audit reports
MIT