AI-powered smart contract risk monitoring—decentralized by Chainlink CRE.
ChainGuard Sentinel is a monitoring and alerting system for already-deployed smart contracts. It detects market-based risks (depegs, volatility spikes, liquidity drops) using AI and Chainlink’s Runtime Environment (CRE), without requiring any change to your contract code.
Smart contract owners face ongoing risk after deployment: market moves, liquidity events, and oracle deviations can lead to liquidations, depegs, or exploits. Existing tools often:
- Rely on centralized dashboards or bots (single point of failure).
- Don’t orchestrate monitoring, AI analysis, and alerts in one decentralized flow.
- Require custom infra for multi-chain and high-frequency data.
ChainGuard Sentinel uses Chainlink CRE to run the full pipeline (EVM reads → market data → AI analysis → on-chain report) as a single decentralized workflow, so execution is tamper-resistant, verifiable, and scalable.
-
One-click risk analysis
You add a contract address; the app sends a request to a CRE consumer contract on Sepolia. A CRE workflow (EVM log trigger) picks up the event, reads contract state and market data, runs AI risk analysis, and writes the report back on-chain. The dashboard shows risk level, score, and summary without you running any backend. -
Automatic scanning at interval
The dashboard (or Vercel Cron in production) calls a trigger API at a configurable interval (e.g. every 30 seconds for testing, 15 minutes in production). That API sendsrequestRiskAnalysisfor every monitored contract. CRE (local listener or DON) runs the workflow and writes reports; the UI polls and updates “Last updated” so you can confirm the cron is working. -
Persistence and clarity
Contracts and analysis results are cached in the frontend; “Last updated” and relative timestamps are shown across the dashboard and contract pages so you can track when each contract was last analyzed. -
No backend required
The flow is: Frontend → Consumer contract (tx) → CRE workflow → Consumer contract (report). The Next.js app only talks to the chain and to its own API routes; the CRE workflow runs locally (cre workflow simulate) or on a Chainlink DON.
-
EVM log trigger
The CRE workflow is triggered by theRiskAnalysisRequestedevent emitted by the ChainGuardCREConsumer contract when a user (or the interval job) callsrequestRiskAnalysis(contractAddress, chainSelectorName). -
Blockchain + external systems
The workflow (in the chain-guard-cre repo):- Reads on-chain contract state (balances, tokens) via EVM.
- Fetches market data (e.g. Chainlink Data Feeds / price feeds) and can use OpenRouter/Gemini for AI risk analysis.
- Writes the risk report back on-chain via the consumer contract so the frontend can read it with
getAssessment(requestId).
-
Simulation and production
- Local: Run
npm run script:cre-listenerin this repo; it watches forRiskAnalysisRequestedand runscre workflow simulatein chain-guard-cre so the report is written to Sepolia. - Production: Deploy the same workflow to a Chainlink DON; the DON listens for the event and writes the report. No change to the frontend—only where the workflow runs.
- Local: Run
This satisfies the hackathon requirement: build/simulate/deploy a CRE workflow that integrates at least one blockchain with an external API, system, data source, or LLM, demonstrated via CRE CLI simulation or live DON deployment.
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, React, Tailwind, Vercel |
| Wallet / chain | Wagmi, viem, Sepolia |
| CRE integration | Consumer contract (Sepolia), EVM log trigger, on-chain report storage |
| Workflow runtime | chain-guard-cre (CRE CLI simulate or DON) |
| Contracts | chain-guard-smart-contract (ChainGuardRegistry, ChainGuardCREConsumer) |
Flow (high level):
User / Cron → Frontend → requestRiskAnalysis(tx) → Consumer contract
↓
RiskAnalysisRequested event
↓
CRE workflow (EVM trigger)
↓
EVM reads + feeds + AI → report
↓
Write report on consumer contract
↓
Frontend ← getAssessment(requestId) ← Consumer contract
As per the hackathon submission guidelines, here are the files in this repository that use or integrate with Chainlink (CRE consumer contract, CRE triggers, or Chainlink-related config):
| File | Purpose |
|---|---|
| lib/cre-consumer.ts | CRE consumer address, chain id, parseOnchainAssessment for reading reports |
| lib/cre-consumer-abi.ts | ABI for requestRiskAnalysis and getAssessment |
| hooks/use-cre-onchain.ts | useRequestCREAnalysis, useCREAssessment (wagmi/viem read contract) |
| app/api/cre/trigger-analysis/route.ts | Server-side: sends requestRiskAnalysis for all contracts (cron/interval) |
| app/api/cre/assessment/route.ts | Server-side: reads getAssessment(requestId) for polling |
| app/dashboard/analysis-context.tsx | Persists analysis state and polls CRE assessment |
| app/dashboard/contracts/[id]/page.tsx | Run Full Analysis UI, calls consumer, applies on-chain result |
| app/dashboard/page.tsx | Trigger-analysis at interval, persists requestIds, polls assessments |
| app/dashboard/contracts/page.tsx | Contract list and CRE-related UI |
| scripts/cre-evm-listener.mjs | Watches RiskAnalysisRequested, runs cre workflow simulate |
| scripts/run-full-analysis-flow.mjs | Script to run full flow (tx → poll getAssessment) |
| File | Purpose |
|---|---|
| app/api/cre/analyze/route.ts | Optional server-side analyze (pre-CRE + CRE simulate + post-CRE AI) |
| app/api/cre/analyze/stream/route.ts | Streaming analyze with CRE |
| app/api/cre/simulate/route.ts | CRE simulate API |
| app/api/cre/enrich/route.ts | Enrich CRE output with AI |
| app/api/cre/portfolio/route.ts | Portfolio/TVL using chain data |
| app/api/cron/scan/route.ts | Cron entrypoint; coordinates with trigger-analysis |
| lib/cre/run-discovery.ts | Contract discovery (EVM reads, optional AI naming) |
| lib/cre/feeds.ts | Chainlink price feed addresses |
| lib/cre/chainlink-prices.ts | Chainlink price feed usage |
| lib/cre/build-config.ts | Build CRE config from discovery |
| lib/cre/run-simulate.ts | Run CRE simulation |
| lib/cre/serverless-check.ts | CRE availability check in serverless |
| lib/cre/post-cre-ai.ts | Post-CRE AI step |
| lib/api.ts | applyOnchainAssessmentToContractStorage, CRE-related types |
| lib/storage.ts | Persists contracts and alerts; merge with CRE results |
| lib/email-templates/risk-alert.ts | Email alerts for risk events |
| File | Purpose |
|---|---|
| app/dashboard/scan-context.tsx | Scan context (legacy; trigger-analysis used for interval) |
| app/dashboard/alerts/page.tsx | Alerts feed (alerts may be driven by CRE results) |
| app/page.tsx | Landing; mentions CRE/Chainlink |
| components/web3-provider.tsx | Web3 config for wallet and chain (Sepolia for consumer) |
| vercel.json | Cron for /api/cre/trigger-analysis and /api/cron/scan |
The CRE workflow itself (EVM trigger, EVM reads, Chainlink feeds, AI, write report) lives in the chain-guard-cre repository.
- Node.js 18+
- A funded Sepolia wallet (for sending
requestRiskAnalysisand for CRE automation) - Chainlink CRE CLI installed (for local listener)
cp .env.local.example .env.localEdit .env.local and set at least:
NEXT_PUBLIC_CHAINGUARD_CRE_CONSUMER_ADDRESS– consumer contract (from chain-guard-smart-contract deploy)NEXT_PUBLIC_CRE_CONSUMER_CHAIN_ID=11155111NEXT_PUBLIC_SEPOLIA_RPC_URLorALCHEMY_API_KEY– for Sepolia RPCCRE_AUTOMATION_PRIVATE_KEYorCRE_REQUEST_PRIVATE_KEY– for interval-triggered analysis (optional; omit to use only manual “Run Full Analysis”)
npm install
npm run devOpen http://localhost:3000, connect your wallet (Sepolia), and add a contract.
So that “Run Full Analysis” actually runs the workflow and writes the report on-chain:
npm run script:cre-listenerKeep this running in a separate terminal. It watches for RiskAnalysisRequested on the consumer contract and runs cre workflow simulate in the chain-guard-cre repo (clone it next to chain-guard or set CRE_PROJECT_PATH). Configure chain-guard-cre with Alchemy RPC and OpenRouter/Gemini (see chain-guard-cre README).
In .env.local:
NEXT_PUBLIC_CHAIN_GUARD_SCAN_INTERVAL_MS=30000With the dashboard open, the app will call the trigger-analysis API every 30s and the listener will process each request. “Last updated” on each contract card updates when the report is written and the frontend poller applies it.
- The first scan runs a few seconds after the dashboard loads; subsequent runs use the interval (default 15 minutes).
- Production: Deploy the CRE workflow to a Chainlink DON and set
CRE_AUTOMATION_PRIVATE_KEY(orCRE_REQUEST_PRIVATE_KEY) in Vercel. Use Vercel Cron (seevercel.json) to hit/api/cre/trigger-analysison a schedule (e.g. every 15 minutes). No backend in the Next.js app—only the consumer contract and the DON.
- chain-guard-cre – CRE workflow (EVM log trigger, EVM reads, Chainlink feeds, AI, on-chain report).
- chain-guard-smart-contract – ChainGuardRegistry and ChainGuardCREConsumer (Sepolia).
Replace Sobilo34 with your GitHub username or organization in the links above.
MIT.