x402 micropayment, live demo.

Buy a compliance report from StableKYA.com for $0.001 testnet USDC. Watch every stage of the payment lifecycle as it happens.

X402 PAYMENT JOURNEYIntentIdentityDiscoveryNegotiationTransportAuthorizationFacilitationFinality

Your Wallet

The x402 journey begins when you delegate spending authority by connecting a wallet. Your wallet's identity — address and chain — becomes the foundation for every compliance check that follows.

YOU ARE HEREYOU ARE HERE
L5ApplicationL4MiddlewareL3ExecutionL2ConsensusL1NetworkSTATESelf-Custody EOAWallet UIL5Smart Contract WalletYOUR WALLETPasskey UIOFAC / KYTERC-4337L3MPC WalletKYC GateMPC ThresholdL4Hosted / CustodialIdentityGas SponsorL4Agent WalletAgentKitSpend PolicySession KeysL3Code-enforcedPolicy-enforced
Your wallet's compliance surface reaches L3 Execution — session keys, spending limits, and transfer hooks are code-enforced. For the full wallet taxonomy, see StableKYA.com.

The Gate

When any HTTP client — browser, CLI, or AI agent — hits a paywalled resource, the server responds with HTTP 402 Payment Required. The payment requirements are encoded in the response headers. The server doesn't know or care what the client is.

YOU ARE HEREYOU ARE HERE
This is what your agent sees when it hits a paywalled resource. The server doesn't know or care whether the client is a browser, a CLI tool, or an autonomous AI agent. The 402 response is the same for all of them.

The Payment

You sign an EIP-3009 transferWithAuthorization — a gasless USDC transfer that the CDP facilitator submits on your behalf. OFAC screening fires at S6 as a code-enforced gate before the transfer lands on-chain.

YOU ARE HEREYOU ARE HERE
Waiting for wallet connection…
OFAC screening fires at S6 as a code-enforced gate. The CDP facilitator verifies the payment signature and screens the sender address before submitting the transfer on-chain. For the full checkpoint taxonomy, see StableKYA.com.

The Delivery

On successful payment, the server responds with 200 OK and delivers the compliance report as a PDF. The settlement receipt includes the transaction hash, block number, and finality time. The loop closes: the diagram inside the PDF maps the transaction you just made.

YOU ARE HEREYOU ARE HERE
🔒
LOCKED — PAYMENT REQUIRED

Know Your Agent: Anatomy of an x402 Compliant Transaction

The compliance diagram inside this report maps the transaction you just completed.

The compliance diagram inside this PDF is a map of the transaction you just made. Open it.

The Code

The payment flow code — buyer site and publisher Worker — is open source. The server is ~40 lines. The client is ~60. The STP Sequence and Stablecoin Stack compliance diagrams are not.

X402 PAYMENT JOURNEYIntentIdentityDiscoveryNegotiationTransportAuthorizationFacilitationFinality
Server (Worker) — ~40 lines
// stablekya.com/api/report — x402 gate
export default {
  async fetch(request: Request, env: Env) {
    const paymentSig = request.headers
      .get('PAYMENT-SIGNATURE');

    if (!paymentSig) {
      return new Response('Payment Required', {
        status: 402,
        headers: {
          'PAYMENT-REQUIRED': btoa(JSON.stringify({
            accepts: [{
              scheme: 'exact',
              network: 'base-sepolia',
              asset: 'USDC',
              amount: '1000',
              payTo: env.MERCHANT_ADDRESS,
              resource: 'kya-compliance-report-v1',
            }],
          })),
        },
      });
    }

    // Verify payment via facilitator...
    const report = await env.REPORTS
      .get('kya-report-v1.pdf');
    return new Response(report.body, {
      headers: {
        'Content-Type': 'application/pdf',
      },
    });
  },
};
Client (Browser) — ~60 lines
// Stable402.com — x402 buyer flow
async function purchaseReport() {
  // 1. Hit the gate
  const res402 = await fetch(
    'https://stablekya.com/api/report'
  );
  const requirements = JSON.parse(atob(
    res402.headers.get('PAYMENT-REQUIRED')
  )).accepts[0];

  // 2. Sign EIP-3009 authorization
  const signature = await walletClient
    .signTypedData({
      domain: {
        name: 'USDC', version: '2',
        chainId: 84532,
        verifyingContract: USDC,
      },
      types: {
        TransferWithAuthorization: [
          /* from, to, value, ... */
        ],
      },
      message: {
        from: address,
        to: requirements.payTo,
        value: BigInt(requirements.amount),
      },
    });

  // 3. Retry with payment
  const res200 = await fetch(
    'https://stablekya.com/api/report',
    {
      headers: {
        'PAYMENT-SIGNATURE': btoa(
          JSON.stringify({
            x402Version: 2,
            accepted: requirements,
            payload: { signature },
          })
        ),
      },
    }
  );

  // 4. Deliver the PDF
  const pdf = await res200.blob();
  downloadPdf(pdf, 'kya-report.pdf');
}
View on GitHub