@payai/x402-next-starter 0.1.5 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/package.json +7 -3
- package/template/.env-local +10 -1
- package/template/.env.example +4 -0
- package/template/.prettierignore +1 -0
- package/template/README.md +204 -54
- package/template/app/api/weather/route.ts +69 -0
- package/template/app/globals.css +16 -20
- package/template/app/layout.tsx +5 -15
- package/template/app/page.tsx +21 -8
- package/template/app/protected/page.tsx +40 -3
- package/template/eslint.config.js +1 -1
- package/template/next-env.d.ts +6 -0
- package/template/next.config.ts +1 -13
- package/template/package.json +18 -16
- package/template/postcss.config.mjs +1 -1
- package/template/proxy.ts +78 -0
- package/template/public/favicon.ico +0 -0
- package/template/public/site.webmanifest +7 -9
- package/template/public/x402-icon-black.png +0 -0
- package/template/public/x402-logo-dark.png +0 -0
- package/template/tsconfig.json +9 -2
- package/template/turbo.json +9 -0
- package/template/app/assets/x402_wordmark_dark.png +0 -0
- package/template/app/assets/x402_wordmark_dark.svg +0 -4
- package/template/app/assets/x402_wordmark_light.svg +0 -1
- package/template/app/favicon.ico +0 -0
- package/template/middleware.ts +0 -31
- package/template/package-lock.json +0 -8726
- package/template/public/apple-touch-icon.png +0 -0
- package/template/public/favicon-96x96.png +0 -0
- package/template/public/favicon.svg +0 -3
- package/template/public/web-app-manifest-192x192.png +0 -0
- package/template/public/web-app-manifest-512x512.png +0 -0
- package/template/tailwind.config.ts +0 -18
- package/template/types/svg.d.ts +0 -5
package/template/next.config.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
2
|
|
|
3
|
-
const nextConfig: NextConfig = {
|
|
4
|
-
env: {
|
|
5
|
-
RESOURCE_WALLET_ADDRESS: process.env.RESOURCE_WALLET_ADDRESS,
|
|
6
|
-
NEXT_PUBLIC_FACILITATOR_URL: process.env.NEXT_PUBLIC_FACILITATOR_URL,
|
|
7
|
-
},
|
|
8
|
-
webpack(config) {
|
|
9
|
-
config.module.rules.push({
|
|
10
|
-
test: /\.svg$/,
|
|
11
|
-
use: ["@svgr/webpack"],
|
|
12
|
-
});
|
|
13
|
-
return config;
|
|
14
|
-
},
|
|
15
|
-
};
|
|
3
|
+
const nextConfig: NextConfig = {};
|
|
16
4
|
|
|
17
5
|
export default nextConfig;
|
package/template/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "next-example",
|
|
2
|
+
"name": "@x402/next-example",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
@@ -14,29 +14,31 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@heroicons/react": "^2.2.0",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"x402
|
|
22
|
-
"@
|
|
17
|
+
"@x402/core": "^2.3.0",
|
|
18
|
+
"@x402/evm": "^2.3.0",
|
|
19
|
+
"@x402/svm": "^2.3.0",
|
|
20
|
+
"@x402/next": "^2.3.0",
|
|
21
|
+
"@x402/paywall": "^2.3.0",
|
|
22
|
+
"@x402/extensions": "^2.3.0",
|
|
23
|
+
"next": "^16.0.10",
|
|
24
|
+
"react": "^19.2.3",
|
|
25
|
+
"react-dom": "^19.2.3"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
28
|
+
"@eslint/js": "^9.24.0",
|
|
29
|
+
"@tailwindcss/postcss": "^4.0.0",
|
|
30
|
+
"@types/node": "^22.13.4",
|
|
27
31
|
"@types/react": "^19",
|
|
28
32
|
"@types/react-dom": "^19",
|
|
29
|
-
"@eslint/js": "^9.24.0",
|
|
30
|
-
"eslint": "^9.24.0",
|
|
31
|
-
"eslint-plugin-jsdoc": "^50.6.9",
|
|
32
|
-
"eslint-plugin-prettier": "^5.2.6",
|
|
33
33
|
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
34
34
|
"@typescript-eslint/parser": "^8.29.1",
|
|
35
|
+
"eslint": "^9.24.0",
|
|
36
|
+
"eslint-config-next": "16.0.6",
|
|
35
37
|
"eslint-plugin-import": "^2.31.0",
|
|
38
|
+
"eslint-plugin-jsdoc": "^50.6.9",
|
|
39
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
36
40
|
"prettier": "3.5.2",
|
|
37
|
-
"
|
|
38
|
-
"postcss": "^8",
|
|
39
|
-
"tailwindcss": "^3.4.1",
|
|
41
|
+
"tailwindcss": "^4.0.0",
|
|
40
42
|
"typescript": "^5"
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { paymentProxy } from "@x402/next";
|
|
2
|
+
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
|
|
3
|
+
import { registerExactEvmScheme } from "@x402/evm/exact/server";
|
|
4
|
+
import { registerExactSvmScheme } from "@x402/svm/exact/server";
|
|
5
|
+
import { createPaywall } from "@x402/paywall";
|
|
6
|
+
import { evmPaywall } from "@x402/paywall/evm";
|
|
7
|
+
import { svmPaywall } from "@x402/paywall/svm";
|
|
8
|
+
import { declareDiscoveryExtension } from "@x402/extensions/bazaar";
|
|
9
|
+
|
|
10
|
+
const facilitatorUrl = process.env.FACILITATOR_URL;
|
|
11
|
+
export const evmAddress = process.env.EVM_ADDRESS as `0x${string}`;
|
|
12
|
+
export const svmAddress = process.env.SVM_ADDRESS;
|
|
13
|
+
|
|
14
|
+
if (!facilitatorUrl) {
|
|
15
|
+
console.error("❌ FACILITATOR_URL environment variable is required");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!evmAddress || !svmAddress) {
|
|
20
|
+
console.error("❌ EVM_ADDRESS and SVM_ADDRESS environment variables are required");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Create HTTP facilitator client
|
|
25
|
+
const facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });
|
|
26
|
+
|
|
27
|
+
// Create x402 resource server
|
|
28
|
+
export const server = new x402ResourceServer(facilitatorClient);
|
|
29
|
+
|
|
30
|
+
// Register schemes
|
|
31
|
+
registerExactEvmScheme(server);
|
|
32
|
+
registerExactSvmScheme(server);
|
|
33
|
+
|
|
34
|
+
// Build paywall
|
|
35
|
+
export const paywall = createPaywall()
|
|
36
|
+
.withNetwork(evmPaywall)
|
|
37
|
+
.withNetwork(svmPaywall)
|
|
38
|
+
.withConfig({
|
|
39
|
+
appName: process.env.APP_NAME || "Next x402 Demo",
|
|
40
|
+
appLogo: process.env.APP_LOGO || "/x402-icon-blue.png",
|
|
41
|
+
testnet: true,
|
|
42
|
+
})
|
|
43
|
+
.build();
|
|
44
|
+
|
|
45
|
+
// Build proxy
|
|
46
|
+
export const proxy = paymentProxy(
|
|
47
|
+
{
|
|
48
|
+
"/protected": {
|
|
49
|
+
accepts: [
|
|
50
|
+
{
|
|
51
|
+
scheme: "exact",
|
|
52
|
+
price: "$0.001",
|
|
53
|
+
network: "eip155:84532", // base-sepolia
|
|
54
|
+
payTo: evmAddress,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
scheme: "exact",
|
|
58
|
+
price: "$0.001",
|
|
59
|
+
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", // solana devnet
|
|
60
|
+
payTo: svmAddress,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
description: "Premium music: x402 Remix",
|
|
64
|
+
mimeType: "text/html",
|
|
65
|
+
extensions: {
|
|
66
|
+
...declareDiscoveryExtension({}),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
server,
|
|
71
|
+
undefined, // paywallConfig (using custom paywall instead)
|
|
72
|
+
paywall, // custom paywall provider
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Configure which paths the proxy should run on
|
|
76
|
+
export const config = {
|
|
77
|
+
matcher: ["/protected/:path*"],
|
|
78
|
+
};
|
|
Binary file
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "x402.
|
|
3
|
-
"short_name": "x402",
|
|
2
|
+
"name": "x402 Next.js Demo",
|
|
3
|
+
"short_name": "x402 Demo",
|
|
4
4
|
"icons": [
|
|
5
5
|
{
|
|
6
|
-
"src": "/
|
|
6
|
+
"src": "/x402-icon-black.png",
|
|
7
7
|
"sizes": "192x192",
|
|
8
|
-
"type": "image/png"
|
|
9
|
-
"purpose": "maskable"
|
|
8
|
+
"type": "image/png"
|
|
10
9
|
},
|
|
11
10
|
{
|
|
12
|
-
"src": "/
|
|
11
|
+
"src": "/x402-icon-black.png",
|
|
13
12
|
"sizes": "512x512",
|
|
14
|
-
"type": "image/png"
|
|
15
|
-
"purpose": "maskable"
|
|
13
|
+
"type": "image/png"
|
|
16
14
|
}
|
|
17
15
|
],
|
|
18
|
-
"theme_color": "#
|
|
16
|
+
"theme_color": "#000000",
|
|
19
17
|
"background_color": "#ffffff",
|
|
20
18
|
"display": "standalone"
|
|
21
19
|
}
|
|
Binary file
|
|
Binary file
|
package/template/tsconfig.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"moduleResolution": "bundler",
|
|
12
12
|
"resolveJsonModule": true,
|
|
13
13
|
"isolatedModules": true,
|
|
14
|
-
"jsx": "
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
15
|
"incremental": true,
|
|
16
16
|
"plugins": [
|
|
17
17
|
{
|
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
"@/*": ["./*"]
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"include": [
|
|
25
|
+
"include": [
|
|
26
|
+
"types/**/*.ts",
|
|
27
|
+
"next-env.d.ts",
|
|
28
|
+
"**/*.ts",
|
|
29
|
+
"**/*.tsx",
|
|
30
|
+
".next/types/**/*.ts",
|
|
31
|
+
".next/dev/types/**/*.ts"
|
|
32
|
+
],
|
|
26
33
|
"exclude": ["node_modules"]
|
|
27
34
|
}
|
|
Binary file
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg width="156" height="48" viewBox="0 0 156 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M0.224 47L12.96 29.656L0.8 12.952H7.648L16.48 25.816H16.672L25.504 12.952H32.16L20 29.464L32.8 47H25.952L16.48 33.304H16.288L6.88 47H0.224Z" fill="#464B55"/>
|
|
3
|
-
<path d="M40.2015 35.864V31L60.0415 1.944H67.4015V30.872H74.5695V35.864H67.4015V47H61.4495V35.864H40.2015ZM46.2175 30.616V30.872H61.5775V8.536H61.2575L46.2175 30.616ZM98.355 0.983997C108.531 0.983997 114.739 7.768 114.739 18.776V29.976C114.739 41.24 108.467 47.896 98.355 47.896C88.307 47.896 81.971 41.24 81.971 29.976V18.776C81.971 7.768 88.243 0.983997 98.355 0.983997ZM98.355 42.584C104.883 42.584 108.723 37.784 108.723 29.976V18.84C108.723 11.16 104.883 6.296 98.355 6.296C91.827 6.296 87.987 11.16 87.987 18.84V29.976C87.987 37.784 91.827 42.584 98.355 42.584ZM123.485 47V41.688C123.485 36.056 126.493 32.216 133.213 28.376L142.621 23C147.741 20.056 148.829 17.176 148.829 14.296V13.528C148.829 9.304 145.885 5.912 139.869 5.912C134.045 5.912 130.333 9.368 130.269 15.384H124.381C124.509 6.232 130.973 0.983997 139.869 0.983997C149.085 0.983997 154.909 6.36 154.909 13.72C154.909 18.712 152.797 23.256 145.821 27.288L135.837 33.048C131.357 35.736 129.437 37.976 129.437 41.496V41.88H155.805V47H123.485Z" fill="white"/>
|
|
4
|
-
</svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg fill="none" height="48" viewBox="0 0 156 48" width="156" xmlns="http://www.w3.org/2000/svg"><path d="m.224 47 12.736-17.344-12.16-16.704h6.848l8.832 12.864h.192l8.832-12.864h6.656l-12.16 16.512 12.8 17.536h-6.848l-9.472-13.696h-.192l-9.408 13.696z" fill="#bfc4cf"/><path d="m40.2015 35.864v-4.864l19.84-29.056h7.36v28.928h7.168v4.992h-7.168v11.136h-5.952v-11.136zm6.016-5.248v.256h15.36v-22.336h-.32zm52.1375-29.632003c10.176 0 16.384 6.784003 16.384 17.792003v11.2c0 11.264-6.272 17.92-16.384 17.92-10.048 0-16.384-6.656-16.384-17.92v-11.2c0-11.008 6.272-17.792003 16.384-17.792003zm0 41.600003c6.528 0 10.368-4.8 10.368-12.608v-11.136c0-7.68-3.84-12.544-10.368-12.544s-10.368 4.864-10.368 12.544v11.136c0 7.808 3.84 12.608 10.368 12.608zm25.13 4.416v-5.312c0-5.632 3.008-9.472 9.728-13.312l9.408-5.376c5.12-2.944 6.208-5.824 6.208-8.704v-.768c0-4.224-2.944-7.616-8.96-7.616-5.824 0-9.536 3.456-9.6 9.472h-5.888c.128-9.152 6.592-14.400003 15.488-14.400003 9.216 0 15.04 5.376003 15.04 12.736003 0 4.992-2.112 9.536-9.088 13.568l-9.984 5.76c-4.48 2.688-6.4 4.928-6.4 8.448v.384h26.368v5.12z" fill="#000"/></svg>
|
package/template/app/favicon.ico
DELETED
|
Binary file
|
package/template/middleware.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
2
|
-
import { paymentMiddleware, Network, Resource } from "x402-next";
|
|
3
|
-
|
|
4
|
-
const facilitatorUrl = process.env.NEXT_PUBLIC_FACILITATOR_URL as Resource;
|
|
5
|
-
const payTo = process.env.RESOURCE_WALLET_ADDRESS as Address;
|
|
6
|
-
const network = process.env.NETWORK as Network;
|
|
7
|
-
|
|
8
|
-
export const middleware = paymentMiddleware(
|
|
9
|
-
payTo,
|
|
10
|
-
{
|
|
11
|
-
"/protected": {
|
|
12
|
-
price: "$0.01",
|
|
13
|
-
network,
|
|
14
|
-
config: {
|
|
15
|
-
description: "Access to protected content",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
url: facilitatorUrl,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
appName: "Next x402 Demo",
|
|
24
|
-
appLogo: "/x402-icon-blue.png",
|
|
25
|
-
},
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Configure which paths the middleware should run on
|
|
29
|
-
export const config = {
|
|
30
|
-
matcher: ["/protected/:path*"],
|
|
31
|
-
};
|