Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions solutions/x402-insured-settlement/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules/
dist/
.next/
.vercel/
coverage/
*.tsbuildinfo

# Secrets — never commit
.env
.env.*
!.env.example

# Local runtime state (demo agents) — contains private keys
.agent-store.json
.agent-store.json.*
.session-store.json

# OS
.DS_Store
Thumbs.db
1 change: 1 addition & 0 deletions solutions/x402-insured-settlement/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-linker=hoisted
6 changes: 6 additions & 0 deletions solutions/x402-insured-settlement/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 100,
"singleQuote": false,
"semi": true,
"trailingComma": "all"
}
21 changes: 21 additions & 0 deletions solutions/x402-insured-settlement/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Reineira Labs Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 83 additions & 0 deletions solutions/x402-insured-settlement/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: x402 Insured Settlement
slug: x402-insured-settlement
description: Agentic x402 payments settled through on-chain escrow with optional insurance — autonomous buyer and seller agents moving real USDC on Arbitrum Sepolia, built on ReineiraOS.
framework: monorepo
type: dapp
tags: [x402, payments, escrow, insurance, agents, ai, arbitrum, fhe, fhenix, erc4337, rss]
demoUrl: null
image: null
author: ReineiraOS
dateAdded: 2026-06-23
repoPath: solutions/x402-insured-settlement
---

# x402 Insured Settlement

[![Platform](https://img.shields.io/badge/ReineiraOS-v0.1-blue)](https://reineira.xyz)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
[![Buildathon](https://img.shields.io/badge/%F0%9F%8F%86%201st%20place-Agentic%20track-FACC15)](https://arbitrum-london.hackquest.io/buildathons/Arbitrum-Open-House-London-Online-Buildathon)

> 🏆 **1st place — Agentic track**, [Arbitrum Open House London Online Buildathon](https://arbitrum-london.hackquest.io/buildathons/Arbitrum-Open-House-London-Online-Buildathon) (2026) — [announcement](https://x.com/arbitrum/status/2069113449221910953).

Autonomous AI agents that pay each other for real resources — settled on-chain
through an x402 → escrow rail with optional insurance coverage and claims. A
buyer agent purchases data behind an x402 paywall; a seller agent serves it; the
payment funds an on-chain escrow on Arbitrum Sepolia and releases on delivery.
Built on the published [`@reineira-os/x402-*`](https://github.com/ReineiraOS/x402)
packages.

## What it does

- **Agentic x402** — a buyer agent and a seller agent transact over the x402
payment-required protocol, no human in the loop
- **Escrow-gated settlement** — every `402` opens a real on-chain escrow; funds
release to the seller on delivery, refund the buyer on timeout
- **Optional insurance** — buyers can attach parametric coverage; missed
delivery files a claim against an underwriter pool
- **Confidential rail (FHE)** — the same flow runs against the Fhenix
FHE-encrypted escrow stack, hiding amounts on-chain
- **Two-Key Halt** — a Sentinel / Guardian verdict primitive that can freeze a
rail under attack
- **Settlement Theater** — a live terminal that surfaces every verify / settle /
release step as it happens

## Packages

| Package | Stack | Purpose |
| -------------------------- | ----------------------------- | -------------------------------------------------------------- |
| `packages/demo` | Next.js 16, React 19, ZeroDev | Payment-agents dashboard, resource server, Settlement Theater |
| `packages/facilitator-web` | Hono | Deployable x402 facilitator (`/verify` + `/settle`) for Vercel |

The on-chain protocol (escrow, receivers, resolvers, FHE codec) ships as the
published `@reineira-os/x402-*` packages — this example consumes them, it does
not vendor their source.

## Setup

```bash
pnpm install
```

Then copy and fill the env files (testnet only — Arbitrum Sepolia):

```bash
cp packages/demo/.env.example packages/demo/.env.local
cp packages/facilitator-web/.env.example packages/facilitator-web/.env.local
```

## Development

```bash
pnpm dev # demo on http://localhost:3000
pnpm build # build every package
pnpm typecheck # tsc --noEmit across packages
```

The demo calls a facilitator for `/verify` + `/settle`. Run `packages/facilitator-web`
(or any deployment of `@reineira-os/x402-facilitator`) and point the demo at it
via `FACILITATOR_URL`.

## License

MIT — see [LICENSE](LICENSE).
31 changes: 31 additions & 0 deletions solutions/x402-insured-settlement/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@x402-insured-settlement/monorepo",
"version": "0.1.0",
"private": true,
"description": "x402 Insured Settlement — agentic payments with on-chain escrow and optional insurance, built on ReineiraOS",
"reineira": {
"platform": "0.1"
},
"scripts": {
"dev": "pnpm --filter @x402-insured-settlement/demo run dev",
"dev:demo": "pnpm --filter @x402-insured-settlement/demo run dev",
"build": "pnpm -r run build",
"typecheck": "pnpm -r run typecheck",
"format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md}'",
"format:check": "prettier --check '**/*.{ts,tsx,js,jsx,json,md}'"
},
"devDependencies": {
"prettier": "^3.4.0"
},
"packageManager": "pnpm@10.30.3",
"engines": {
"node": ">=20.0.0",
"pnpm": ">=10.0.0"
},
"license": "MIT",
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
}
}
7 changes: 7 additions & 0 deletions solutions/x402-insured-settlement/packages/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Local runtime state — contains private keys, never commit
.agent-store.json
.session-store.json
*.bak
.env*
.next
node_modules
56 changes: 56 additions & 0 deletions solutions/x402-insured-settlement/packages/demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Payment agents (demo)

`@x402-insured-settlement/demo` — a Next.js dashboard for the x402 + RSS
insured-settlement flow, with autonomous buyer and seller agents settling
real on-chain payments on Arbitrum Sepolia. Built on the published
`@reineira-os/x402-*` packages.

## What it is

A "Payment agents" dashboard with a passkey-secured treasury and two
autonomous AI agents — a buyer that pays for resources and a seller that
serves them behind an x402 paywall. Payments settle on-chain via our own
x402 → escrow rail, with optional insurance coverage and claims. A
"Settlement Theater" terminal surfaces each step as it happens.

Sidebar navigation:

| Route | Page | Shows |
| ------------ | ------------ | ------------------------------------------------------------------ |
| `/` | Agents | Buyer + seller agents, treasury, the Settlement Theater terminal |
| `/analytics` | Analytics | Charts over settlement activity |
| `/plugins` | Plugins | RSS resolver / policy plugins wired into the escrow |
| `/resources` | Resources | The paid-resource catalog the buyer can purchase |
| `/two-key` | Two-Key Halt | A security primitive on x402 rails (Sentinel / Guardian / verdict) |

## Run

The demo needs a facilitator running (it does `/verify` + `/settle`) and a
`.env.local` in this directory with the Arbitrum Sepolia + agent keys — copy
`.env.example` and fill it in.

Start the facilitator (`../facilitator-web`, or any deployment of
`@reineira-os/x402-facilitator`), then from the solution root:

```bash
pnpm --filter @x402-insured-settlement/demo dev
```

Or from this directory:

```bash
pnpm dev # next dev on http://localhost:3000
pnpm build # next build
pnpm typecheck # tsc --noEmit
```

## Routes

- `GET /api/resource` — the x402 resource server.
- No `payment-signature` header → `402` with an x402 `payment-required`
body (version 2, scheme `exact`, network `eip155:421614`, USDC asset
from `@reineira-os/x402-shared`).
- With `payment-signature` header → validates the escrow, runs real
facilitator `/verify` + `/settle`, then returns a **live on-chain data
report** (`lib/resources.ts`): current Arbitrum Sepolia block + gas plus
ETH/USD spot, fetched fresh at request time. Nothing is hardcoded.
Loading
Loading