x402

x402 protocol v2 for internet-native payments. Use when building x402 servers, clients, facilitators, or integrating x402 payment flows. Triggers: x402, payment required, 402, paywall, micropayment, EIP-3009, payment protocol, facilitator, PaymentPayload, PaymentRequirements.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "x402" with this command: npx skills add thegreataxios/agent-skills/thegreataxios-agent-skills-x402

x402 Protocol v2

Open payment standard enabling clients to pay for external resources over any transport layer (HTTP, MCP, A2A). Protocol version: 2.

Core Concepts

x402 has three architectural layers:

  1. TypesPaymentRequirements, PaymentPayload, SettlementResponse, VerifyResponse (transport/scheme-agnostic)
  2. Logic — Payment formation, verification, settlement (scheme+network specific, e.g. exact/EVM)
  3. Representation — How payment data is transmitted (transport-specific: HTTP headers, JSON-RPC, etc.)

Payment Flow

  1. Client requests a protected resource
  2. Server responds with Payment Required + PaymentRequired JSON (contains accepts array)
  3. Client picks a payment method, signs authorization, sends PaymentPayload
  4. Server forwards to facilitator → verifysettle → returns resource + SettlementResponse

Three Actors

  • Resource Server — Requires payment, delegates verification/settlement to facilitator
  • Client — Signs payment authorizations (wallet-based)
  • Facilitator — Verifies signatures, checks balances, broadcasts settlement transactions

PaymentRequired (Server → Client)

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://api.example.com/data",
    "description": "Premium data",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "maxAmountRequired": "10000",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "payTo": "0x...",
      "maxTimeoutSeconds": 60,
      "extra": { "name": "USDC", "version": "2" }
    }
  ],
  "extensions": {}
}

Field Reference

FieldTypeReqDescription
x402VersionnumberMust be 2
errorstringHuman-readable error
resourceResourceInfoURL, description, mimeType
acceptsPaymentRequirements[]Acceptable payment methods
extensionsobjectExtension data (key → {info, schema})

PaymentRequirements Fields

FieldTypeReqDescription
schemestringe.g. "exact"
networkstringCAIP-2 format, e.g. "eip155:8453"
maxAmountRequiredstringMaximum amount in atomic units
assetstringToken contract address or ISO 4217 code
payTostringRecipient wallet address
maxTimeoutSecondsnumberMax time for payment completion
extraobjectScheme-specific info

PaymentPayload (Client → Server)

{
  "x402Version": 2,
  "resource": { "url": "...", "description": "...", "mimeType": "..." },
  "accepted": { /* chosen PaymentRequirements */ },
  "payload": {
    "signature": "0x...",
    "authorization": {
      "from": "0x...", "to": "0x...", "value": "10000",
      "validAfter": "1740672089", "validBefore": "1740672154",
      "nonce": "0x..."
    }
  },
  "extensions": {}
}
FieldTypeReqDescription
x402VersionnumberProtocol version
resourceResourceInfoResource being accessed
acceptedPaymentRequirementsChosen payment method
payloadobjectScheme-specific payment data
extensionsobjectMust include at least server-provided extension info; may append but not delete/overwrite

EVM Exact Payload

FieldTypeReqDescription
signaturestringEIP-712 signature
authorization.fromstringPayer address
authorization.tostringRecipient address
authorization.valuestringAmount in atomic units
authorization.validAfterstringUnix timestamp
authorization.validBeforestringUnix timestamp
authorization.noncestring32-byte random nonce

SettlementResponse

{
  "success": true,
  "transaction": "0x...",
  "network": "eip155:8453",
  "payer": "0x..."
}
FieldTypeReqDescription
successbooleanSettlement succeeded
errorReasonstringError if failed
payerstringPayer wallet address
transactionstringTx hash (empty string if failed)
networkstringCAIP-2 network
extensionsobjectExtension data

VerifyResponse

FieldTypeReqDescription
isValidbooleanAuthorization is valid
invalidReasonstringReason if invalid
payerstringPayer wallet address

Facilitator API

Three HTTP REST endpoints:

POST /verify

Verifies payment authorization without settling. Request body: { paymentPayload, paymentRequirements }. Returns VerifyResponse.

POST /settle

Settles payment on-chain. Same request body as /verify. Returns SettlementResponse.

GET /supported

Returns supported schemes, networks, extensions, and signer addresses.

{
  "kinds": [
    { "x402Version": 2, "scheme": "exact", "network": "eip155:8453" }
  ],
  "extensions": [],
  "signers": {
    "eip155:*": ["0x..."],
    "solana:*": ["CKP..."]
  }
}

Exact Scheme — EVM

Uses EIP-3009 transferWithAuthorization for gasless ERC-20 transfers (e.g. USDC).

Verification steps:

  1. Validate EIP-712 signature
  2. Check payer token balance
  3. Validate amount ≥ required
  4. Check time window (validAfter/validBefore)
  5. Match parameters to payment requirements
  6. Simulate transferWithAuthorization tx

Settlement: Call transferWithAuthorization on the ERC-20 contract.

EIP-3009 type structure:

const authorizationTypes = {
  TransferWithAuthorization: [
    { name: "from", type: "address" },
    { name: "to", type: "address" },
    { name: "value", type: "uint256" },
    { name: "validAfter", type: "uint256" },
    { name: "validBefore", type: "uint256" },
    { name: "nonce", type: "bytes32" },
  ],
};

Exact Scheme — SVM (Solana)

Uses TransferChecked for SPL tokens. Key verification:

  • Strict instruction layout: Compute Unit Limit → Compute Unit Price → TransferChecked
  • Facilitator fee payer must NOT appear in instruction accounts or as transfer authority/source
  • Compute unit price bounded to prevent gas abuse
  • Destination ATA must match payTo/asset PDA
  • Transfer amount must exactly equal PaymentRequirements.amount

Networks (CAIP-2 Format)

NetworkCAIP-2 ID
Base mainneteip155:8453
Base Sepoliaeip155:84532
Avalanche mainneteip155:43114
Avalanche Fujieip155:43113
Solana mainnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
Solana devnetsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1

Extensions

Extensions are key-value maps in PaymentRequired and PaymentPayload:

  • Each key = extension identifier
  • Each value = { info: object, schema: object } where schema is JSON Schema for info
  • Client must include at least the server-provided info; may append but cannot delete/overwrite

Discovery API (Bazaar)

GET /discovery/resources

Params: type (e.g. "http"), limit (1-100, default 20), offset (default 0).

Returns paginated list of x402-enabled resources with accepts arrays, lastUpdated timestamps, and optional metadata.

Error Codes

CodeMeaning
insufficient_fundsPayer lacks tokens
invalid_exact_evm_payload_authorization_valid_afterAuth not yet valid
invalid_exact_evm_payload_authorization_valid_beforeAuth expired
invalid_exact_evm_payload_authorization_valueAmount insufficient
invalid_exact_evm_payload_signatureBad signature
invalid_exact_evm_payload_recipient_mismatchWrong recipient
invalid_networkUnsupported network
invalid_payloadMalformed payload
invalid_payment_requirementsBad requirements
invalid_scheme / unsupported_schemeScheme not supported
invalid_x402_versionWrong protocol version
invalid_transaction_stateTx failed on-chain
unexpected_verify_error / unexpected_settle_errorInternal errors

Security

  • Replay prevention: 32-byte EIP-3009 nonce + smart contract nonce reuse protection + time windows
  • Auth integration: Supports SIWE for authenticated/discounted pricing

Reference Implementation

See https://github.com/coinbase/x402 for the canonical implementation.

For detailed scheme-specific implementation, see the reference files:

  • reference/exact-core.md — Core exact scheme specification
  • reference/exact-evm.md — EVM implementation (EIP-3009)
  • reference/exact-svm.md — Solana implementation
  • reference/exact-sui.md — Sui implementation

For facilitator API examples and discovery API schemas, see reference/facilitator-api.md.

For x402 extension specifications, see the extension reference files:

  • reference/extension-bazaar.md — Resource discovery and cataloging
  • reference/extension-payment-identifier.md — Idempotency keys for deduplication
  • reference/extension-sign-in-with-x.md — Wallet-based authentication (CAIP-122/SIWE)
  • reference/extension-eip2612-gas-sponsoring.md — Gasless EIP-2612 permit flow
  • reference/extension-erc20-gas-sponsoring.md — Gasless ERC-20 approval flow

Transport Support

x402 is transport-agnostic. Current transports:

  • HTTP402 Payment Required status, base64-encoded headers (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE). See reference/transport-http.md.
  • MCP — Payment via _meta["x402/payment"] and _meta["x402/payment-response"], signaling via isError: true + structuredContent. See reference/transport-mcp.md.
  • A2A — Task-based lifecycle with x402.payment.* metadata keys, AgentCard extension declaration, X-A2A-Extensions header activation. See reference/transport-a2a.md.

Framework Integration

Server-side: Express.js middleware (require_payment()), FastAPI, Hono, Next.js, ai/agents. Client-side: axios/fetch, httpx/requests, MCP clients, A2A clients.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

skale-dev

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

bite-dev

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

arktype

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

zod

No summary provided by upstream source.

Repository SourceNeeds Review