Skip to content

Commit 716123e

Browse files
[Docs] Simplify x402 documentation and rename "Facilitator API" to "Facilitator"
1 parent ae3dfa3 commit 716123e

File tree

4 files changed

+19
-36
lines changed

4 files changed

+19
-36
lines changed

apps/portal/src/app/payments/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const sidebar: SideBar = {
8282
},
8383
{
8484
href: `${paymentsSlug}/x402/facilitator`,
85-
name: "Facilitator API",
85+
name: "Facilitator",
8686
},
8787
],
8888
name: "x402",

apps/portal/src/app/payments/x402/client/page.mdx

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,18 @@ The client library wraps the native `fetch` API and handles:
6868
<TabsContent value="http">
6969
## Prepare Payment
7070

71-
Create a signed payment header from the authenticated user to include in your API request:
71+
Fetch any x402-compatible API and automatically handle payment flows when APIs return a `402 Payment Required` response using the authenticated wallet.
7272

73-
### Making the Paid Request
74-
75-
After preparing the payment, include it in your API request:
73+
Only requires passing a 'url' and 'from' query parameters with the authenticated wallet address (server or user wallet) to complete the payment.
7674

7775
```bash
78-
# First, make the initial request to get payment requirements
79-
curl -X GET https://api.example.com/paid-endpoint
80-
81-
# Response will be 402 Payment Required with payment details
82-
# {
83-
# "x402Version": 1,
84-
# "accepts": [...payment requirements...],
85-
# "error": "Payment required"
86-
# }
87-
88-
# Select one of the payment methods, and sign the payment authorization using the API
89-
curl -X POST https://api.thirdweb.com/v1/payments/x402/prepare \
76+
curl -X POST https://api.thirdweb.com/v1/payments/x402/fetch?url=https://api.example.com/premium&from=0x1234... \
9077
-H "Content-Type: application/json" \
91-
-H "Authorization: Bearer <user-access-token>" \
92-
-d '{
93-
"from": "0x1234...",
94-
"paymentRequirements": { ... }
95-
}'
96-
97-
# Response will contain the signed payment header
98-
# {
99-
# "paymentPayload": { ... },
100-
# "paymentHeader": "..." // base64 encoded payment header
101-
# }
102-
103-
# Finally, make the request with the payment header
104-
curl -X GET https://api.example.com/paid-endpoint \
105-
-H "X-PAYMENT: <base64-encoded-payment>"
78+
-H "Authorization: Bearer <user-wallet-token>" \
79+
-d '{ ... }' # request body passed through to the url called.
10680
```
10781

108-
## API Reference
109-
110-
<OpenApiEndpoint path="/v1/payments/x402/prepare" method="POST" />
82+
<OpenApiEndpoint path="/v1/payments/x402/fetch" method="POST" />
11183

11284
</TabsContent>
11385
</Tabs>

apps/portal/src/app/payments/x402/facilitator/page.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tabs, TabsList, TabsTrigger, TabsContent, OpenApiEndpoint, Callout } from "@doc";
22
import { TypeScriptIcon, EngineIcon } from "@/icons";
33

4-
# Facilitator API
4+
# Facilitator
55

66
The facilitator is a service that handles verifying and submitting x402 payments. It uses your own [server wallet](/wallets/server) and leverages EIP-7702 to submit transactions gaslessly.
77

@@ -16,6 +16,13 @@ The thirdweb facilitator is compatible with any x402 backend and middleware libr
1616

1717
You can view all transactions processed by your facilitator in your project dashboard.
1818

19+
## Chain and token support
20+
21+
Our facilitator supports payments on any EVM chain, as long as the payment token supports either:
22+
23+
- ERC-2612 permit (most ERC20 tokens)
24+
- ERC-3009 sign with authorization (USDC on all chains)
25+
1926
<Tabs defaultValue="typescript">
2027
<TabsList>
2128
<TabsTrigger value="typescript" className="flex items-center [&>p]:mb-0">

apps/portal/src/app/payments/x402/page.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const fetchWithPay = wrapFetchWithPayment(fetch, client, wallet);
3333
const response = await fetchWithPay('https://api.example.com/paid-endpoint');
3434
```
3535

36+
You can also use the thirdweb API to fetch any x402 compatible endpoint and pay for it with the authenticated wallet. See the [client side docs](/payments/x402/client) for more details.
37+
3638
## Server Side
3739

3840
To make your API calls payable, use the `settlePayment` function in a middleware or endpoint:
@@ -77,6 +79,8 @@ export async function GET(request: Request) {
7779
}
7880
```
7981

82+
You can also create middlewares to handle payment for multiple endpoints, see the [server side docs](/payments/x402/server) for more details. The [facilitator](/payments/x402/facilitator) handles settling the payment onchain using your own server wallet.
83+
8084
## Going Further
8185

8286
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">

0 commit comments

Comments
 (0)