Skip to main content
Glama
0xConsole
by 0xConsole
README.md
# Flare Bridge Sentinel

**Autonomous AI agent monitoring Flare's interoperable asset ecosystem β€” FAssets, FTSOv2, cross-chain bridges β€” with 8 MCP tools and real Coston2 testnet integration.**

## 🎯 Problem

Flare's interoperability layer (FAssets, FTSO) unlocks DeFi for non-native assets like XRP. But monitoring this infrastructure requires watching multiple on-chain data sources, oracle price feeds, and bridge states in real time. No tool exists that autonomously monitors the health and risk of Flare's interoperable asset ecosystem.

## βœ… Solution

**Flare Bridge Sentinel** is an autonomous AI agent that:

1. **Perceives** β€” Pulls live data from Flare Coston2 testnet RPC: chain status, FTSOv2 oracle prices, FAsset (FXRP) bridge state, FlareContractRegistry
2. **Analyzes** β€” Runs anomaly detection heuristics on price feeds, bridge supply, gas prices, and RPC latency
3. **Scores** β€” Computes a composite 0-100 risk score from anomaly severity, feed health, and FAsset collateralization
4. **Alerts** β€” Generates severity-classified alerts with human-readable summaries and recommended actions
5. **Audits** β€” Records every scan, anomaly, and alert in a persistent audit trail

## πŸ† Unique Angle

> Unlike generic blockchain monitors, Flare Bridge Sentinel is built specifically for Flare's interoperability layer β€” querying FTSOv2 oracle price feeds, FAsset (FXRP) bridge supply, and the FlareContractRegistry through 8 MCP-style tools that AI agents can call autonomously.

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   AI Agent   │────▢│  MCP Protocol    │────▢│  Flare Bridge Sentinel       β”‚
β”‚ (orchestrator)β”‚     β”‚  (8 tools)       β”‚     β”‚  FastAPI + Vercel Serverless β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                            β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚                                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Flare Coston2 RPC  β”‚              β”‚   SQLite Audit Trail       β”‚
                    β”‚  (chainId 114)      β”‚              β”‚   (scans, anomalies,       β”‚
                    β”‚                     β”‚              β”‚    alerts, FTSO snapshots) β”‚
                    β”‚  β€’ FTSOv2 Oracle    β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚  β€’ FAsset (FXRP)    β”‚
                    β”‚  β€’ ContractRegistry β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ”§ MCP Tools (8)

| # | Tool | Description |
|---|------|-------------|
| 1 | `get_chain_status` | Live Flare Coston2 chain metadata (chainId, block, gas) |
| 2 | `get_ftso_prices` | Real FTSOv2 oracle prices (FLR, BTC, ETH, XRP, DOGE) |
| 3 | `monitor_fasset` | FAsset FXRP bridge state (supply, decimals, manager) |
| 4 | `get_registry_contracts` | FlareContractRegistry β€” all 69 protocol contracts |
| 5 | `detect_anomaly` | Heuristic anomaly detection on price feeds + bridge |
| 6 | `calculate_risk_score` | Composite 0-100 risk score |
| 7 | `generate_alert` | Severity-classified alert with recommendations |
| 8 | `get_audit_trail` | Persistent audit trail of past scans |

## πŸ“‘ Real On-Chain Data (Verified Live)

All data is **real** from Flare Coston2 testnet β€” no mocks:

| Source | Contract | Verified |
|--------|----------|----------|
| Flare Coston2 RPC | `https://coston2-api.flare.network/ext/C/rpc` | chainId=114, block ~34M |
| FTSOv2 Price Feeds | `0xc4e9c78ea53db782e28f28fdf80baf59336b304d` | FLR=$0.006, BTC=$63.5K, ETH=$1.88K, XRP=$1.02, DOGE=$0.072 |
| FAsset FXRP Token | `0x0b6A3645d3a4885Bdb64717E2CE3B565Ea83c474` | totalSupply=6,142,098 FXRP, decimals=6 |
| AssetManager FXRP | `0xc1ca88b9351D99986685920141687403d01E33dB` | fAsset() β†’ FXRP token address |
| FlareContractRegistry | `0xaD67FE6610c43C95d9c02f4E5a44B5befB02cD69` | getAllContracts() β†’ 69 contracts |

## πŸš€ Setup (<5 commands)

```bash
git clone https://github.com/0xConsole/flare-bridge-sentinel.git
cd flare-bridge-sentinel
pip install -r requirements.txt
uvicorn app.main:app --reload
# Open http://localhost:8000
```

## 🌐 Live Demo

- **Demo URL:** https://flare-bridge-sentinel.vercel.app
- **GitHub:** https://github.com/0xConsole/flare-bridge-sentinel
- **Health check:** `/api/health` β€” chain status + RPC connectivity
- **Autonomous sweep:** `/api/demo` β€” full 6-step agent run
- **MCP tools:** `/mcp/tools` β€” list all 8 tools | `/mcp/call?tool=get_ftso_prices` β€” call any tool

## πŸ› οΈ Tech Stack

- **Python 3.12** + **FastAPI**
- **Flare Coston2 testnet** (public RPC, chainId 114)
- **FTSOv2** (Flare Time Series Oracle) β€” real decentralized price feeds
- **FAsset FXRP** β€” real XRP bridge token on Coston2
- **FlareContractRegistry** β€” canonical protocol contract registry
- **SQLite** (audit trail persistence)
- **Vercel** serverless (free tier)
- Static HTML/CSS/JS dashboard (dark theme, no framework)

## πŸ“‹ What's Real vs What's Next

| Component | Status |
|-----------|--------|
| Flare Coston2 RPC | βœ… Real (live block data) |
| FTSOv2 price feeds | βœ… Real (live oracle prices) |
| FAsset FXRP monitoring | βœ… Real (live token supply) |
| FlareContractRegistry | βœ… Real (live contract resolution) |
| Anomaly detection | βœ… Real (heuristic on live data) |
| Risk scoring | βœ… Real (computed from live anomalies) |
| Audit trail | βœ… Real (SQLite persistence) |
| LLM agent reasoning | πŸ”„ Rule-based orchestration (LLM-ready: swap agent.py loop for Gemini/GPT) |
| Mainnet deployment | πŸ“‹ Next step (Coston2 β†’ Songbird β†’ Flare Mainnet) |

## 🎯 Bounty Target

**Bounty 1: Interoperable Asset Products** β€” Flare Bridge Sentinel monitors the interoperability infrastructure (FAssets, FTSO) that enables DeFi for non-native assets. It directly addresses the "interoperable asset products" focus area by monitoring the health and risk of Flare's cross-chain asset bridge.

## πŸ“œ License

Apache 2.0

## πŸ”— Links

- **Flare Developer Docs:** https://dev.flare.network/
- **Flare Summer Signal Hackathon:** https://dorahacks.io/hackathon/flaresummersignal
- **MCP Protocol:** https://modelcontextprotocol.io