You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/settings/SponsorshipPolicies/index.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -552,7 +552,7 @@ export function AccountAbstractionSettingsPage(
Copy file name to clipboardExpand all lines: apps/portal/src/app/payments/x402/client/page.mdx
+6-34Lines changed: 6 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,46 +68,18 @@ The client library wraps the native `fetch` API and handles:
68
68
<TabsContentvalue="http">
69
69
## Prepare Payment
70
70
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.
72
72
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.
76
74
77
75
```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... \
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.
7
7
@@ -16,6 +16,13 @@ The thirdweb facilitator is compatible with any x402 backend and middleware libr
16
16
17
17
You can view all transactions processed by your facilitator in your project dashboard.
18
18
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)
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
+
36
38
## Server Side
37
39
38
40
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) {
77
79
}
78
80
```
79
81
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.
Sponsorship policies are a way to control the execution of sponsored transactions on your account.
4
+
5
+
You can use them to:
6
+
7
+
- Set global spend limits.
8
+
- Restrict sponsorship to a particular chain.
9
+
- Restrict sponsorship to a particular contract.
10
+
- Allow/Disallow specific wallets
11
+
- Setup your own server verifier.
12
+
13
+
These policies can be set from your project dashboard, under project > account abstraction > settings.
14
+
15
+
## Server Verifier
16
+
17
+
The most flexible and powerful way to control the execution of sponsored transactions is to setup your own server verifier.
18
+
19
+
In the project dashboard, under project > account abstraction > settings, setup your backend URL and any additional headers you need to pass to the verifier.
20
+
21
+
On every user transaction, your backend will be called with the transaction data and the user's wallet address, your endpoint should return a boolean indicating whether the transaction should be sponsored.
22
+
23
+
### Backend endpoint specification:
24
+
25
+
Your backend will be called with the following request:
26
+
27
+
```http
28
+
POST https://your-backend-url/verify-transaction
29
+
Content-Type: application/json
30
+
Referer: "https://api.thirdweb.com",
31
+
# additional custom headers
32
+
33
+
# request body
34
+
{
35
+
"clientId": string;
36
+
"chainId": number;
37
+
"userOp": {
38
+
sender: string;
39
+
targets: string[];
40
+
gasLimit: string;
41
+
gasPrice: string;
42
+
data?: {
43
+
targets: string[];
44
+
callDatas: string[];
45
+
values: string[];
46
+
};
47
+
}
48
+
}
49
+
```
50
+
51
+
Your backend should process the request, apply your own policy logic based on the request data and return the following JSON response:
52
+
53
+
```http
54
+
HTTP/1.1 200 OK
55
+
Content-Type: application/json
56
+
57
+
{
58
+
"isAllowed": boolean;
59
+
"reason"?: string;
60
+
}
61
+
```
62
+
63
+
The `isAllowed` field indicates whether the transaction should be sponsored or not. `reason` is an optional field that can be used to provide a reason for the decision.
0 commit comments