⚠️

Checking...

The environment variables required for signing transactions are not loaded. The demo will not work until you restart the dev server.

Steps to fix:
1. Open terminal where dev server is running
2. Press Ctrl+C to stop the server
3. Run: npm run dev
4. Hard refresh browser (Cmd+Shift+R or Ctrl+Shift+R)

x402 Payment Protocol

HTTP-native payments for API access on Starknet

API Response

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

STEP 1

Request Protected Resource

Send a standard HTTP GET request to the protected weather API endpoint. The server will detect no payment header and respond with HTTP 402 Payment Required, including payment details (amount, asset, recipient address, network) in the response body. This tells the client exactly how to construct and sign the payment.

How it works:

  1. 1.Client initiates request to the server for a paid resource
  2. 2.Server responds with 402 Payment Required including payment requirements
  3. 3.Client prepares and submits payment payload based on requirements
  4. 4.Server verifies payment payload via facilitator service
  5. 5.Server settles payment and confirms transaction
  6. 6.Server responds with the requested resource

Key Terms:

Client: Entity making HTTP request (buyer)
Server: Resource provider requiring payment (seller)
Facilitator: Service that verifies and settles payments

Key Features:

✓ HTTP-native protocol (uses 402 status code)
✓ Gasless for both client and server
✓ Chain and token agnostic (this demo uses Starknet)
✓ Open standard - no single party dependency