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/portal/src/app/wallets/server/send-transactions/page.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Send, monitor, and manage transactions. Send transactions from user or server wa
80
80
- For user wallets in React applications that use the SDK, you can obtain the user wallet auth token (JWT) with the [`useAuthToken()`](/references/typescript/v5/useAuthToken) hook.
81
81
- For user wallets in TypeScript applications, you can get it by calling `wallet.getAuthToken()` on a connected [`inAppWallet()`](/references/typescript/v5/inAppWallet) or [`ecosystemWallet()`](/references/typescript/v5/ecosystemWallet).
@@ -48,12 +52,10 @@ The client library wraps the native `fetch` API and handles:
48
52
awaitwallet.connect({ client })
49
53
50
54
// Wrap fetch with payment handling
51
-
// maxValue is the maximum payment amount in base units (defaults to 1 USDC = 1_000_000)
52
55
const fetchWithPay =wrapFetchWithPayment(
53
56
fetch,
54
57
client,
55
58
wallet,
56
-
BigInt(1*10**6) // max 1 USDC
57
59
);
58
60
59
61
// Make a request that may require payment
@@ -66,14 +68,70 @@ The client library wraps the native `fetch` API and handles:
66
68
-`fetch` - The fetch function to wrap (typically `globalThis.fetch`)
67
69
-`client` - The thirdweb client used to access RPC infrastructure
68
70
-`wallet` - The wallet used to sign payment messages
69
-
-`maxValue` - (Optional) The maximum allowed payment amount in base units (defaults to 1 USDC = 1,000,000)
71
+
-`options` - (Optional) Configuration object:
72
+
-`maxValue` - Maximum allowed payment amount in base units
73
+
-`paymentRequirementsSelector` - Custom function to select payment requirements from available options
70
74
71
75
### Reference
72
76
73
77
For full API documentation, see the [TypeScript Reference](/references/typescript/v5/x402/wrapFetchWithPayment).
74
78
75
79
</TabsContent>
76
80
81
+
<TabsContentvalue="react">
82
+
## Using `useFetchWithPayment`
83
+
84
+
The `useFetchWithPayment` hook is a React-specific wrapper that automatically handles 402 Payment Required responses with built-in UI for payment errors, insufficient funds, and wallet connection.
0 commit comments