# Agent Security & Hallucination Gate (x402) - LLM Reference Guide

> **Deterministic Security & Hallucination Inspection Micro-Oracle for Autonomous AI Agents**
> **Protocol:** HTTP 402 (x402) & EIP-191 / EIP-712 Attestation
> **Networks:** Polygon (137), Base (8453), Arbitrum (42161)
> **Latency:** <10ms (In-Memory Deterministic AST & NLI Parsing)

---

## 🛡️ Available Endpoints & Capabilities

### 1. Security & Hallucination Inspection
- **POST `/inspect`** or **POST `/api/v1/gate/inspect`**
  - Evaluates agent outputs against ground truth facts.
  - Detects prompt injection, jailbreak attempts, API token / private key leakage, and numerical/factual hallucinations.
  - Returns `verdict` (`PASSED` / `BLOCKED`), `risk_score` (0.0 to 1.0), and cryptographic `attestation`.

### 2. Fast AST Code Audit
- **POST `/inspect/ast`** or **POST `/api/v1/gate/inspect/ast`**
  - Parses raw Python code into an AST to detect `os.system`, `subprocess`, `eval`, `exec`, reverse shells, and malicious socket interactions.

### 3. On-Chain Attestation & Calldata
- **POST `/api/v1/gate/attestation/onchain`**
  - Generates EIP-712 structured data and raw ABI calldata (`v, r, s`, `payloadHash`) for Solidity smart contracts.

### 4. Agent Vault & Pre-Funded Accounts
- **POST `/api/v1/vault/deposit`**: Pre-fund agent balance with USDC.
- **GET `/api/v1/vault/balance/{agent_address}`**: Retrieve real-time available USDC balance.

### 5. Multi-Chain Network Config
- **GET `/api/v1/gate/chains`**: List supported chain IDs, RPC endpoints, and vault contract addresses.

---

## ⚡ MCP Tool Names for Autonomous Agents
- `inspect_security_and_hallucinations`: Full audit + NLI fact check + signature.
- `verify_agent_output`: Sub-5ms fast prompt & secret filter.
- `inspect_code_ast_safety`: AST code safety verification.
- `get_onchain_security_attestation`: Cryptographic calldata for on-chain execution.
