AegisAEGIS

Integration Guide

Use Aegis in Your Project

Aegis is published on npm and works with any Express app. Three real use cases, complete code, copy and paste.

1
Track 3 — API Monetization

Monetize Any API

Turn any Express endpoint into a paid service. One middleware line adds x402 micropayments — agents pay per call, you earn per call.

Install

Terminal
npm install aegis-ows-gate express

Code

server.js — complete, runnable
import express from "express";
import { aegisGate } from "aegis-ows-gate";

const app = express();

// Your API is now paid — $0.001 SOL per call
app.get("/api/data",
  aegisGate({ price: "0.001", token: "SOL", agentId: "my-service" }),
  (req, res) => {
    res.json({ result: "your data here" });
  }
);

app.listen(3000, () => {
  console.log("Paid API running on http://localhost:3000");
});

Test it

Terminal — test with curl
# Without payment → 402 Payment Required
curl http://localhost:3000/api/data
# Returns: { "error": "Payment Required", "x402": { "price": "0.001", "token": "SOL", ... } }

# With payment → 200 OK
curl http://localhost:3000/api/data \
  -H 'X-PAYMENT: {"fromAgent":"buyer","txHash":"sig-123456789012345678","timestamp":"2026-04-04T00:00:00Z","deadline":9999999999}'
# Returns: { "result": "your data here" }

What happens

Unpaid requests get a 402 response with payment instructions (price, token, payment address).
Callers include an X-PAYMENT header with a signed payment proof.
Gate verifies the proof, credits your agent's earnings ledger, and passes the request through.
Every payment appears in the Aegis Nexus dashboard automatically.

2
Track 4 — Multi-Agent

Agent-to-Agent Payments

One agent pays another for a service. payAndFetch handles the full x402 handshake — discover the price, sign the payment through OWS, get the content.

Install

Terminal
npm install aegis-ows-gate

Code

buyer-agent.js — pay for a service
import { payAndFetch } from "aegis-ows-gate";

// Agent discovers and pays for a service — one line
const result = await payAndFetch(
  "http://data-service:3000/api/data",
  "buyer-agent"
);

console.log(result); // The paid content

// What happened under the hood:
// 1. payAndFetch called the URL, got a 402 response
// 2. Read the price from the x402 payment details
// 3. Signed the payment through OWS (all policies checked)
// 4. Re-sent the request with the payment proof
// 5. Returned the 200 response body

What happens

payAndFetch abstracts the entire payment flow into a single async call.
The payment goes through OWS's signing enclave, so all active policies (budget, guard, deadswitch) are enforced.
Both the buyer's spend and the seller's earnings are recorded in the Aegis ledger.
Works with any Aegis Gate-protected endpoint, across agents, across machines.

3
Track 2 — Spend Governance

Add Spending Policies

Control how much your agent can spend, which addresses it can pay, and kill it if it goes silent. Three policy executables plug directly into OWS.

Install

Terminal
npm install aegis-ows-shared

Code

budget-policy.json — spending limits
{
  "limits": [
    {
      "chainId": "solana:devnet",
      "token": "SOL",
      "daily": "1.00",
      "weekly": "5.00",
      "monthly": "15.00"
    },
    {
      "chainId": "eip155:1",
      "token": "USDC",
      "daily": "10.00",
      "weekly": "50.00"
    }
  ]
}

Test it

Terminal — register with OWS
# Register policies with OWS
ows policy create \
  --name aegis-budget \
  --executable ./node_modules/.bin/aegis-budget \
  --config ./budget-policy.json

# Or use the Aegis CLI for guided setup
npx aegis-ows-cli install

What happens

aegis-budget enforces per-chain, per-token spending caps (daily, weekly, monthly).
aegis-guard maintains an address allowlist/blocklist so agents only pay trusted recipients.
aegis-deadswitch revokes signing keys after a configurable period of inactivity.
All three plug into OWS's policy engine via stdin/stdout — the standard extension point.

Aegis is open source and published on npm. Use it in your hackathon project, or build on top of it.