githubEdit

money-bill-transferx402

Accept and make instant USD₮ payments over HTTP using WDK self-custodial wallets

What Is x402?

x402arrow-up-right is an open payment protocol, originally developed by Coinbasearrow-up-right, that gives the long-reserved HTTP 402 Payment Requiredarrow-up-right status code a concrete, blockchain-native meaning: if you want this resource, pay for it. No accounts, API keys, or checkout flows. Just plain HTTP.

This matters for AI agents because they need to pay for resources programmatically. x402 makes payment a first-class part of the web stack, so an agent can discover a price, sign a payment, and receive a resource in a single request-response cycle.

The Three Roles

Role
Description

Client (Buyer)

The entity requesting a paid resource. Can be a human application, an AI agent, or any service with a wallet.

Resource Server (Seller)

The API or service providing the paid resource. Defines payment requirements and returns 402 for unpaid requests.

Facilitator

An intermediary that verifies payment signatures and submits transactions on-chain. Never holds funds, only executes signed authorizations.

How the Protocol Works

1

Client requests a resource

A standard HTTP request. GET, POST, whatever your API expects.

2

Server responds with 402 Payment Required

The response body describes what to pay: amount, token, network, and recipient address.

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:9745",
    "maxAmountRequired": "1000000",
    "asset": "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
    "resource": "https://api.example.com/data",
    "payTo": "0x1234...abcd"
  }]
}
3

Client signs a payment

The client constructs an EIP-3009arrow-up-right transferWithAuthorization and signs it with their wallet. No tokens leave the wallet yet. It's a signed intent, not a transfer.

4

Client retries with payment header

The signed payload goes in the X-PAYMENT header on the same request.

5

Facilitator verifies

The server forwards the payload to the facilitator's /verify endpoint. The facilitator checks that the signature is valid, the amount is sufficient, and the payer has funds. No money moves yet.

6

Server performs the work

Inference, database query, generation, whatever the resource requires. This only happens after verification succeeds.

7

Facilitator settles on-chain

The server calls the facilitator's /settle endpoint. The facilitator submits the signed authorization on-chain, transferring tokens from buyer to seller.

8

Server returns the resource

200 OK with the result in the body and a settlement receipt in the X-PAYMENT-RESPONSE header.

For the full protocol specification, see x402.orgarrow-up-right and the x402 GitHub repositoryarrow-up-right.

How to Use x402 With WDK

WDK wallets work as drop-in signers for x402. WalletAccountEvm satisfies the client x402 signer interface directly. Self-custodial x402 payments on any EVM chain.

This guide walks through three things:

  1. Client (Buyer) - Pay for x402-protected resources using a WDK wallet

  2. Server with Hosted Facilitator - Accept x402 payments by delegating verification and settlement to a third-party facilitator

  3. Server with Self-Hosted Facilitator - Run verification and settlement in-process using a WDK wallet, with no external dependencies

circle-exclamation

x402 with WDK works on any EVM chain where USD₮0 is deployed (see full list at docs.usdt0.toarrow-up-right). However, we recommend Plasma and Stable for x402 payments. Both chains are purpose-built for USD₮ transfers with near-instant finality and near-zero fees. Agents only need to hold USD₮.

Chain
CAIP-2
RPC
USD₮0 Contract
Explorer

Plasma

eip155:9745

https://rpc.plasma.to

0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb

Stable

eip155:988

https://rpc.stable.xyz

0x779Ded0c9e1022225f8E0630b35a9b54bE713736


Client: Paying for Resources

circle-info

See the full working client example at x402/client.jsarrow-up-right.

1

Create a wallet

2

Register with x402

WalletAccountEvm satisfies the ClientEvmSigner interface directly. No adapter needed.

3

Make a paid request

fetchWithPayment intercepts any 402 response, signs an EIP-3009 authorization with your WDK wallet, and retries automatically.

circle-exclamation

Getting USD₮0 on Plasma or Stable

Before you can make x402 payments, your wallet needs USD₮0 on the target chain. If you hold USD₮ on Ethereum (or any supported EVM chain), bridge it using @tetherto/wdk-protocol-bridge-usdt0-evm.

circle-info

The bridge uses LayerZeroarrow-up-right for secure cross-chain transfers. USD₮ on Ethereum is automatically converted to USD₮0 on the destination chain.

Bridge USD₮ from Ethereum to Plasma / Stable

1

Create wallet and bridge protocol

2

Get a quote (recommended)

3

Execute the bridge

USD₮0 arrives on the destination chain within a few minutes.

circle-info

You can bridge from any of 25+ supported EVM chains, not just Ethereum. Point your wallet at the source chain's RPC and use the USD₮ token addressarrow-up-right on that chain. See the full bridge module documentation.


Server: Accepting Payments (Hosted Facilitator)

Your server delegates verification and settlement to a hosted facilitator. You never interact with the chain directly.

circle-info

About the Semantic facilitator: Semanticarrow-up-right operates a public USD₮-enabled x402 facilitator at https://x402.semanticpay.io. This is a third-party service not operated, endorsed, or guaranteed by Tether.

The x402 protocol is an open standard. Anyone can build and host their own facilitator. For the API reference, see the Semantic facilitator docsarrow-up-right.

See the full working server example at x402/server.jsarrow-up-right.

1

Derive your receiving address

2

Create the facilitator client

3

Configure payment middleware

circle-info

The extra fields are passed to the buyer for EIP-712 signature construction. name and version must match what the on-chain USD₮0 contract expects.

4

Add your routes

Routes not listed in the middleware config behave like normal Express routes.

Multi-Chain (Plasma + Stable)

To accept payments on both chains, add both networks to the accepts array and register both with the resource server. The buyer's client picks whichever network it has funds on.

Lifecycle Events

The Semantic facilitator supports an optional X-Event-Callback header. When provided, the facilitator POSTs real-time events to your callback URL during verification and settlement.

Type
When
Key Fields

verify_started

Facilitator begins verifying

details.network, details.checks

verify_completed

Verification finished

details.isValid

verify_failed

Verification error

details.error

settle_started

Broadcasting on-chain transaction

details.network

settle_completed

Transaction confirmed

details.transactionHash

settle_failed

Settlement error

details.error

circle-info

Events are fire-and-forget. If the callback URL is unreachable, events are silently dropped.


Server: Self-Hosted Facilitator (In-Process)

Instead of relying on a hosted facilitator, you can run verification and settlement in-process using the @semanticio/wdk-wallet-evm-x402-facilitator community module. This wraps a WDK wallet as an x402 FacilitatorEvmSigner. Your server handles the entire payment lifecycle locally.

circle-check
circle-exclamation
circle-info

See the full working self-hosted server example at x402/server-inprocess.jsarrow-up-right.

1

Create the facilitator signer

The facilitator wallet submits settlement transactions on-chain. It needs gas tokens on the target chain.

circle-info

The facilitator wallet and the seller wallet can use different seed phrases. The facilitator pays gas; the seller receives USD₮. The facilitator wallet must have enough native token to pay gas.

2

Initialize the facilitator

Available hooks: onBeforeVerify, onAfterVerify, onBeforeSettle, onAfterSettle. All are async and receive a context object with the payment payload and result.

3

Wire into Express

Same paymentMiddleware pattern, but pass the in-process facilitator directly instead of an HTTPFacilitatorClient.


Summary

Role
Packages
Notes

Buyer (Client)

@tetherto/wdk-wallet-evm, @x402/fetch, @x402/evm

WalletAccountEvm satisfies ClientEvmSigner directly.

Seller (Hosted)

@tetherto/wdk-wallet-evm, @x402/express, @x402/evm, @x402/core

Delegates to a hosted facilitator. Semantic supports Plasma and Stable.

Seller (Self-Hosted)

@tetherto/wdk-wallet-evm, @semanticio/wdk-wallet-evm-x402-facilitator, @x402/core, @x402/evm, @x402/express

In-process facilitator. Any USD₮0 chain.


Resources