ClawGuard is an autonomous AI-powered blockchain risk monitor for NEAR Protocol and XRP Ledger. It runs a 30-second monitoring cycle, analyzes live blockchain stats with OpenAI, fires Telegram alerts for elevated risk, and logs alerts immutably on-chain to the XRP Ledger.
- Monorepo tool: pnpm workspaces
- Node.js version: 24
- Package manager: pnpm
- TypeScript version: 5.9
- API framework: Express 5
- Database: PostgreSQL + Drizzle ORM
- Validation: Zod (
zod/v4),drizzle-zod - API codegen: Orval (from OpenAPI spec)
- Build: esbuild (CJS bundle)
- AI: Replit AI Integrations (OpenAI gpt-5.1) — no API key required
- Blockchain: xrpl.js (XRPL), NEAR JSON-RPC (NEAR Protocol)
- Alerts: Telegram Bot API
- Frontend: React + Vite + TailwindCSS + shadcn/ui
nearStats.ts— fetches live NEAR block height, validators, gas price, stakexrplStats.ts— fetches live XRPL ledger index, base fee, server state, load factoropenclawReasoner.ts— AI risk analysis (LOW/MEDIUM/HIGH) using OpenAItelegramAlert.ts— sends Telegram alerts for MEDIUM/HIGH riskxrplLogger.ts— writes immutable on-chain memo to XRP Ledger for MEDIUM/HIGH riskmonitorService.ts— orchestrates 30-second cycles, persists alerts to DB
/— Dashboard: live risk level, summary stats, recent alerts/alerts— Full alert history, filterable by risk level/stats— Live NEAR and XRPL blockchain metrics, auto-refreshes
GET /status— current monitor state and risk levelGET /alerts— paginated alert historyGET /stats— live blockchain stats (cached 25s)POST /trigger— manually trigger a monitoring cycleGET /summary— aggregated risk distribution stats
pnpm run typecheck— full typecheck across all packagespnpm run build— typecheck + build all packagespnpm --filter @workspace/api-spec run codegen— regenerate API hooks and Zod schemaspnpm --filter @workspace/db run push— push DB schema changes (dev only)
TELEGRAM_BOT_TOKEN— from @BotFather on TelegramTELEGRAM_CHAT_ID— your Telegram chat IDXRPL_SECRET— XRPL wallet secret (testnet from xrpl.org/resources/dev-tools/xrp-faucets)XRPL_ADDRESS— XRPL wallet address (testnet)NEAR_ACCOUNT_ID— NEAR testnet account ID
- The monitor runs automatically on server start — no manual activation needed
- Telegram and XRPL on-chain logging are gracefully skipped if secrets are not configured
- AI analysis uses Replit's built-in OpenAI integration (charged to Replit credits, no key needed)
- NEAR uses testnet RPC; XRPL uses altnet (testnet)