Skip to content

Commit da26cc9

Browse files
[Portal] Move x402 from payments to top-level section
1 parent 673e51b commit da26cc9

File tree

12 files changed

+141
-40
lines changed

12 files changed

+141
-40
lines changed

apps/portal/redirects.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ const paymentRedirects = {
742742
"/payments/swap": "/bridge/swap",
743743
"/payments/tokens": "/bridge/tokens",
744744
"/payments/routes": "/bridge/routes",
745+
"/payments/x402": "/x402",
746+
"/payments/x402/:path*": "/x402/:path*",
745747
};
746748

747749
const contractRedirects = {

apps/portal/src/app/Header.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const links = [
4343
href: "/payments",
4444
name: "Payments",
4545
},
46+
{
47+
href: "/x402",
48+
name: "x402",
49+
},
4650
{
4751
href: "/bridge",
4852
name: "Bridge",

apps/portal/src/app/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ function LearningResourcesSection() {
183183
icon={PaymentsIcon}
184184
title="Payments"
185185
/>
186+
<ArticleCardIndex
187+
description="Instant payments for APIs, websites, and agents"
188+
href="/x402"
189+
icon={ZapIcon}
190+
title="x402"
191+
/>
186192
<ArticleCardIndex
187193
description="Bridge, swap, and onramp tokens on any chain"
188194
href="/bridge"

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,6 @@ export const sidebar: SideBar = {
6161
name: "Guides",
6262
},
6363
{ separator: true },
64-
{
65-
isCollapsible: false,
66-
links: [
67-
{
68-
href: `${paymentsSlug}/x402`,
69-
name: "Get Started",
70-
},
71-
{
72-
href: `${paymentsSlug}/x402/client`,
73-
name: "Client Side",
74-
},
75-
{
76-
href: `${paymentsSlug}/x402/server`,
77-
name: "Server Side",
78-
},
79-
{
80-
href: `${paymentsSlug}/x402/agents`,
81-
name: "Agents",
82-
},
83-
{
84-
href: `${paymentsSlug}/x402/facilitator`,
85-
name: "Facilitator",
86-
},
87-
],
88-
name: "x402",
89-
},
90-
{ separator: true },
9164
{
9265
isCollapsible: false,
9366
links: [
File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The client library wraps the native `fetch` API and handles:
7575
</TabsContent>
7676

7777
<TabsContent value="http">
78-
## Prepare Payment
78+
## Fetch with Payment
7979

8080
Fetch any x402-compatible API and automatically handle payment flows when APIs return a `402 Payment Required` response using the authenticated wallet.
8181

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ You can view all transactions processed by your facilitator in your project dash
2727

2828
## Chain and token support
2929

30-
Our facilitator supports payments on any EVM chain, as long as the payment token supports either:
30+
The thirdweb x402 client/server stack supports payments on [170+ EVM chains](https://thirdweb.com/chainlist?service=account-abstraction).
31+
32+
The payment token must support either:
3133

3234
- ERC-2612 permit (most ERC20 tokens)
3335
- ERC-3009 sign with authorization (USDC on all chains)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createMetadata } from "@doc";
2+
import { DocLayout } from "@/components/Layouts/DocLayout";
3+
import { sidebar } from "./sidebar";
4+
5+
export default async function Layout(props: { children: React.ReactNode }) {
6+
return (
7+
<DocLayout editPageButton={true} sideBar={sidebar}>
8+
{props.children}
9+
</DocLayout>
10+
);
11+
}
12+
13+
export const metadata = createMetadata({
14+
description:
15+
"Instant payments for your APIs, websites, and autonomous agents. x402 is an open-source protocol that turns the HTTP 402 status code into a fully-featured, on-chain payment layer.",
16+
image: {
17+
icon: "payments",
18+
title: "x402 Payments Docs",
19+
},
20+
title: "x402 Payments Documentation",
21+
});

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ export const metadata = createMetadata({
1212

1313
# x402 Payments
1414

15-
x402 is an open-source protocol that turns the dormant HTTP 402 Payment Required status code into a fully-featured, on-chain payment layer for APIs, websites, and autonomous agents.
15+
[x402](https://x402.org) is an open-source protocol that turns the dormant HTTP 402 Payment Required status code into a fully-featured, on-chain payment layer for APIs, websites, and autonomous agents.
1616

17-
Learn more about the protocol at [x402.org](https://x402.org).
1817

1918
<ArticleIconCard
2019
title="x402 Playground"
@@ -23,6 +22,15 @@ Learn more about the protocol at [x402.org](https://x402.org).
2322
href="https://playground.thirdweb.com/payments/x402"
2423
/>
2524

25+
## Chain and token support
26+
27+
The thirdweb x402 client/server stack supports payments on [170+ EVM chains](https://thirdweb.com/chainlist?service=account-abstraction).
28+
29+
The payment token must support either:
30+
31+
- ERC-2612 permit (most ERC20 tokens)
32+
- ERC-3009 sign with authorization (USDC on all chains)
33+
2634
## Client Side
2735

2836
`wrapFetchWithPayment` wraps the native fetch API to automatically handle `402 Payment Required` responses from any x402-compatible API:
@@ -42,7 +50,7 @@ const fetchWithPay = wrapFetchWithPayment(fetch, client, wallet);
4250
const response = await fetchWithPay('https://api.example.com/paid-endpoint');
4351
```
4452

45-
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.
53+
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](/x402/client) for more details.
4654

4755
## Server Side
4856

@@ -88,7 +96,7 @@ export async function GET(request: Request) {
8896
}
8997
```
9098

91-
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.
99+
You can also create middlewares to handle payment for multiple endpoints, see the [server side docs](/x402/server) for more details. The [facilitator](/x402/facilitator) handles settling the payment onchain using your own server wallet.
92100

93101
## Going Further
94102

@@ -97,18 +105,18 @@ You can also create middlewares to handle payment for multiple endpoints, see th
97105
title="Client Side"
98106
description="Learn how to interact with x402-compatible APIs from your client applications"
99107
icon={TypeScriptIcon}
100-
href="/payments/x402/client"
108+
href="/x402/client"
101109
/>
102110
<ArticleIconCard
103111
title="Server Side"
104112
description="Accept x402 payments in your APIs with middleware or dedicated endpoints"
105113
icon={EngineIcon}
106-
href="/payments/x402/server"
114+
href="/x402/server"
107115
/>
108116
<ArticleIconCard
109117
title="Facilitator API"
110118
description="Configure the facilitator service to verify and settle payments"
111119
icon={EngineIcon}
112-
href="/payments/x402/facilitator"
120+
href="/x402/facilitator"
113121
/>
114122
</div>

apps/portal/src/app/payments/x402/server/page.mdx renamed to apps/portal/src/app/x402/server/page.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,23 +421,31 @@ Protect multiple endpoints with a shared middleware:
421421
</TabsContent>
422422
</Tabs>
423423

424-
## Price Configuration
424+
## Price and Token Configuration
425425

426426
You can specify prices in multiple ways:
427427

428428
### USD String
429429

430+
This will default to using USDC on the specified network.
431+
430432
```typescript
431-
price: "$0.10" // 10 cents in USD
433+
network: polygon, // or any other EVM chain
434+
price: "$0.10" // 10 cents in USDC
432435
```
433436

434437
### ERC20 Token
435438

439+
You can use any ERC20 token that supports the ERC-2612 permit or ERC-3009 sign with authorization.
440+
441+
Simply pass the amount in base units and the token address.
442+
436443
```typescript
444+
network: arbitrum,
437445
price: {
438-
amount: "100000", // Amount in base units (100000 = 0.1 USDC with 6 decimals)
446+
amount: "1000000000000000", // Amount in base units (0.001 tokens with 18 decimals)
439447
asset: {
440-
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Token address
448+
address: "0xf01E52B0BAC3E147f6CAf956a64586865A0aA928", // Token address
441449
}
442450
}
443451
```

0 commit comments

Comments
 (0)