Rein is a control plane for the AI agent payment economy, a developer tool and middleware built on the x402 / ERC-8004 technology stack. Its core design is non-custodial: Rein only governs an agent's spending authority and never holds the funds themselves.
Key capabilities
Rein provides a complete set of components covering multiple stages of payment governance:
- @reinconsole/sdk: Wraps an agent's fetch calls, performing policy checks on every x402 paywall before funds move, generating receipts, and maintaining observability.
- @reinconsole/mcp: Provides the guard as an MCP server that can be integrated into any MCP-capable framework (such as Claude Code and Codex-style agents), delivering spending-governed fetch and read-only rule introspection without code changes.
- @reinconsole/policy-engine: A sandboxed declarative rule engine with rule priority deny > escalate > allow > default, backed by a Fastify API. Every decision is ed25519-signed and sha256 hash-chained into a tamper-proof audit log.
- @reinconsole/core: Canonical zod schemas serving as the single source of truth for database rows, API payloads, and SDK types, including floating-point-free decimal currency arithmetic.
- @reinconsole/mock-rails: A simulated payment world (x402 facilitator + on-chain ledger + indexer) for reconciling spending and flagging "shadow spend" that bypasses the guard.
- @reinconsole/x402-rails: Real-world rails, including an EIP-3009 payer (gasless for agents), a client hosting the x402.org facilitator, a strict x402-v1 vendor, and an on-chain indexer that reconciles USDC transfers back to intents via authorization nonces.
- @reinconsole/console: A real-time "mission control" web UI showing decisions, vendor gateway quotes/receipts/rejections, signer releases, settlements, and shadow spend, and providing a kill switch, vendor revenue dashboard, live reputation scoreboard, and tamper-proof audChain.
- @reinconsole/signer: Custody tier. Wallet keys are stored in the signer; agents receive capped, expiring session tokens, and each EIP-3009 signature is released only under an engine signature authorization credential targeting the exact transfer; credentials are verifiable offline and single-use.
- @reinconsole/gate: Supply-side middleware that providers can place in front of any Node HTTP API to monetize via x402: glob-based pricing routes, quote-strict v1 402 responses, cross-check + filter + replay protection for incoming payments, settlement via pluggable rails, and retention of provider-side receipts and revenue statistics.
- @reinconsole/store: Persistence layer based on Postgres (embedded PGlite, no Docker or daemon required, upgradable to hosted Postgres), persisting agents, policies, spending, signing decision chains, reputation evidence, gateway receipts + replay slots, and signer sessions.
- @reinconsole/graph: Reputation layer. Observes all bus events published across the stack and scores every provider and payer with evidence: five interpretable 0–100 components plus confidence, recomputed on demand from raw evidence. Scores feed back into enforcement on both sides.
- @reinconsole/erc8004: On-chain identity source. Reads identity facts from the ERC-8004 identity registry and turns them into linked facts for the graph, supporting write paths and an in-memory registry twin for offline work.
Usage
The project provides npm packages, which can be used via npx @reinconsole/init to quickly launch demos of the sandbox, payments, and denials. The full stack can run scenarios through the console, supporting offline simulated rails and the real x402 rail on Base Sepolia. The policy engine can run independently, but note the authentication configuration: without an API key it binds only to 127.0.0.1 and refuses to start on public interfaces.
Use Cases
Suitable for developers and teams that need to set payment rules for AI agents, monitor transactions, manage provider monetization, and build counterparty reputation systems, especially in scenarios involving the x402 payment protocol and the ERC-8004 identity standard.
Limitations
The current version is v0.3 (latest on npm 0.5.0), and the hosted engine is in invite-only beta. Wallet private keys are intentionally not persisted and must be re-registered at startup. Some features depend on the Base Sepolia testnet or real USDC settlement.