Skip to main content

x402: The Agentic Economy

Agntor handles the 402 Payment Required handshake automatically, enabling your agents to make verified payments without human intervention.

How It Works

1

Request

Your agent hits a paid API endpoint.
2

Challenge

The server returns an x402 header with payment requirements.
3

Audit

Agntor checks if the transaction fits the agent’s Spend Policy.
4

Settlement

If safe, Agntor signs the attestation and releases the payment.

Setting a Spend Policy

Define spending limits and restrictions for your agent:
import { AgntorClient } from '@agntor/sdk';

const agntor = new AgntorClient({
  apiKey: process.env.AGNTOR_API_KEY
});

await agntor.payments.setPolicy({
  // Daily spending limit
  dailyLimit: "0.01 ETH",
  
  // Approved domains for payments
  allowedDomains: [
    "*.cloud-compute.com",
    "api.search.com",
    "storage.provider.io"
  ],
  
  // Human approval threshold
  requireHumanApprovalAbove: "0.05 ETH",
  
  // Per-transaction limit
  maxTransactionAmount: "0.005 ETH"
});

Payment Flow Example

import { AgntorShield } from '@agntor/core';

const shield = new AgntorShield({
  identity: 'eip8004:0x...',
  policy: 'enterprise-standard',
  maxSpend: '0.05_ETH_x402'
});

// Agent makes a request to a paid API
const result = await shield.execute(async (ctx) => {
  // Agntor automatically handles x402 negotiation
  const response = await fetch('https://api.compute-provider.com/gpu', {
    headers: {
      'X-Agntor-Identity': ctx.identity
    }
  });
  
  return response.json();
});

Payment Events

Monitor all payment activity:
agntor.payments.on('transaction', (event) => {
  console.log(`Amount: ${event.amount}`);
  console.log(`Recipient: ${event.recipient}`);
  console.log(`Status: ${event.status}`);
  console.log(`Attestation: ${event.attestationTx}`);
});

agntor.payments.on('blocked', (event) => {
  console.warn(`Payment blocked: ${event.reason}`);
  // Reasons: EXCEEDS_LIMIT, DOMAIN_NOT_ALLOWED, REQUIRES_APPROVAL
});

Security Features

FeatureDescription
EscrowFunds held in smart contract until service delivery confirmed
AttestationEvery payment linked to on-chain identity
Rate LimitingAutomatic throttling to prevent runaway spending
Audit TrailComplete transaction history for compliance
Always set appropriate spending limits. Agents without limits may drain funds if compromised.

Next Steps