x402 Payment Protocol Demo

HTTP 402 on Aptos Blockchain • v2 with Gasless Transactions

Access Protected Weather API

Click below to access the protected weather API. The x402axios.get() function will automatically handle the payment if required!

Open DevTools Network tab to see 2 requests: first without payment (gets 402), then with payment (gets data)

How x402Axios Works

  1. 1.Initial Request: Tries to access resource (no payment)
  2. 2.402 Detection: Server returns 402 with payment requirements
  3. 3.Extract Requirements: Gets network (aptos:2), amount, asset, sponsored flag
  4. 4.Build Fee Payer Tx: Creates sponsored transaction (gasless!)
  5. 5.Retry with Payment: Resends with PAYMENT-SIGNATURE header
  6. 6.Sponsor & Settle: Facilitator sponsors gas & submits

Just call x402Axios({ privateKey, url }) - that's it!

API Response

No response yet. Make a request to see the response here.