create-mantle-facilitator 0.4.3 → 0.4.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 +60 -114
- package/package.json +1 -1
- package/template/README.md +47 -23
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ CLI tool to scaffold a self-hosted x402 payment facilitator for Mantle blockchai
|
|
|
8
8
|
## Quick Start
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npx create-mantle-facilitator
|
|
12
|
-
cd my-facilitator
|
|
11
|
+
npx create-mantle-facilitator
|
|
12
|
+
cd my-facilitator # or the name you chose
|
|
13
13
|
npm install
|
|
14
14
|
npm run dev
|
|
15
15
|
```
|
|
@@ -23,8 +23,7 @@ Welcome to Mantle Facilitator Setup!
|
|
|
23
23
|
? RPC URL for Mantle network: https://rpc.mantle.xyz
|
|
24
24
|
? Facilitator wallet private key: (optional, set later)
|
|
25
25
|
? USDC contract address: 0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9
|
|
26
|
-
? Enable telemetry?
|
|
27
|
-
? Enter PROJECT_KEY from dashboard: (optional)
|
|
26
|
+
? Enable telemetry? (Send anonymous usage stats) No
|
|
28
27
|
|
|
29
28
|
✓ Done! Your facilitator is ready.
|
|
30
29
|
```
|
|
@@ -45,10 +44,13 @@ PORT=8080
|
|
|
45
44
|
NETWORK_ID=mantle-mainnet
|
|
46
45
|
CHAIN_ID=5000
|
|
47
46
|
|
|
48
|
-
# Telemetry (
|
|
49
|
-
TELEMETRY_PROJECT_KEY=
|
|
47
|
+
# Telemetry (Optional - always present in .env)
|
|
48
|
+
# TELEMETRY_PROJECT_KEY=your_project_key_here
|
|
49
|
+
# Get your key from https://x402mantlesdk.xyz/dashboard
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
**Note:** The telemetry section is always added to `.env` (commented out if disabled during setup). To enable later, just uncomment and add your project key.
|
|
53
|
+
|
|
52
54
|
### Important Notes
|
|
53
55
|
|
|
54
56
|
- **FACILITATOR_PRIVATE_KEY**: This wallet will pay gas fees for all settlements. Make sure it has MNT for gas.
|
|
@@ -89,50 +91,43 @@ npm start
|
|
|
89
91
|
|
|
90
92
|
Facilitator runs on `http://localhost:8080` by default.
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Deployment
|
|
95
|
-
|
|
96
|
-
### Railway (Recommended)
|
|
94
|
+
### Startup Banner
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
# Install Railway CLI
|
|
100
|
-
npm install -g @railway/cli
|
|
96
|
+
When the facilitator starts successfully, you'll see a banner:
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
```
|
|
99
|
+
+--------------------------------------------------+
|
|
100
|
+
| Mantle x402 Facilitator |
|
|
101
|
+
+--------------------------------------------------+
|
|
102
|
+
| Network: mantle-mainnet (5000) |
|
|
103
|
+
| Address: 0xAbcd...ef01 |
|
|
104
|
+
| Port: 8080 |
|
|
105
|
+
| Telemetry: disabled |
|
|
106
|
+
+--------------------------------------------------+
|
|
107
|
+
|
|
108
|
+
Note: Telemetry is disabled.
|
|
109
|
+
To enable analytics, set TELEMETRY_PROJECT_KEY in .env
|
|
110
|
+
Get your key at https://x402mantlesdk.xyz/dashboard
|
|
111
|
+
|
|
112
|
+
Server listening on http://localhost:8080
|
|
106
113
|
```
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
### Configuration Validation
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
The facilitator validates all required environment variables at startup with helpful error messages:
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
5. Set start command: `npm start`
|
|
117
|
-
6. Add environment variables
|
|
119
|
+
- **FACILITATOR_PRIVATE_KEY**: Must be 66 chars (0x + 64 hex digits)
|
|
120
|
+
- **FACILITATOR_SECRET**: Required for secure authentication
|
|
121
|
+
- **RPC_URL**: Must be valid URL (http:// or https://)
|
|
122
|
+
- **USDC_ADDRESS**: Must be valid Ethereum address
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
If validation fails, you'll see step-by-step fix instructions in the console.
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
# Install Fly CLI and login
|
|
123
|
-
flyctl auth login
|
|
126
|
+
---
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
flyctl launch
|
|
128
|
+
## Deployment
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
flyctl secrets set FACILITATOR_PRIVATE_KEY=0x...
|
|
130
|
-
flyctl secrets set RPC_URL=https://rpc.mantle.xyz
|
|
131
|
-
flyctl secrets set USDC_ADDRESS=0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9
|
|
132
|
-
|
|
133
|
-
# Deploy
|
|
134
|
-
flyctl deploy
|
|
135
|
-
```
|
|
130
|
+
Deploy your facilitator to any Node.js hosting platform.
|
|
136
131
|
|
|
137
132
|
### Docker
|
|
138
133
|
|
|
@@ -152,27 +147,16 @@ docker build -t my-facilitator .
|
|
|
152
147
|
docker run -p 8080:8080 --env-file .env my-facilitator
|
|
153
148
|
```
|
|
154
149
|
|
|
155
|
-
###
|
|
150
|
+
### Railway
|
|
156
151
|
|
|
157
152
|
```bash
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
npm run build
|
|
163
|
-
|
|
164
|
-
# Install PM2 for process management
|
|
165
|
-
npm install -g pm2
|
|
166
|
-
|
|
167
|
-
# Start with PM2
|
|
168
|
-
pm2 start dist/index.js --name facilitator
|
|
169
|
-
|
|
170
|
-
# Save process list and setup startup script
|
|
171
|
-
pm2 save
|
|
172
|
-
pm2 startup
|
|
153
|
+
npm install -g @railway/cli
|
|
154
|
+
railway login
|
|
155
|
+
railway init
|
|
156
|
+
railway up
|
|
173
157
|
```
|
|
174
158
|
|
|
175
|
-
|
|
159
|
+
Then add environment variables in Railway dashboard.
|
|
176
160
|
|
|
177
161
|
---
|
|
178
162
|
|
|
@@ -299,6 +283,25 @@ The facilitator uses EIP-3009 `transferWithAuthorization` which allows:
|
|
|
299
283
|
|
|
300
284
|
---
|
|
301
285
|
|
|
286
|
+
## Supported Tokens
|
|
287
|
+
|
|
288
|
+
Currently, the facilitator supports **USDC only** for gasless payments.
|
|
289
|
+
|
|
290
|
+
### Why only USDC?
|
|
291
|
+
|
|
292
|
+
Gasless payments require tokens that implement the **EIP-3009** standard (`transferWithAuthorization`). This standard allows users to sign a payment authorization off-chain, while the facilitator submits the transaction and pays gas fees.
|
|
293
|
+
|
|
294
|
+
On Mantle mainnet, **USDC is currently the only token** that implements EIP-3009. As other stablecoins and tokens adopt this standard, we will add support for them.
|
|
295
|
+
|
|
296
|
+
| Token | EIP-3009 Support | Status |
|
|
297
|
+
|-------|------------------|--------|
|
|
298
|
+
| USDC | Yes | Supported |
|
|
299
|
+
| USDT | No | Not available |
|
|
300
|
+
| DAI | No | Not available |
|
|
301
|
+
| Other tokens | — | Pending EIP-3009 adoption |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
302
305
|
## Telemetry
|
|
303
306
|
|
|
304
307
|
When `TELEMETRY_PROJECT_KEY` is set, the facilitator sends anonymous analytics:
|
|
@@ -331,63 +334,6 @@ Telemetry errors never affect payment processing — if analytics backend is dow
|
|
|
331
334
|
2. **Private Key Security**
|
|
332
335
|
- Never commit `.env` to git
|
|
333
336
|
- Use secret management in production (Railway secrets, Fly secrets, etc.)
|
|
334
|
-
- Consider using hardware wallets for high-value facilitators
|
|
335
|
-
|
|
336
|
-
3. **Gas Management**
|
|
337
|
-
- Monitor MNT balance regularly
|
|
338
|
-
- Set up alerts for low balance
|
|
339
|
-
- Facilitator needs ~0.001 MNT per settlement
|
|
340
|
-
|
|
341
|
-
4. **Network Security**
|
|
342
|
-
- Use HTTPS in production
|
|
343
|
-
- Consider rate limiting
|
|
344
|
-
- Monitor for unusual patterns
|
|
345
|
-
|
|
346
|
-
---
|
|
347
|
-
|
|
348
|
-
## Monitoring
|
|
349
|
-
|
|
350
|
-
Check facilitator health:
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
# Check if running
|
|
354
|
-
curl http://your-facilitator.com/health
|
|
355
|
-
|
|
356
|
-
# Check wallet balance
|
|
357
|
-
curl http://your-facilitator.com/health | jq '.mntBalance'
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
Set up monitoring alerts for:
|
|
361
|
-
- Health endpoint availability
|
|
362
|
-
- Low MNT balance (< 0.1 MNT)
|
|
363
|
-
- High error rates
|
|
364
|
-
|
|
365
|
-
---
|
|
366
|
-
|
|
367
|
-
## Troubleshooting
|
|
368
|
-
|
|
369
|
-
### "Missing env var: FACILITATOR_PRIVATE_KEY"
|
|
370
|
-
|
|
371
|
-
Set the private key in `.env`:
|
|
372
|
-
```env
|
|
373
|
-
FACILITATOR_PRIVATE_KEY=0x...
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
### "Insufficient funds for gas"
|
|
377
|
-
|
|
378
|
-
The facilitator wallet needs MNT for gas fees. Send some MNT to the facilitator address shown in `/health`.
|
|
379
|
-
|
|
380
|
-
### "Invalid signature"
|
|
381
|
-
|
|
382
|
-
- Check that the client is signing for the correct network (Mantle mainnet, chainId 5000)
|
|
383
|
-
- Verify USDC address matches: `0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9`
|
|
384
|
-
|
|
385
|
-
### Port already in use
|
|
386
|
-
|
|
387
|
-
Change the port in `.env`:
|
|
388
|
-
```env
|
|
389
|
-
PORT=8081
|
|
390
|
-
```
|
|
391
337
|
|
|
392
338
|
---
|
|
393
339
|
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -16,6 +16,27 @@ npm run dev
|
|
|
16
16
|
|
|
17
17
|
Facilitator runs on `http://localhost:8080`.
|
|
18
18
|
|
|
19
|
+
## Startup Information
|
|
20
|
+
|
|
21
|
+
When the facilitator starts, it displays a banner with:
|
|
22
|
+
- Network and chain ID (Mantle mainnet, 5000)
|
|
23
|
+
- Facilitator wallet address
|
|
24
|
+
- Port
|
|
25
|
+
- Telemetry status
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
+--------------------------------------------------+
|
|
29
|
+
| Mantle x402 Facilitator |
|
|
30
|
+
+--------------------------------------------------+
|
|
31
|
+
| Network: mantle-mainnet (5000) |
|
|
32
|
+
| Address: 0xAbcd...ef01 |
|
|
33
|
+
| Port: 8080 |
|
|
34
|
+
| Telemetry: disabled |
|
|
35
|
+
+--------------------------------------------------+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If telemetry is disabled, you'll see instructions to enable it.
|
|
39
|
+
|
|
19
40
|
## Configuration
|
|
20
41
|
|
|
21
42
|
Edit `.env` file:
|
|
@@ -30,10 +51,22 @@ FACILITATOR_SECRET=fac_xxx... # Auto-generated, share with your backend
|
|
|
30
51
|
PORT=8080
|
|
31
52
|
USDC_ADDRESS=0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9
|
|
32
53
|
|
|
33
|
-
# Telemetry (
|
|
34
|
-
TELEMETRY_PROJECT_KEY=
|
|
54
|
+
# Telemetry (Optional - always present in .env)
|
|
55
|
+
# TELEMETRY_PROJECT_KEY=your_project_key_here
|
|
56
|
+
# Get your key from https://x402mantlesdk.xyz/dashboard
|
|
35
57
|
```
|
|
36
58
|
|
|
59
|
+
### Configuration Validation
|
|
60
|
+
|
|
61
|
+
Required variables are validated at startup with helpful error messages:
|
|
62
|
+
|
|
63
|
+
- **FACILITATOR_PRIVATE_KEY** - Must be 66 chars (0x + 64 hex)
|
|
64
|
+
- **FACILITATOR_SECRET** - Required for secure authentication
|
|
65
|
+
- **RPC_URL** - Must be valid URL
|
|
66
|
+
- **USDC_ADDRESS** - Must be valid Ethereum address
|
|
67
|
+
|
|
68
|
+
If validation fails, you'll see step-by-step fix instructions.
|
|
69
|
+
|
|
37
70
|
**Important:**
|
|
38
71
|
- The facilitator wallet needs MNT for gas fees. Check balance at `/health`.
|
|
39
72
|
- Copy `FACILITATOR_SECRET` to your backend's environment variables.
|
|
@@ -84,36 +117,27 @@ npm start # Run production build
|
|
|
84
117
|
|
|
85
118
|
## Deployment
|
|
86
119
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
railway login
|
|
91
|
-
railway init
|
|
92
|
-
railway up
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Add environment variables in Railway dashboard.
|
|
96
|
-
|
|
97
|
-
### Docker
|
|
120
|
+
Deploy to any Node.js hosting platform. Examples:
|
|
98
121
|
|
|
99
122
|
```bash
|
|
123
|
+
# Docker
|
|
100
124
|
docker build -t facilitator .
|
|
101
125
|
docker run -p 8080:8080 --env-file .env facilitator
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### PM2 (VPS)
|
|
105
126
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
pm2 start dist/index.js --name facilitator
|
|
127
|
+
# Railway
|
|
128
|
+
railway login && railway init && railway up
|
|
109
129
|
```
|
|
110
130
|
|
|
111
131
|
## Telemetry
|
|
112
132
|
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
|
|
133
|
+
The `TELEMETRY_PROJECT_KEY` setting is always present in `.env`:
|
|
134
|
+
- If enabled during setup: filled with your key
|
|
135
|
+
- If disabled: commented out (easy to enable later)
|
|
136
|
+
|
|
137
|
+
**To enable telemetry:**
|
|
138
|
+
1. Get key from https://x402mantlesdk.xyz/dashboard
|
|
139
|
+
2. Uncomment `TELEMETRY_PROJECT_KEY` in `.env`
|
|
140
|
+
3. Restart facilitator
|
|
117
141
|
|
|
118
142
|
**What is sent:** buyer address, amount, asset, txHash, timestamp
|
|
119
143
|
|