"In Web3, traditional security 'gravity' doesn't exist. MamoruAI is the life-support system for your logic."
MamoruAI is an AI-driven smart contract security scanner designed for the Zero-Gravity Environment of decentralized finance. While traditional scanners assume ground-level protection with firewalls and centralized oversight, MamoruAI treats every line of code as if it's floating in the vacuum of spaceโwhere a single vulnerability can eject your entire capital into the void.
Most scanners assume a "Ground-Level" environment where firewalls and centralized oversight act as gravity. MamoruAI is built for the Zero-G Environment of decentralized finance. We treat every line of code as if it's floating in a vacuumโwhere there is no friction to stop a malicious actor once a leak begins.
We don't just check if the code works; we "depressurize" the contract. By injecting thousands of extreme, non-linear inputs, we simulate the "Antigravity" of a chaotic mainnet launch.
- Traditional Approach: "Does this function return the expected value?"
- MamoruAI Approach: "What happens when we call this function with max uint256, zero addresses, and reentrancy patterns simultaneously?"
In Zero-G, once an exploit starts, it has infinite inertiaโit cannot be stopped. MamoruAI uses LLM-orchestrated reasoning (Gemini 1.5 Pro) to predict the momentum of an exploit before it is even deployed.
- Static Analysis: Slither detects the vulnerability pattern
- AI Contextualization: Gemini explains the exploit chain in human language
- Preventive Patching: AI-generated Solidity refactoring suggestions
Our AI doesn't just suggest a fix; it generates a "hermetic seal"โrefactored Solidity code that is structurally sound enough to survive the harsh vacuum of permissionless execution.
Example:
// โ BEFORE: Vulnerable to Reentrancy (No Gravity)
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
msg.sender.call{value: amount}(""); // EXPLOIT VECTOR
balances[msg.sender] -= amount;
}
// โ
AFTER: Vacuum-Sealed (Checks-Effects-Interactions)
function withdraw(uint amount) public nonReentrant {
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount; // STATE UPDATE FIRST
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
}MamoruAI follows a decoupled microservices architecture with three core components:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Next.js UI โโโโโโโบโ Inngest Queue โโโโโโโบโ Python Engine โ
โ (Frontend) โ โ (Orchestration) โ โ (Slither + AI) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ PostgreSQL โ
โ (Persistence) โ
โโโโโโโโโโโโโโโโโโโ
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15, TypeScript, TailwindCSS | Modern Web3 UI with wallet connectivity |
| Analysis Engine | Python, FastAPI, Slither | Static analysis + AI-driven contextual explanations |
| Orchestration | Inngest | Background job processing, retry logic |
| Database | PostgreSQL + Prisma | Audit results persistence |
| Localization | next-intl | Bilingual support (EN/JA) |
For detailed architecture diagrams and flow charts, see docs/ARCHITECTURE.md.
| Feature | Traditional Scanner (Earth) | MamoruAI (Zero-G) |
|---|---|---|
| Logic Scoping | Static & Rigid | Dynamic & Multi-Dimensional |
| Error Feedback | "Line 42: Overflow" | "Line 42: AI-Detected Logic Leak. [Fix Here]" |
| Language Support | English Only | Bilingual (EN/JA) Global Support |
| Speed | Slow/Manual | 60s Automated "Deep-Space" Scan |
| Exploit Prediction | Pattern Matching | LLM-Powered Contextual Reasoning |
| Patch Generation | Manual Developer Work | AI-Generated Solidity Refactoring |
Don't just run a script; monitor the system.
- Structured Logging: Every scan generates a JSON-based trace log, compatible with ELK Stack or Datadog
- State Machines: The audit process is governed by a strict finite state machine (FSM), ensuring no scan is left in a "zombie" state during engine failures
enum AuditStatus {
PENDING โ "Scan queued, waiting for worker"
IN_PROGRESS โ "Slither running, AI reasoning"
COMPLETED โ "Results stored, ready for review"
FAILED โ "Engine error, retry logic triggered"
}-
Dockerized Isolation: The Python Analysis Engine runs in a hardened, scratch-based Docker container. This prevents "Audit Contamination" where one contract's logic could potentially affect the engine's next scan.
-
Redundant LLM Fallbacks: If the primary AI (Gemini) hits a rate limit, the system automatically fails over to GPT-4o or a local Llama 3 instance to ensure the security "life support" never goes offline.
Because MamoruAI targets the global Web3 market, the system is architected with i18n at the core:
- Bilingual Reports: Audit summaries are generated in both English and Japanese (ๅฎใAIใฌใใผใ), allowing seamless collaboration between international developer teams and Japanese security firms.
- Cultural Context: Japanese Web3 community represents 30%+ of global DeFi TVLโMamoruAI respects this by providing native language support.
MamoruAI/
โโโ frontend/ # Next.js 15 Web UI
โ โโโ src/
โ โ โโโ app/ # App Router pages
โ โ โโโ components/ # Reusable UI components
โ โ โโโ lib/ # Prisma client, utilities
โ โ โโโ messages/ # i18n translations (en.json, ja.json)
โ โโโ prisma/
โ โ โโโ schema.prisma # Database schema
โ โโโ package.json
โ
โโโ engine/ # Python Analysis Engine
โ โโโ main.py # FastAPI server
โ โโโ ai_service.py # Gemini 1.5 Pro integration
โ โโโ requirements.txt # Python dependencies
โ โโโ Dockerfile
โ
โโโ docs/
โ โโโ ARCHITECTURE.md # Detailed system design
โ
โโโ docker-compose.yml # Multi-container orchestration
- Docker Desktop installed and running (Download)
- API Keys (see below)
# Create .env file in project root
# Copy .env.example to .env and add your API keys
# Required API Keys:
GEMINI_API_KEY=your_gemini_api_key_here # Get from: https://makersuite.google.com/app/apikey
ETHERSCAN_API_KEY=your_etherscan_api_key_here # Get from: https://etherscan.io/apis (free tier works)
# Optional (for Inngest):
INNGEST_EVENT_KEY=
INNGEST_SIGNING_KEY=Option A: Using Docker Compose (Recommended)
# Start all services
docker compose up --build
# Or if you have older Docker Compose:
docker-compose up --build
# Run in background:
docker compose up --build -dOption B: Using Startup Script
- Windows: Run
start.bat - Linux/Mac: Run
./start.sh(make executable first:chmod +x start.sh)
After containers start, run database migrations:
cd frontend
npx prisma migrate dev --name init
npx prisma generate
cd ..- Frontend: http://localhost:3000
- Engine API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
- Navigate to
http://localhost:3000/dashboard - Enter a verified contract address (e.g.,
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) - Click "Trigger Security Audit"
- Wait 30-60 seconds for analysis to complete
- View detailed results with AI explanations
Check service status:
docker compose ps
# or
docker-compose psView logs:
docker compose logs -f
# View specific service:
docker compose logs -f engineRestart services:
docker compose restartStop services:
docker compose downFor more details, see RUN.md or QUICKSTART.md.
cd frontend
npm install
npm run devcd engine
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reloadcd frontend
npx prisma migrate dev --name init
npx prisma generate- Contract Submission โ User submits address via Web UI
- Inngest Trigger โ Background job queued
- Source Code Fetching โ Retrieve from Etherscan/Blockscout
- Slither Analysis โ Static analysis detects vulnerability patterns
- AI Contextualization โ Gemini 1.5 Pro explains exploits in natural language
- Result Persistence โ Store in PostgreSQL with structured JSON
- Real-Time Updates โ WebSocket/polling updates UI
- โ Reentrancy Detection via Slither's call graph analysis
- โ Access Control Flaws (missing modifiers, public state variables)
- โ Integer Overflow/Underflow (pre-Solidity 0.8.0)
- โ
Unchecked External Calls (low-level
.call()without success checks) - โ Gas Optimization opportunities
- โ AI-Powered Exploit Chains (multi-step vulnerability correlation)
MamoruAI supports bilingual audit reports:
// messages/en.json
{
"dashboard.title": "COMMAND CENTER",
"dashboard.subtitle": "Monitor and analyze smart contract security."
}
// messages/ja.json
{
"dashboard.title": "ใณใใณใใปใณใฟใผ",
"dashboard.subtitle": "ในใใผใใณใณใใฉใฏใใฎใปใญใฅใชใใฃใ็ฃ่ฆใปๅๆ"
}Switch languages via the UI or by setting the user's locale preference.
- Core engine with Slither integration
- AI-powered contextual explanations (Gemini 1.5 Pro)
- Etherscan source code fetching
- Database persistence for audit results
- Input validation and error handling
- Health check endpoints
- Dockerized deployment
- Basic test infrastructure
- Real-time WebSocket audit updates
- Formal verification integration (Certora/SMTChecker)
- Multi-chain support (Base, Arbitrum, Optimism - Ethereum supported)
- Public API for CI/CD integration
- Browser extension for instant contract scanning
- Comprehensive test coverage
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Slither by Trail of Bits for industry-standard static analysis
- Gemini 1.5 Pro by Google for advanced AI reasoning
- Inngest for reliable background job processing
- The Web3 Community for building in the Zero-G environment
- Project Maintainer: [suraj kumar]
- Email: surajnsg115@gmail.com
- Twitter: [@whotf_surajj] https://x.com/whotf_surajj
Built with suraj for the decentralized future. Stay safe in Zero-G. ๐