x402 & The Agent Economy

afx402 Features

A complete platform for autonomous agent payments. Software as the primary user. No wallets, no checkout pages—just programmable settlement.

Built onMonad Testnet·x402 Protocol

On-Chain Settlement

EIP-712 flash payments with escrow-based settlement on Monad.

production

Deploy the X402Settlement.sol contract to Monad Testnet. Supports escrow deposits, batch settlement, and automatic fee distribution.

SolidityEIP-712Monad Testnet
// Open escrow with MON
contract.openEscrow{ value: 0.1 ether }();

// Settle signed promise
contract.settlePayment(payer, agentId, amount, nonce, expiresAt, signature);

AI-Powered Agents

Real LLM integration via Google Gemini for intelligent tasks.

production

12 agents including 6 AI-powered (Research, Summarizer, Code Reviewer, Translator, Sentiment, Data Extractor) and 6 utility agents. Each charges per-call via x402.

Gemini APIGoogle AI StudioStreaming SSE
// Execute AI research agent
const result = await fetch("/api/agents/execute", {
  method: "POST",
  body: JSON.stringify({ agent_id: "research", input: "Explain x402 protocol" })
});

Agent-to-Agent Payments

Agents autonomously pay other agents with no human intervention.

production

Each agent has a virtual wallet. Agent A can call Agent B and pay automatically. Supports daily budgets and auto-topup from owner's balance.

Virtual WalletsBudget PoliciesAuto-Topup
// Agent calling another agent
const result = await agentCallAgent(db, {
  callerAgentId: "research",
  targetAgentId: "summarizer",
  input: { text: longDocument }
});

Self-Healing Escrow

Automatic balance top-up when agent funds drop below threshold.

production

Configure autoTopupThreshold and autoTopupAmount per agent. When balance is low, funds are automatically transferred from the owner's prepaid balance.

Auto-TopupThreshold MonitoringOwner Funding
// Auto-topup triggers when balance < threshold
const result = await autoTopupIfNeeded(db, agentId);
// result: { topped_up: true, amount: 500000000000000n }

Circuit Breaker & Failover

Automatic agent failover when primary service fails.

production

Implements circuit breaker pattern: closed → open → half-open. When an agent fails repeatedly, traffic routes to backup agents automatically.

Circuit BreakerFailover GroupsHealth Monitoring
// Execute with automatic failover
const result = await executeWithFailover("research", async (agentId) => {
  return runBuiltinAgent(agentId, input);
});
// result.wasFailover tells if backup was used

Streaming Responses (SSE)

Real-time token streaming for AI agents via Server-Sent Events.

production

AI agents stream responses token-by-token. Perfect for chat interfaces and long-running tasks. Uses standard SSE protocol.

SSEStreaming APIReal-time
// Stream AI response
const es = new EventSource("/api/agents/stream?agent=research&input=...");
es.addEventListener("chunk", (e) => {
  appendToOutput(JSON.parse(e.data).content);
});

Live Mission Control

Real-time dashboard showing payment flows and agent activity.

production

SSE-powered dashboard with live stats: calls/24h, volume, active agents, pending settlements. Events stream in real-time.

SSEReal-time StatsEvent Stream
// Connect to live dashboard
const es = new EventSource("/api/dashboard/stream");
es.addEventListener("stats_update", (e) => updateStats(JSON.parse(e.data)));
es.addEventListener("payment", (e) => addPaymentEvent(JSON.parse(e.data)));

Autonomous Spend Policies

Machine-controlled budgets enforced before every payment.

production

Set daily_cap_wei and allow_agent_ids per wallet. Policies are checked before any payment executes. Humans set constraints, machines execute.

Policy EngineDaily CapsAgent Allowlists
// Set spend policy
await fetch("/api/policy/set", {
  method: "POST",
  body: JSON.stringify({
    daily_cap_wei: "1000000000000000000", // 1 MON/day
    allow_agent_ids: ["research", "summarizer"]
  })
});

Monad Testnet Configuration

Network Details

Chain ID10143
Network NameMonad Testnet
CurrencyMON
RPC URLhttps://testnet-rpc.monad.xyz

Canonical Contracts

Wrapped MON

0xFb8b...C541

Multicall3

0xcA11...CA11

Permit2

0x0000...8ba3

Quick Start for Developers

1. Get Test MON

Visit the Monad faucet to get testnet MON for development.

Get MON from Faucet →

2. Fund Prepaid Balance

Use our dev faucet to credit your prepaid balance for testing agents.

Go to Settings →

# Install SDK and call an agent

npm install afx402-sdk

# Execute a paid agent call

curl -X POST https://your-app.vercel.app/api/agents/execute \

-d '{"agent_id": "research", "input": "Explain x402", "wallet": "0x..."}'

On-Chain Verification (Proof of Deployment)

Our X402Settlement contract is live on Monad Testnet. All flash payments, escrow operations, and settlements are verifiable on-chain.

Network

Monad Testnet (Chain ID: 10143)

Contract Features (Deployed)

  • EIP-712 Flash Payment Signatures
  • Escrow Management (Open, Top-up, Close)
  • Batch Settlement (Gas Optimized)
  • Agent Registration & Earnings Withdrawal
  • 1% Platform Fee Distribution
  • Nonce Replay Protection

💡 For Judges: Click the explorer link above to verify the contract deployment, view transactions, and confirm on-chain activity.

# Contract Source Location

contracts/X402Settlement.sol

# Deployment Script

node scripts/deploy-settlement.mjs

# Settlement Integration

lib/chain/settlement.ts

Built for the x402 & Agent Economy Hackathon · January 2026

Powered by Monad · x402 Protocol · Gemini AI