Give AI a wallet without giving it the keys to everything.
Sentinel is a security middleware that sits between any AI agent and its wallet on NEAR. Before an agent sends funds, the layer checks:
- Policy Engine — spending limits, allowed recipients, daily caps, human approval thresholds
- Counterparty Check — scores the receiver (account age, contract status, blocklist, AI risk analysis) → returns allow/warn/block
- Audit Trail — logs every payment attempt with full evidence and TEE attestation
- Prompt Injection Defense — blocks malicious prompts from tricking the agent into paying bad addresses
AI agents that hold crypto wallets can be tricked into sending funds to attackers via prompt injection, phishing, or compromised instructions. There is no standard security layer that gates agent payments before signing. Sentinel provides that layer.
- Uses NEAR RPC (testnet) to query account info, contract status, and balance for counterparty scoring
- Designed for function-call access keys: agents sign with keys scoped to one contract, never full-access keys
- Function-call keys can't transfer NEAR or add keys, and lock themselves out if gas runs out — the agent gets money but not the keys
- TEE attestation verifies policy engine integrity
- Shared blocklist for cross-agent reputation
- OpenRouter (free models) powers AI risk analysis for each payment
- The AI scores counterparty risk (0-100) and provides human-readable reasons
- Prompt injection demo shows AI-powered defense: a malicious prompt tries to make the agent pay a known scammer, and the security layer blocks it
NEAR Hackathon — AI Security & Defense (security)
- Backend: FastAPI + Python
- Frontend: Vanilla HTML/CSS/JS (no framework dependencies)
- AI: OpenRouter (free models) via OpenAI-compatible API
- Blockchain: NEAR RPC (testnet) for on-chain account/contract queries
- Deployment: Render (Docker)
- Icons: Lucide (via CDN)
- fastapi, uvicorn, httpx, openai, python-dotenv, pydantic
- No frontend framework — pure HTML/CSS/JS for minimal dependencies
- Docker for deployment
cd backend
pip install -r requirements.txt
export OPENROUTER_API_KEY=your_key
python main.py- Open the app at https://near-sec-agent.onrender.com/
- Set a policy: Scroll to "Policy Configuration", set max per TX to 100, daily limit 500, require human above 50. Click "Set Policy".
- Check a payment: In "Counterparty Check", enter agent_id "demo-agent", recipient "alice.near", amount 10. Click "Check Payment". See the risk score and verdict.
- Run the attack demo: Click "Run Attack Demo". Watch 7 steps: a prompt-injected agent tries to send 500 NEAR to scammer.near. The security layer blocks it at every step.
- Audit trail: Scroll down to see all logged transactions with risk scores and decisions.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health | Health check + TEE status |
| POST | /api/policy | Set agent policy |
| GET | /api/policy/{agent_id} | Get agent policy |
| POST | /api/check | Counterparty check (allow/warn/block) |
| POST | /api/blocklist/add | Add to shared blocklist |
| GET | /api/blocklist | View blocklist |
| GET | /api/audit | View audit trail |
| GET | /api/audit/stats | Audit statistics |
| GET | /api/tee/attestation | TEE attestation status |
| POST | /api/demo/prompt-injection | Run attack demo |
MIT — see LICENSE
Built for NEAR HACKATHON (Nov 1-14, 2026). Track: AI Security & Defense.
Repository is public. Demo: https://near-sec-agent.onrender.com/