Skip to main content
x402 is an emerging standard designed to facilitate autonomous financial transactions between AI agents, servers, and automated systems. Rem provides the reference implementation and middleware for incorporating x402 into your payment flows.

Why x402?

In the agentic economy, payments are no longer initiated solely by humans via web interfaces. Machines need a way to:
  1. Discover Payment Terms: Understand costs before execution.
  2. Negotiate Parameters: Handle variable pricing or volume discounts.
  3. Execute Autonomously: Settle transactions without human-in-the-loop approvals.
  4. Verify Cryptographically: Ensure the identity and authorization of both parties.

Rem’s x402 Implementation

Rem provides a suite of tools to make x402 adoption seamless for institutions.

1. Middleware for Hono & Express

We provide drop-in middleware that handles the x402 handshake and request/response lifecycle.
import { x402 } from '@rem-money/sdk';

app.use('/v1/payments/*', x402({
  provider: 'rem',
  thresholds: {
    maxPerTransaction: 1000 // USDC
  }
}));

2. Header-Based Negotiation

x402 utilizes custom HTTP headers to communicate payment requirements between the agent and the gateway.
  • X-402-Payment-Required: Sent by the server when a payment is needed.
  • X-402-Wallet-Address: The destination for the machine-to-machine transfer.
  • X-402-Status: Real-time settlement status.

3. Integration with Circle

Rem’s x402 middleware is pre-wired to resolve payments via the Circle Payment Network, ensuring that sub-second settlement on Solana, Base, or Tempo is immediately reflected in the x402 state machine.

Technical Workflow

  1. Initial Request: An agent attempts to access a protected resource.
  2. Rejection (402): The server returns a 402 Payment Required status with x402 headers defining the cost.
  3. Settlement: The agent’s wallet (managed via Rem or MCP) executes a transfer on-chain.
  4. Verification: The Rem gateway detects the on-chain event and updates the x402 session.
  5. Success: The agent retries the original request, which now passes the x402 verification check.

Use Cases

Compute Reselling

Automated settlement for GPU or inference time based on usage.

Data Marketplaces

Pay-per-query access for LLM training or real-time data feeds.

Agentic Commerce

AI agents purchasing APIs, services, or physical goods.

Ad Networks

Real-time bidding and settlement for machine-driven advertising.

View API Reference

See how to implement x402 endpoints in your own applications.