Skip to content

Commit 0082e99

Browse files
[SDK] Add x402 recipientAddress to payment request and replace deprecated payTo (#8226)
1 parent 28955e0 commit 0082e99

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

.changeset/loud-apples-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Add optional recipientAddress to x402 settlePayment

.changeset/lucky-meals-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Expose 7702 utility functions

packages/thirdweb/src/exports/wallets/in-app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export {
5454
createSessionKey,
5555
isCreateSessionKeySupported,
5656
} from "../../extensions/erc7702/account/createSessionKey.js";
57+
5758
export type {
5859
Condition,
5960
LimitType,

packages/thirdweb/src/x402/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function decodePaymentRequest(
4444
price,
4545
network,
4646
facilitator,
47+
payTo,
4748
resourceUrl,
4849
routeConfig = {},
4950
method,
@@ -104,7 +105,7 @@ export async function decodePaymentRequest(
104105
resource: resourceUrl,
105106
description: description ?? "",
106107
mimeType: mimeType ?? "application/json",
107-
payTo: getAddress(facilitator.address),
108+
payTo: getAddress(facilitator.address), // always pay to the facilitator address first
108109
maxTimeoutSeconds: maxTimeoutSeconds ?? 300,
109110
asset: getAddress(asset.address),
110111
outputSchema: {
@@ -117,6 +118,7 @@ export async function decodePaymentRequest(
117118
output: outputSchema,
118119
},
119120
extra: {
121+
recipientAddress: payTo, // input payTo is the final recipient address
120122
...((asset as ERC20TokenAmount["asset"]).eip712 ?? {}),
121123
},
122124
});

packages/thirdweb/src/x402/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type PaymentArgs = {
3434
facilitator: ThirdwebX402Facilitator;
3535
/** Optional configuration for the payment middleware route */
3636
routeConfig?: PaymentMiddlewareConfig;
37-
/** @deprecated Use facilitator.address instead */
37+
/** Optional recipient address to receive the payment if different from your facilitator address */
3838
payTo?: string;
3939
};
4040

0 commit comments

Comments
 (0)