x402-express-mantle 1.0.2 → 1.0.4
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/README.md +43 -31
- package/package.json +17 -6
package/README.md
CHANGED
|
@@ -14,55 +14,63 @@ Complete x402 Express middleware SDK with built-in Mantle testnet support and US
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install x402-express-mantle
|
|
17
|
+
npm install x402-express-mantle@1.0.3
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Quick Start
|
|
21
21
|
|
|
22
22
|
```javascript
|
|
23
|
-
import express from
|
|
24
|
-
import {
|
|
25
|
-
import { ExactEvmScheme } from
|
|
26
|
-
import { HTTPFacilitatorClient } from
|
|
23
|
+
import express from "express";
|
|
24
|
+
import { paymentMiddleware, x402ResourceServer } from "x402-express-mantle";
|
|
25
|
+
import { ExactEvmScheme } from "x402-evm-mantle";
|
|
26
|
+
import { HTTPFacilitatorClient } from "x402-core-mantle/http";
|
|
27
27
|
|
|
28
28
|
const app = express();
|
|
29
29
|
|
|
30
30
|
// Connect to your Mantle facilitator
|
|
31
|
-
const facilitatorClient = new HTTPFacilitatorClient({
|
|
32
|
-
url:
|
|
31
|
+
const facilitatorClient = new HTTPFacilitatorClient({
|
|
32
|
+
url: "https://your-mantle-facilitator.com",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
// Routes with automatic Mantle payment processing
|
|
36
36
|
const routes = {
|
|
37
|
-
|
|
38
|
-
accepts: [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
"GET /premium-data": {
|
|
38
|
+
accepts: [
|
|
39
|
+
{
|
|
40
|
+
scheme: "exact",
|
|
41
|
+
price: "$0.001",
|
|
42
|
+
network: "eip155:5003", // Mantle testnet (pre-configured)
|
|
43
|
+
payTo: "0xYourMantleWalletAddress",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
description: "Premium data access",
|
|
47
|
+
},
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
// Configure payment schemes (Mantle support built-in)
|
|
49
|
-
const schemes = [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const schemes = [
|
|
52
|
+
{
|
|
53
|
+
network: "eip155:5003", // Mantle testnet
|
|
54
|
+
server: new ExactEvmScheme(),
|
|
55
|
+
},
|
|
56
|
+
];
|
|
53
57
|
|
|
54
58
|
// Add payment middleware
|
|
55
|
-
app.use(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
app.use(
|
|
60
|
+
paymentMiddleware(
|
|
61
|
+
routes,
|
|
62
|
+
new x402ResourceServer(facilitatorClient).register(
|
|
63
|
+
"eip155:5003",
|
|
64
|
+
new ExactEvmScheme()
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
);
|
|
60
68
|
|
|
61
69
|
// Your protected route
|
|
62
|
-
app.get(
|
|
70
|
+
app.get("/premium-data", (req, res) => {
|
|
63
71
|
res.json({
|
|
64
|
-
data:
|
|
65
|
-
network:
|
|
72
|
+
data: "Premium Mantle content!",
|
|
73
|
+
network: "Mantle Testnet",
|
|
66
74
|
});
|
|
67
75
|
});
|
|
68
76
|
|
|
@@ -90,6 +98,7 @@ Direct middleware function using a pre-configured server instance.
|
|
|
90
98
|
Configuration-based middleware that creates the server internally.
|
|
91
99
|
|
|
92
100
|
### Core Classes
|
|
101
|
+
|
|
93
102
|
- `x402ResourceServer` - Resource server for advanced configurations
|
|
94
103
|
- `x402HTTPResourceServer` - HTTP resource server
|
|
95
104
|
- `HTTPFacilitatorClient` - Client for connecting to facilitators
|
|
@@ -134,8 +143,8 @@ This SDK includes custom Mantle configurations:
|
|
|
134
143
|
|
|
135
144
|
### Vercel
|
|
136
145
|
|
|
137
|
-
|
|
138
|
-
npm install x402-express-mantle
|
|
146
|
+
````bash
|
|
147
|
+
npm install x402-express-mantle@1.0.3
|
|
139
148
|
|
|
140
149
|
## Quick Example
|
|
141
150
|
|
|
@@ -146,15 +155,17 @@ npm install
|
|
|
146
155
|
cp .env-local .env
|
|
147
156
|
# Edit .env with your facilitator URL and EVM address
|
|
148
157
|
npm run dev
|
|
149
|
-
|
|
158
|
+
````
|
|
150
159
|
|
|
151
160
|
The example server demonstrates:
|
|
161
|
+
|
|
152
162
|
- Mantle testnet payment integration
|
|
153
163
|
- Multiple pricing tiers ($0.001 and $0.005 USDC)
|
|
154
164
|
- Free and paid endpoints
|
|
155
165
|
- Complete payment flow
|
|
156
166
|
|
|
157
167
|
# Deploy to Vercel with your environment variables
|
|
168
|
+
|
|
158
169
|
```
|
|
159
170
|
|
|
160
171
|
### Other Platforms
|
|
@@ -171,3 +182,4 @@ Works with any Node.js platform supporting Express.js.
|
|
|
171
182
|
## License
|
|
172
183
|
|
|
173
184
|
Apache-2.0
|
|
185
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x402-express-mantle",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "./
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"main": "./lib/cjs/index.js",
|
|
5
|
+
"module": "./lib/esm/index.mjs",
|
|
6
|
+
"types": "./lib/cjs/index.d.ts",
|
|
5
7
|
"type": "module",
|
|
6
8
|
"scripts": {
|
|
7
9
|
"test": "echo 'No tests specified'",
|
|
@@ -20,9 +22,9 @@
|
|
|
20
22
|
"author": "Mantle x402 Team",
|
|
21
23
|
"description": "x402 Express middleware SDK with built-in Mantle testnet support and USDC Token configurations",
|
|
22
24
|
"dependencies": {
|
|
23
|
-
"x402-core-mantle": "2.1.
|
|
24
|
-
"x402-evm-mantle": "2.1.
|
|
25
|
-
"x402-svm-mantle": "2.1.
|
|
25
|
+
"x402-core-mantle": "2.1.2-mantle",
|
|
26
|
+
"x402-evm-mantle": "2.1.2-mantle",
|
|
27
|
+
"x402-svm-mantle": "2.1.2-mantle",
|
|
26
28
|
"@solana/kit": "^2.1.1",
|
|
27
29
|
"viem": "^2.39.3",
|
|
28
30
|
"zod": "^3.24.2"
|
|
@@ -31,7 +33,16 @@
|
|
|
31
33
|
"express": "^4.0.0 || ^5.0.0"
|
|
32
34
|
},
|
|
33
35
|
"exports": {
|
|
34
|
-
".":
|
|
36
|
+
".": {
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./lib/esm/index.d.mts",
|
|
39
|
+
"default": "./lib/esm/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./lib/cjs/index.d.ts",
|
|
43
|
+
"default": "./lib/cjs/index.js"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
35
46
|
},
|
|
36
47
|
"files": [
|
|
37
48
|
"lib",
|