moltspay 1.3.0 → 1.4.1
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/.env.example +14 -0
- package/README.md +319 -89
- package/dist/cdp/index.d.mts +4 -4
- package/dist/cdp/index.d.ts +4 -4
- package/dist/cdp/index.js +57 -0
- package/dist/cdp/index.js.map +1 -1
- package/dist/cdp/index.mjs +57 -0
- package/dist/cdp/index.mjs.map +1 -1
- package/dist/chains/index.d.mts +9 -8
- package/dist/chains/index.d.ts +9 -8
- package/dist/chains/index.js +57 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/index.mjs +57 -0
- package/dist/chains/index.mjs.map +1 -1
- package/dist/cli/index.js +2021 -285
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +2023 -277
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +39 -3
- package/dist/client/index.d.ts +39 -3
- package/dist/client/index.js +563 -37
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +571 -35
- package/dist/client/index.mjs.map +1 -1
- package/dist/facilitators/index.d.mts +220 -1
- package/dist/facilitators/index.d.ts +220 -1
- package/dist/facilitators/index.js +664 -1
- package/dist/facilitators/index.js.map +1 -1
- package/dist/facilitators/index.mjs +670 -1
- package/dist/facilitators/index.mjs.map +1 -1
- package/dist/{index-On9ZaGDW.d.mts → index-D_2FkLwV.d.mts} +6 -2
- package/dist/{index-On9ZaGDW.d.ts → index-D_2FkLwV.d.ts} +6 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1440 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1448 -151
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +13 -3
- package/dist/server/index.d.ts +13 -3
- package/dist/server/index.js +909 -54
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +919 -54
- package/dist/server/index.mjs.map +1 -1
- package/dist/verify/index.d.mts +1 -1
- package/dist/verify/index.d.ts +1 -1
- package/dist/verify/index.js +57 -0
- package/dist/verify/index.js.map +1 -1
- package/dist/verify/index.mjs +57 -0
- package/dist/verify/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.d.ts +3 -3
- package/dist/wallet/index.js +57 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +57 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +5 -2
- package/schemas/moltspay.services.schema.json +27 -132
package/.env.example
CHANGED
|
@@ -60,3 +60,17 @@ CDP_API_KEY_SECRET=
|
|
|
60
60
|
# https://facilitator.questflow.ai/
|
|
61
61
|
# QUESTFLOW_ENDPOINT=https://facilitator.questflow.ai
|
|
62
62
|
# QUESTFLOW_API_KEY=
|
|
63
|
+
|
|
64
|
+
# ===========================================
|
|
65
|
+
# Solana Relay Fee Payer
|
|
66
|
+
# ===========================================
|
|
67
|
+
# Private key for paying Solana transaction fees (base58 encoded)
|
|
68
|
+
# Required for server-side settlement on Solana chains
|
|
69
|
+
# SOLANA_FEE_PAYER_KEY=
|
|
70
|
+
|
|
71
|
+
# ===========================================
|
|
72
|
+
# BNB Chain Relay Fee Payer
|
|
73
|
+
# ===========================================
|
|
74
|
+
# Private key for paying BNB Chain transaction fees
|
|
75
|
+
# Required for server-side settlement on BNB chains (bsc, opbnb)
|
|
76
|
+
# BNB_SERVER_PRIVATE_KEY=
|
package/README.md
CHANGED
|
@@ -19,13 +19,14 @@ MoltsPay enables agent-to-agent commerce using the [x402 protocol](https://www.x
|
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
22
|
+
- **Skill Integration** - Add `moltspay.services.json` to any existing skill
|
|
23
|
+
- **x402 Protocol** - HTTP-native payments (402 Payment Required)
|
|
24
|
+
- **Gasless** - Both client and server pay no gas (facilitators handle it)
|
|
25
|
+
- **Payment Verification** - Automatic on-chain verification
|
|
26
|
+
- **Secure Wallet** - Spending limits, whitelist, and audit logging
|
|
27
|
+
- **Multi-chain** - Base, Polygon, Solana, BNB, Tempo (mainnet & testnet)
|
|
28
|
+
- **Agent-to-Agent** - Complete A2A payment flow support
|
|
29
|
+
- **Multi-VM** - EVM chains + Solana (SVM) with unified API
|
|
29
30
|
|
|
30
31
|
## Installation
|
|
31
32
|
|
|
@@ -51,8 +52,9 @@ export async function textToVideo({ prompt }) {
|
|
|
51
52
|
{
|
|
52
53
|
"provider": {
|
|
53
54
|
"name": "My Video Service",
|
|
54
|
-
"wallet": "
|
|
55
|
-
"
|
|
55
|
+
"wallet": "0xYOUR_EVM_WALLET_ADDRESS",
|
|
56
|
+
"solana_wallet": "YOUR_SOLANA_ADDRESS",
|
|
57
|
+
"chains": ["base", "polygon", "solana", "bnb"]
|
|
56
58
|
},
|
|
57
59
|
"services": [{
|
|
58
60
|
"id": "text-to-video",
|
|
@@ -63,6 +65,8 @@ export async function textToVideo({ prompt }) {
|
|
|
63
65
|
}
|
|
64
66
|
```
|
|
65
67
|
|
|
68
|
+
**Note:** `solana_wallet` is optional - only needed if accepting Solana payments.
|
|
69
|
+
|
|
66
70
|
**3. Start server:**
|
|
67
71
|
```bash
|
|
68
72
|
npx moltspay start ./my-skill --port 3000
|
|
@@ -74,15 +78,15 @@ That's it! Your skill now accepts x402 payments.
|
|
|
74
78
|
|
|
75
79
|
**1. Initialize wallet (one time):**
|
|
76
80
|
```bash
|
|
77
|
-
npx moltspay init
|
|
78
|
-
#
|
|
81
|
+
npx moltspay init # EVM wallet (Base, Polygon, BNB, etc.)
|
|
82
|
+
npx moltspay init --chain solana # Solana wallet (mainnet & devnet)
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
**2. Fund your wallet (US users):**
|
|
82
86
|
```bash
|
|
83
|
-
npx moltspay fund
|
|
87
|
+
npx moltspay fund 5
|
|
84
88
|
# Opens Coinbase Pay - use debit card or Apple Pay
|
|
85
|
-
# USDC arrives in
|
|
89
|
+
# USDC arrives in < 1 minutes. No ETH needed!
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
Or send USDC directly to your wallet address from any exchange.
|
|
@@ -102,53 +106,66 @@ Want to test before using real money? Use our testnet faucets:
|
|
|
102
106
|
|
|
103
107
|
```bash
|
|
104
108
|
# 1. Create wallet (if you don't have one)
|
|
105
|
-
npx moltspay init
|
|
109
|
+
npx moltspay init # EVM wallet (Base, Polygon, BNB, etc.)
|
|
110
|
+
npx moltspay init --chain solana # Solana wallet (mainnet & devnet)
|
|
106
111
|
|
|
107
|
-
# 2. Get free testnet tokens
|
|
112
|
+
# 2. Get free testnet tokens (pick one or all!)
|
|
108
113
|
npx moltspay faucet # Base Sepolia (1 USDC, once per 24h)
|
|
109
|
-
npx moltspay faucet --chain
|
|
114
|
+
npx moltspay faucet --chain solana_devnet # Solana devnet (1 USDC)
|
|
115
|
+
npx moltspay faucet --chain bnb_testnet # BNB testnet (1 USDC + 0.001 tBNB for gas)
|
|
116
|
+
npx moltspay faucet --chain tempo_moderato # Tempo testnet (1 pathUSD)
|
|
110
117
|
|
|
111
|
-
# 3. Test payments
|
|
112
|
-
#
|
|
113
|
-
npx moltspay pay https://moltspay.com/a/
|
|
118
|
+
# 3. Test payments on different chains
|
|
119
|
+
# Base Sepolia (CDP, gasless)
|
|
120
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video \
|
|
114
121
|
--chain base_sepolia --prompt "a robot dancing"
|
|
115
122
|
|
|
116
|
-
#
|
|
123
|
+
# Solana devnet (SPL transfer)
|
|
124
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video \
|
|
125
|
+
--chain solana_devnet --prompt "a cat playing piano"
|
|
126
|
+
|
|
127
|
+
# BNB testnet (gas sponsored)
|
|
128
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video \
|
|
129
|
+
--chain bnb_testnet --prompt "a sunset timelapse"
|
|
130
|
+
|
|
131
|
+
# Tempo Moderato (gas-free, MPP protocol)
|
|
117
132
|
npx moltspay pay https://server.com service-id \
|
|
118
133
|
--chain tempo_moderato --prompt "test"
|
|
119
134
|
```
|
|
120
135
|
|
|
121
136
|
## Payment Protocols
|
|
122
137
|
|
|
123
|
-
MoltsPay supports
|
|
138
|
+
MoltsPay supports multiple payment protocols, each optimized for different chains:
|
|
124
139
|
|
|
125
140
|
| Protocol | Chains | Gas | Description |
|
|
126
141
|
|----------|--------|-----|-------------|
|
|
127
|
-
| x402 | Base, Polygon
|
|
128
|
-
|
|
|
142
|
+
| x402 + CDP | Base, Polygon | Gasless (CDP pays) | HTTP 402 + EIP-3009 signatures |
|
|
143
|
+
| x402 + SOL | Solana | Gasless (server pays) | HTTP 402 + SPL transfer |
|
|
144
|
+
| x402 + BNB | BNB | Gasless (server pays) | HTTP 402 + EIP-712 intent signing |
|
|
145
|
+
| MPP | Tempo | Gas-free native | HTTP 402 + WWW-Authenticate |
|
|
129
146
|
|
|
130
147
|
### How x402 Protocol Works
|
|
131
148
|
|
|
132
149
|
```
|
|
133
150
|
Client Server CDP Facilitator
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
| | |
|
|
152
|
+
| POST /execute | |
|
|
153
|
+
| --------------------------------------------------> | |
|
|
154
|
+
| | |
|
|
155
|
+
| 402 + payment requirements | |
|
|
156
|
+
| <-------------------------------------------------- | |
|
|
157
|
+
| | |
|
|
158
|
+
| [Sign EIP-3009 - NO GAS] | |
|
|
159
|
+
| | |
|
|
160
|
+
| POST + X-Payment header | |
|
|
161
|
+
| --------------------------------------------------> | Verify signature |
|
|
162
|
+
| | --------------------------------------------------> |
|
|
163
|
+
| | |
|
|
164
|
+
| | Execute transfer (pays gas) |
|
|
165
|
+
| | <-------------------------------------------------- |
|
|
166
|
+
| | |
|
|
167
|
+
| 200 OK + result | |
|
|
168
|
+
| <-------------------------------------------------- | |
|
|
152
169
|
```
|
|
153
170
|
|
|
154
171
|
**Key insight:** Client signs a payment authorization, server submits it. Neither party pays gas - the CDP facilitator handles settlement.
|
|
@@ -159,36 +176,88 @@ MPP (Machine Payments Protocol) is simpler - client executes the transfer direct
|
|
|
159
176
|
|
|
160
177
|
```
|
|
161
178
|
Client Server
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
| |
|
|
180
|
+
| POST /service |
|
|
181
|
+
| --------------------------------------------------> |
|
|
182
|
+
| |
|
|
183
|
+
| 402 + WWW-Authenticate |
|
|
184
|
+
| <-------------------------------------------------- |
|
|
185
|
+
| |
|
|
186
|
+
| [Execute TIP-20 transfer] |
|
|
187
|
+
| [No gas needed on Tempo] |
|
|
188
|
+
| |
|
|
189
|
+
| POST + Authorization: Payment|
|
|
190
|
+
| --------------------------------------------------> |
|
|
191
|
+
| |
|
|
192
|
+
| [Server verifies on-chain] |
|
|
193
|
+
| |
|
|
194
|
+
| 200 OK + Payment-Receipt |
|
|
195
|
+
| <-------------------------------------------------- |
|
|
179
196
|
```
|
|
180
197
|
|
|
181
198
|
**Key insight:** On Tempo, the client executes the transfer directly (gas-free), then retries with the transaction hash. No CDP facilitator needed.
|
|
182
199
|
|
|
200
|
+
### How Solana Protocol Works
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Client Server (Fee Payer) Solana Network
|
|
204
|
+
| | |
|
|
205
|
+
| POST /execute | |
|
|
206
|
+
| --------------------------------------------------> | |
|
|
207
|
+
| | |
|
|
208
|
+
| 402 + payment requirements | |
|
|
209
|
+
| (includes solana_wallet) | |
|
|
210
|
+
| <-------------------------------------------------- | |
|
|
211
|
+
| | |
|
|
212
|
+
| [Sign SPL Transfer] | |
|
|
213
|
+
| [NO GAS - just signing] | |
|
|
214
|
+
| | |
|
|
215
|
+
| POST + X-Payment (signature) | |
|
|
216
|
+
| --------------------------------------------------> | Execute transfer |
|
|
217
|
+
| | (server pays ~$0.001 SOL) |
|
|
218
|
+
| | --------------------------------------------------> |
|
|
219
|
+
| | |
|
|
220
|
+
| 200 OK + result | |
|
|
221
|
+
| <-------------------------------------------------- | |
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Key insight:** Client only signs the SPL transfer (gasless). Server acts as fee payer and executes the transaction on-chain.
|
|
225
|
+
|
|
226
|
+
### How BNB Protocol Works
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
Client Server BNB Network
|
|
230
|
+
| | |
|
|
231
|
+
| POST /execute | |
|
|
232
|
+
| --------------------------------------------------> | |
|
|
233
|
+
| | |
|
|
234
|
+
| 402 + payment requirements | |
|
|
235
|
+
| (includes bnbSpender) | |
|
|
236
|
+
| <-------------------------------------------------- | |
|
|
237
|
+
| | |
|
|
238
|
+
| [Sign EIP-712 intent] | |
|
|
239
|
+
| [NO GAS - just signing] | |
|
|
240
|
+
| | |
|
|
241
|
+
| POST + X-Payment (signature) | |
|
|
242
|
+
| --------------------------------------------------> | Execute transferFrom |
|
|
243
|
+
| | (server pays ~$0.0001 gas) |
|
|
244
|
+
| | --------------------------------------------------> |
|
|
245
|
+
| | |
|
|
246
|
+
| 200 OK + result | |
|
|
247
|
+
| <-------------------------------------------------- | |
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Key insight:** Client only signs an intent (gasless). Server executes the actual transfer and pays the minimal gas (~$0.0001). This is the "pay-for-success" model - payment only happens if service succeeds.
|
|
251
|
+
|
|
183
252
|
## Skill Structure
|
|
184
253
|
|
|
185
254
|
MoltsPay reads your skill's existing structure:
|
|
186
255
|
|
|
187
256
|
```
|
|
188
257
|
my-skill/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
258
|
+
+------ package.json # MoltsPay reads "main" field
|
|
259
|
+
+------ index.js # Your existing exports
|
|
260
|
+
+------ moltspay.services.json # Only file you add!
|
|
192
261
|
```
|
|
193
262
|
|
|
194
263
|
**Your functions stay untouched.** Just add the JSON config.
|
|
@@ -281,8 +350,8 @@ Server does NOT need a private key - the x402 facilitator handles settlement.
|
|
|
281
350
|
|
|
282
351
|
The server automatically detects which chain to verify payments on based on the client's payment header:
|
|
283
352
|
|
|
284
|
-
- Client pays with `--chain base`
|
|
285
|
-
- Client pays with `--chain base_sepolia`
|
|
353
|
+
- Client pays with `--chain base` -> Server verifies on Base mainnet
|
|
354
|
+
- Client pays with `--chain base_sepolia` -> Server verifies on Base Sepolia
|
|
286
355
|
|
|
287
356
|
**No `USE_MAINNET` env var needed!** Just configure your accepted chains in the manifest.
|
|
288
357
|
|
|
@@ -305,9 +374,11 @@ Clients can then pay using `--chain base_sepolia` and get free testnet USDC via
|
|
|
305
374
|
|
|
306
375
|
```bash
|
|
307
376
|
# === Client Commands ===
|
|
308
|
-
npx moltspay init # Create wallet
|
|
377
|
+
npx moltspay init # Create wallet (EVM + Solana)
|
|
309
378
|
npx moltspay fund <amount> # Fund wallet via Coinbase (US)
|
|
310
|
-
npx moltspay faucet # Get free testnet USDC
|
|
379
|
+
npx moltspay faucet # Get free testnet USDC (Base Sepolia)
|
|
380
|
+
npx moltspay faucet --chain solana_devnet # Get Solana devnet USDC
|
|
381
|
+
npx moltspay faucet --chain bnb_testnet # Get BNB testnet USDC + tBNB
|
|
311
382
|
npx moltspay faucet --chain tempo_moderato # Get Tempo testnet tokens
|
|
312
383
|
npx moltspay status # Check balance (all chains)
|
|
313
384
|
npx moltspay config # Update limits
|
|
@@ -326,7 +397,12 @@ npx moltspay services --json # Output as JSON
|
|
|
326
397
|
# === Pay with Chain Selection ===
|
|
327
398
|
npx moltspay pay <url> <service> --chain base # Pay on Base (default)
|
|
328
399
|
npx moltspay pay <url> <service> --chain polygon # Pay on Polygon
|
|
329
|
-
npx moltspay pay <url> <service> --chain base_sepolia # Pay on testnet
|
|
400
|
+
npx moltspay pay <url> <service> --chain base_sepolia # Pay on Base testnet
|
|
401
|
+
npx moltspay pay <url> <service> --chain solana # Pay on Solana
|
|
402
|
+
npx moltspay pay <url> <service> --chain solana_devnet # Pay on Solana devnet
|
|
403
|
+
npx moltspay pay <url> <service> --chain bnb # Pay on BNB
|
|
404
|
+
npx moltspay pay <url> <service> --chain bnb_testnet # Pay on BNB testnet
|
|
405
|
+
npx moltspay pay <url> <service> --chain tempo_moderato # Pay on Tempo
|
|
330
406
|
|
|
331
407
|
# === Server Commands ===
|
|
332
408
|
npx moltspay start <skill-dir> # Start server
|
|
@@ -335,7 +411,7 @@ npx moltspay validate <path> # Validate manifest
|
|
|
335
411
|
|
|
336
412
|
# === Options ===
|
|
337
413
|
--port <port> # Server port (default 3000)
|
|
338
|
-
--chain <chain> # Chain: base, polygon,
|
|
414
|
+
--chain <chain> # Chain: base, polygon, solana, bnb, tempo_moderato, + testnets
|
|
339
415
|
--token <token> # Token: USDC, USDT
|
|
340
416
|
--max-per-tx <amount> # Spending limit per transaction
|
|
341
417
|
--max-per-day <amount> # Daily spending limit
|
|
@@ -349,16 +425,63 @@ npx moltspay validate <path> # Validate manifest
|
|
|
349
425
|
```typescript
|
|
350
426
|
import { MoltsPayClient } from 'moltspay/client';
|
|
351
427
|
|
|
352
|
-
|
|
428
|
+
// Initialize client (uses wallet from ~/.moltspay/wallet.json)
|
|
429
|
+
const client = new MoltsPayClient();
|
|
353
430
|
|
|
354
|
-
//
|
|
355
|
-
const result = await client.
|
|
356
|
-
|
|
357
|
-
|
|
431
|
+
// Standard service call (params wrapped in { params: {...} })
|
|
432
|
+
const result = await client.pay(
|
|
433
|
+
'https://server.com',
|
|
434
|
+
'text-to-video',
|
|
435
|
+
{ prompt: 'a cat dancing' },
|
|
436
|
+
{ chain: 'base' }
|
|
437
|
+
);
|
|
358
438
|
|
|
359
439
|
console.log(result.video_url);
|
|
360
440
|
```
|
|
361
441
|
|
|
442
|
+
#### Custom Input Formats (rawData)
|
|
443
|
+
|
|
444
|
+
Some services have custom input formats instead of the standard `{ params: { prompt } }`.
|
|
445
|
+
Use `rawData: true` to send your data at the top level:
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
// Service expects: { text: "...", target_lang: "..." }
|
|
449
|
+
// NOT: { params: { text: "...", target_lang: "..." } }
|
|
450
|
+
|
|
451
|
+
const result = await client.pay(
|
|
452
|
+
'https://server.com',
|
|
453
|
+
'translate',
|
|
454
|
+
{ text: 'Hello world', target_lang: 'es' },
|
|
455
|
+
{
|
|
456
|
+
chain: 'base_sepolia',
|
|
457
|
+
rawData: true // Send data at top level
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
// Server receives: { service: "translate", text: "Hello world", target_lang: "es", chain: "base_sepolia" }
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
#### PayOptions Reference
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
interface PayOptions {
|
|
468
|
+
token?: 'USDC' | 'USDT'; // Token to pay with (default: USDC)
|
|
469
|
+
autoSelect?: boolean; // Auto-select token based on balance
|
|
470
|
+
chain?: string; // Chain: base, polygon, solana, bnb, tempo_moderato, + testnets
|
|
471
|
+
rawData?: boolean; // Send data at top level (for custom input formats)
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
#### CLI Equivalent
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Standard format (uses { params: { prompt } })
|
|
479
|
+
npx moltspay pay https://server.com text-to-video --prompt "a cat dancing"
|
|
480
|
+
|
|
481
|
+
# Custom format (uses rawData, sends at top level)
|
|
482
|
+
npx moltspay pay https://server.com translate --data '{"text": "Hello", "target_lang": "es"}'
|
|
483
|
+
```
|
|
484
|
+
|
|
362
485
|
### Server
|
|
363
486
|
|
|
364
487
|
```typescript
|
|
@@ -377,15 +500,120 @@ server.listen(3000);
|
|
|
377
500
|
|
|
378
501
|
## Supported Chains
|
|
379
502
|
|
|
380
|
-
| Chain | ID | Type |
|
|
381
|
-
|
|
382
|
-
| Base | 8453 | Mainnet |
|
|
383
|
-
| Polygon | 137 | Mainnet | |
|
|
384
|
-
|
|
|
385
|
-
|
|
|
386
|
-
|
|
|
503
|
+
| Chain | ID | Type | Facilitator | Gas Model |
|
|
504
|
+
|-------|-----|------|-------------|-----------|
|
|
505
|
+
| Base | 8453 | Mainnet | CDP | Gasless (CDP pays) |
|
|
506
|
+
| Polygon | 137 | Mainnet | CDP | Gasless (CDP pays) |
|
|
507
|
+
| Base Sepolia | 84532 | Testnet | CDP | Gasless (CDP pays) |
|
|
508
|
+
| Solana | - | Mainnet | SOL | Gasless (server pays) |
|
|
509
|
+
| Solana Devnet | - | Testnet | SOL | Gasless (server pays) |
|
|
510
|
+
| BNB | 56 | Mainnet | BNB | Gasless (server pays) |
|
|
511
|
+
| BNB Testnet | 97 | Testnet | BNB | Gasless (server pays) |
|
|
512
|
+
| Tempo Moderato | 42431 | Testnet | Tempo | Gas-free native |
|
|
513
|
+
|
|
514
|
+
**Notes:**
|
|
515
|
+
- Ethereum mainnet NOT recommended (gas too expensive)
|
|
516
|
+
- Each chain uses a specialized facilitator for optimal UX
|
|
387
517
|
|
|
388
|
-
###
|
|
518
|
+
### Facilitator Architecture
|
|
519
|
+
|
|
520
|
+
A **facilitator** is the entity that executes the on-chain payment and pays the gas fees. MoltsPay supports two types:
|
|
521
|
+
|
|
522
|
+
| Type | Facilitator | Who Pays Gas? | Trust Model |
|
|
523
|
+
|------|-------------|---------------|-------------|
|
|
524
|
+
| **External** | CDP (Coinbase) | Coinbase | Trust Coinbase infrastructure |
|
|
525
|
+
| **Self-hosted** | SOL, BNB, Tempo | Your server | Trust your own server |
|
|
526
|
+
|
|
527
|
+
**External Facilitator (CDP):**
|
|
528
|
+
- Uses Coinbase Developer Platform as a third-party settlement service
|
|
529
|
+
- Coinbase handles all on-chain execution and gas fees
|
|
530
|
+
- Requires CDP API credentials
|
|
531
|
+
- Supported chains: Base, Polygon
|
|
532
|
+
|
|
533
|
+
**Self-hosted Facilitator (SOL, BNB, Tempo):**
|
|
534
|
+
- Your MoltsPay server acts as the facilitator
|
|
535
|
+
- Server pays gas fees (~$0.001 per tx)
|
|
536
|
+
- No external dependency - fully self-sovereign
|
|
537
|
+
- You control the entire payment flow
|
|
538
|
+
|
|
539
|
+
**Why Self-hosted is More Decentralized:**
|
|
540
|
+
|
|
541
|
+
| Aspect | CDP (External) | Self-hosted |
|
|
542
|
+
|--------|----------------|-------------|
|
|
543
|
+
| Single point of failure | Coinbase down = everyone stuck | Each provider independent |
|
|
544
|
+
| Censorship risk | Coinbase can block accounts | Cannot be censored |
|
|
545
|
+
| Dependency | Relies on third-party | Fully autonomous |
|
|
546
|
+
|
|
547
|
+
This self-hosted approach is a key innovation: **any service provider can become their own facilitator** without relying on third-party infrastructure. Unlike CDP where all users depend on Coinbase, self-hosted facilitators create a truly decentralized network with no single point of failure.
|
|
548
|
+
|
|
549
|
+
**Note:** Clients never need to know the facilitator's private keys. They only sign their own payments - the facilitator handles settlement transparently.
|
|
550
|
+
|
|
551
|
+
### Facilitators Explained
|
|
552
|
+
|
|
553
|
+
| Facilitator | Chains | How It Works |
|
|
554
|
+
|-------------|--------|--------------|
|
|
555
|
+
| **CDP** | Base, Polygon | Client signs EIP-3009, Coinbase executes transfer |
|
|
556
|
+
| **SOL** | Solana | Client signs SPL transfer, server executes as fee payer |
|
|
557
|
+
| **BNB** | BNB | Client signs EIP-712 intent, server executes transfer |
|
|
558
|
+
| **Tempo** | Tempo Moderato | Client executes TIP-20 transfer (native gas-free) |
|
|
559
|
+
|
|
560
|
+
### Solana Support
|
|
561
|
+
|
|
562
|
+
Solana uses the **SolanaFacilitator** with SPL token transfers. Key differences:
|
|
563
|
+
|
|
564
|
+
- **Gasless for users** - Server acts as fee payer (~$0.001 SOL per tx)
|
|
565
|
+
- **Separate wallet** - Solana uses ed25519 keys (different from EVM's secp256k1)
|
|
566
|
+
- **Wallet stored at** `~/.moltspay/wallet-solana.json`
|
|
567
|
+
- **Token** - Official Circle USDC SPL token
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
# Initialize includes Solana wallet automatically
|
|
571
|
+
npx moltspay init
|
|
572
|
+
|
|
573
|
+
# Check Solana balance
|
|
574
|
+
npx moltspay status
|
|
575
|
+
|
|
576
|
+
# Get free devnet USDC
|
|
577
|
+
npx moltspay faucet --chain solana_devnet
|
|
578
|
+
|
|
579
|
+
# Pay on Solana
|
|
580
|
+
npx moltspay pay https://server.com service-id --chain solana --prompt "test"
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
**USDC Addresses:**
|
|
584
|
+
| Network | Mint Address |
|
|
585
|
+
|---------|--------------|
|
|
586
|
+
| Mainnet | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
|
|
587
|
+
| Devnet | `4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU` |
|
|
588
|
+
|
|
589
|
+
### BNB Chain Support
|
|
590
|
+
|
|
591
|
+
BNB uses the **BNBFacilitator** with a pre-approval flow. Since CDP doesn't support BNB, we use a different approach:
|
|
592
|
+
|
|
593
|
+
1. Client signs an EIP-712 payment intent (no gas needed)
|
|
594
|
+
2. Server validates and executes the transfer
|
|
595
|
+
3. Server sponsors gas (~$0.0001 per tx)
|
|
596
|
+
|
|
597
|
+
```bash
|
|
598
|
+
# Get free testnet USDC + tBNB for gas
|
|
599
|
+
npx moltspay faucet --chain bnb_testnet
|
|
600
|
+
|
|
601
|
+
# Pay on BNB (client pays no gas!)
|
|
602
|
+
npx moltspay pay https://server.com service-id --chain bnb_testnet --prompt "test"
|
|
603
|
+
|
|
604
|
+
# Check BNB balance
|
|
605
|
+
npx moltspay status
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
**Important:** BNB tokens use 18 decimals (not 6 like Base/Polygon).
|
|
609
|
+
|
|
610
|
+
**Token Addresses (BNB Mainnet):**
|
|
611
|
+
| Token | Address |
|
|
612
|
+
|-------|---------|
|
|
613
|
+
| USDC | `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d` |
|
|
614
|
+
| USDT | `0x55d398326f99059fF775485246999027B3197955` |
|
|
615
|
+
|
|
616
|
+
### Tempo Testnet
|
|
389
617
|
|
|
390
618
|
Tempo Moderato is a gas-free testnet that supports the **MPP (Machine Payments Protocol)**. Perfect for testing agent-to-agent payments without any gas fees.
|
|
391
619
|
|
|
@@ -408,24 +636,26 @@ npx moltspay status
|
|
|
408
636
|
|
|
409
637
|
## Live Example: Zen7 Video Generation
|
|
410
638
|
|
|
411
|
-
Live service at `https://
|
|
639
|
+
Live service at `https://moltspay.com/a/zen7`
|
|
412
640
|
|
|
413
641
|
**Services:**
|
|
414
|
-
- `text-to-video` - $0.
|
|
415
|
-
- `image-to-video` - $
|
|
642
|
+
- `text-to-video` - $0.01 USDC - Generate video from text prompt
|
|
643
|
+
- `image-to-video` - $0.01 USDC - Animate a static image
|
|
416
644
|
|
|
417
|
-
**Supported Chains:** Base, Polygon
|
|
645
|
+
**Supported Chains:** Base, Polygon, Solana, BNB, Tempo (mainnet & testnet)
|
|
418
646
|
|
|
419
647
|
**Try it:**
|
|
420
648
|
```bash
|
|
421
649
|
# List services
|
|
422
|
-
npx moltspay services https://
|
|
650
|
+
npx moltspay services https://moltspay.com/a/zen7
|
|
423
651
|
|
|
424
652
|
# Pay on Base (default)
|
|
425
|
-
npx moltspay pay https://
|
|
653
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --prompt "a happy cat"
|
|
426
654
|
|
|
427
|
-
# Pay on
|
|
428
|
-
npx moltspay pay https://
|
|
655
|
+
# Pay on different chains
|
|
656
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain polygon --prompt "a happy cat"
|
|
657
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain bnb_testnet --prompt "a happy cat"
|
|
658
|
+
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain solana_devnet --prompt "a happy cat"
|
|
429
659
|
```
|
|
430
660
|
|
|
431
661
|
## Use Cases
|
|
@@ -445,7 +675,7 @@ npx moltspay pay https://juai8.com/zen7 text-to-video --chain polygon --prompt "
|
|
|
445
675
|
|
|
446
676
|
Join our Discord for help, feedback, and updates:
|
|
447
677
|
|
|
448
|
-
|
|
678
|
+
--> **[MoltsPay Discord](https://discord.gg/QwCJgVBxVK)**
|
|
449
679
|
|
|
450
680
|
Or visit the [#moltspay-support](https://discord.com/channels/1472602423267819734/1480968496346304522) channel directly.
|
|
451
681
|
|
package/dist/cdp/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as EvmChainName } from '../index-D_2FkLwV.mjs';
|
|
2
2
|
import { getChain } from '../chains/index.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ interface CDPWalletConfig {
|
|
|
14
14
|
/** Storage directory (default: ~/.moltspay) */
|
|
15
15
|
storageDir?: string;
|
|
16
16
|
/** Chain name */
|
|
17
|
-
chain?:
|
|
17
|
+
chain?: EvmChainName;
|
|
18
18
|
/** CDP API credentials (or use env vars) */
|
|
19
19
|
apiKeyId?: string;
|
|
20
20
|
apiKeySecret?: string;
|
|
@@ -26,7 +26,7 @@ interface CDPWalletData {
|
|
|
26
26
|
/** CDP wallet ID */
|
|
27
27
|
walletId: string;
|
|
28
28
|
/** Chain */
|
|
29
|
-
chain:
|
|
29
|
+
chain: EvmChainName;
|
|
30
30
|
/** Created timestamp */
|
|
31
31
|
createdAt: string;
|
|
32
32
|
/** CDP account data (for restoration) */
|
|
@@ -75,7 +75,7 @@ declare function getCDPWalletAddress(storageDir?: string): string | null;
|
|
|
75
75
|
*/
|
|
76
76
|
declare class CDPWallet {
|
|
77
77
|
readonly address: string;
|
|
78
|
-
readonly chain:
|
|
78
|
+
readonly chain: EvmChainName;
|
|
79
79
|
readonly chainConfig: ReturnType<typeof getChain>;
|
|
80
80
|
private storageDir;
|
|
81
81
|
constructor(config?: CDPWalletConfig);
|
package/dist/cdp/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as EvmChainName } from '../index-D_2FkLwV.js';
|
|
2
2
|
import { getChain } from '../chains/index.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ interface CDPWalletConfig {
|
|
|
14
14
|
/** Storage directory (default: ~/.moltspay) */
|
|
15
15
|
storageDir?: string;
|
|
16
16
|
/** Chain name */
|
|
17
|
-
chain?:
|
|
17
|
+
chain?: EvmChainName;
|
|
18
18
|
/** CDP API credentials (or use env vars) */
|
|
19
19
|
apiKeyId?: string;
|
|
20
20
|
apiKeySecret?: string;
|
|
@@ -26,7 +26,7 @@ interface CDPWalletData {
|
|
|
26
26
|
/** CDP wallet ID */
|
|
27
27
|
walletId: string;
|
|
28
28
|
/** Chain */
|
|
29
|
-
chain:
|
|
29
|
+
chain: EvmChainName;
|
|
30
30
|
/** Created timestamp */
|
|
31
31
|
createdAt: string;
|
|
32
32
|
/** CDP account data (for restoration) */
|
|
@@ -75,7 +75,7 @@ declare function getCDPWalletAddress(storageDir?: string): string | null;
|
|
|
75
75
|
*/
|
|
76
76
|
declare class CDPWallet {
|
|
77
77
|
readonly address: string;
|
|
78
|
-
readonly chain:
|
|
78
|
+
readonly chain: EvmChainName;
|
|
79
79
|
readonly chainConfig: ReturnType<typeof getChain>;
|
|
80
80
|
private storageDir;
|
|
81
81
|
constructor(config?: CDPWalletConfig);
|