moltspay 0.9.6 → 1.0.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.
Files changed (43) hide show
  1. package/README.md +110 -48
  2. package/dist/cdp/index.js +1 -1
  3. package/dist/cdp/index.js.map +1 -1
  4. package/dist/cdp/index.mjs +1 -1
  5. package/dist/cdp/index.mjs.map +1 -1
  6. package/dist/chains/index.js +1 -1
  7. package/dist/chains/index.js.map +1 -1
  8. package/dist/chains/index.mjs +1 -1
  9. package/dist/chains/index.mjs.map +1 -1
  10. package/dist/cli/index.js +229 -48
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/index.mjs +229 -48
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/client/index.d.mts +11 -1
  15. package/dist/client/index.d.ts +11 -1
  16. package/dist/client/index.js +87 -7
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/index.mjs +87 -7
  19. package/dist/client/index.mjs.map +1 -1
  20. package/dist/facilitators/index.js +1 -1
  21. package/dist/facilitators/index.js.map +1 -1
  22. package/dist/facilitators/index.mjs +1 -1
  23. package/dist/facilitators/index.mjs.map +1 -1
  24. package/dist/index.js +191 -33
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +191 -33
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/server/index.d.mts +25 -5
  29. package/dist/server/index.d.ts +25 -5
  30. package/dist/server/index.js +104 -26
  31. package/dist/server/index.js.map +1 -1
  32. package/dist/server/index.mjs +104 -26
  33. package/dist/server/index.mjs.map +1 -1
  34. package/dist/verify/index.js +1 -1
  35. package/dist/verify/index.js.map +1 -1
  36. package/dist/verify/index.mjs +1 -1
  37. package/dist/verify/index.mjs.map +1 -1
  38. package/dist/wallet/index.js +1 -1
  39. package/dist/wallet/index.js.map +1 -1
  40. package/dist/wallet/index.mjs +1 -1
  41. package/dist/wallet/index.mjs.map +1 -1
  42. package/package.json +1 -1
  43. package/schemas/moltspay.services.schema.json +58 -2
package/README.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # MoltsPay
2
2
 
3
- Blockchain payment infrastructure for AI Agents. Turn any skill into a paid service with one JSON file.
3
+ [![npm version](https://img.shields.io/npm/v/moltspay.svg)](https://www.npmjs.com/package/moltspay)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
6
+
7
+ **Blockchain payment infrastructure for AI Agents.** Turn any skill into a paid service with one JSON file.
8
+
9
+ MoltsPay enables agent-to-agent commerce using the [x402 protocol](https://www.x402.org/) - HTTP-native payments where AI agents can pay each other for services without human intervention. Built on USDC stablecoins with gasless transactions powered by Coinbase CDP.
10
+
11
+ ## Why MoltsPay?
12
+
13
+ | Problem | MoltsPay Solution |
14
+ |---------|-------------------|
15
+ | AI agents can't pay for services | x402 protocol - HTTP 402 Payment Required flow |
16
+ | Blockchain payments need gas | Gasless - CDP facilitator handles all gas fees |
17
+ | Complex wallet integration | One JSON file - add `moltspay.services.json` to any skill |
18
+ | Payment verification is hard | Automatic on-chain verification included |
4
19
 
5
20
  ## Features
6
21
 
@@ -8,7 +23,7 @@ Blockchain payment infrastructure for AI Agents. Turn any skill into a paid serv
8
23
  - 🎫 **x402 Protocol** - HTTP-native payments (402 Payment Required)
9
24
  - 💨 **Gasless** - Both client and server pay no gas (CDP facilitator handles it)
10
25
  - ✅ **Payment Verification** - Automatic on-chain verification
11
- - 🔒 **Secure Wallet** - Limits, whitelist, and audit logging
26
+ - 🔒 **Secure Wallet** - Spending limits, whitelist, and audit logging
12
27
  - ⛓️ **Multi-chain** - Base, Polygon, Ethereum (mainnet & testnet)
13
28
  - 🤖 **Agent-to-Agent** - Complete A2A payment flow support
14
29
 
@@ -36,7 +51,8 @@ export async function textToVideo({ prompt }) {
36
51
  {
37
52
  "provider": {
38
53
  "name": "My Video Service",
39
- "wallet": "0xYOUR_WALLET_ADDRESS"
54
+ "wallet": "0xYOUR_WALLET_ADDRESS",
55
+ "chains": ["base", "polygon"]
40
56
  },
41
57
  "services": [{
42
58
  "id": "text-to-video",
@@ -63,13 +79,43 @@ npx moltspay init --chain base
63
79
  ```
64
80
 
65
81
  **2. Fund your wallet:**
66
- Ask your owner to send USDC to your wallet address. No ETH needed!
82
+ Send USDC to your wallet address. No ETH needed!
67
83
 
68
84
  **3. Use paid services:**
69
85
  ```bash
86
+ # Pay on Base (default)
70
87
  npx moltspay pay https://server.com text-to-video --prompt "a cat dancing"
88
+
89
+ # Pay on Polygon
90
+ npx moltspay pay https://server.com text-to-video --chain polygon --prompt "a cat dancing"
91
+ ```
92
+
93
+ ## How x402 Protocol Works
94
+
95
+ ```
96
+ Client Server CDP Facilitator
97
+ │ │ │
98
+ │ POST /execute │ │
99
+ │ ─────────────────────────> │ │
100
+ │ │ │
101
+ │ 402 + payment requirements │ │
102
+ │ <───────────────────────── │ │
103
+ │ │ │
104
+ │ [Sign EIP-3009 - NO GAS] │ │
105
+ │ │ │
106
+ │ POST + X-Payment header │ │
107
+ │ ─────────────────────────> │ Verify signature │
108
+ │ │ ─────────────────────────> │
109
+ │ │ │
110
+ │ │ Execute transfer (pays gas) │
111
+ │ │ <───────────────────────── │
112
+ │ │ │
113
+ │ 200 OK + result │ │
114
+ │ <───────────────────────── │ │
71
115
  ```
72
116
 
117
+ **Key insight:** Client signs a payment authorization, server submits it. Neither party pays gas - the CDP facilitator handles settlement.
118
+
73
119
  ## Skill Structure
74
120
 
75
121
  MoltsPay reads your skill's existing structure:
@@ -81,10 +127,6 @@ my-skill/
81
127
  └── moltspay.services.json # Only file you add!
82
128
  ```
83
129
 
84
- **Entry point discovery:**
85
- 1. If `package.json` exists → uses `main` field
86
- 2. Otherwise → defaults to `index.js`
87
-
88
130
  **Your functions stay untouched.** Just add the JSON config.
89
131
 
90
132
  ## Services Manifest Schema
@@ -96,7 +138,7 @@ my-skill/
96
138
  "name": "Service Name",
97
139
  "description": "Optional description",
98
140
  "wallet": "0x...",
99
- "chain": "base"
141
+ "chains": ["base", "polygon"]
100
142
  },
101
143
  "services": [{
102
144
  "id": "service-id",
@@ -115,12 +157,30 @@ my-skill/
115
157
  }
116
158
  ```
117
159
 
160
+ ### Multi-Chain Configuration
161
+
162
+ Accept payments on multiple chains by specifying a `chains` array:
163
+
164
+ ```json
165
+ {
166
+ "provider": {
167
+ "wallet": "0x...",
168
+ "chains": ["base", "polygon"]
169
+ }
170
+ }
171
+ ```
172
+
173
+ Clients can then choose which chain to pay on:
174
+ ```bash
175
+ npx moltspay pay https://server.com service-id --chain polygon --prompt "..."
176
+ ```
177
+
178
+ If no `--chain` is specified, the client uses the first chain in the provider's list.
179
+
118
180
  ### Validate Your Config
119
181
 
120
182
  ```bash
121
183
  npx moltspay validate ./my-skill
122
- # or
123
- npx moltspay validate ./moltspay.services.json
124
184
  ```
125
185
 
126
186
  ## Server Setup (Mainnet)
@@ -141,43 +201,21 @@ npx moltspay start ./my-skill --port 3000
141
201
 
142
202
  Server does NOT need a private key - the x402 facilitator handles settlement.
143
203
 
144
- ## How x402 Works
145
-
146
- ```
147
- Client Server CDP Facilitator
148
- │ │ │
149
- │ POST /execute │ │
150
- │ ─────────────────────────> │ │
151
- │ │ │
152
- │ 402 + payment requirements │ │
153
- │ <───────────────────────── │ │
154
- │ │ │
155
- │ [Sign EIP-3009 - NO GAS] │ │
156
- │ │ │
157
- │ POST + X-Payment header │ │
158
- │ ─────────────────────────> │ Verify signature │
159
- │ │ ─────────────────────────> │
160
- │ │ │
161
- │ │ Execute transfer (pays gas) │
162
- │ │ <───────────────────────── │
163
- │ │ │
164
- │ 200 OK + result │ │
165
- │ <───────────────────────── │ │
166
- ```
167
-
168
- **Client needs:** USDC balance only (no ETH/gas)
169
- **Server needs:** CDP credentials only (no private key)
170
-
171
204
  ## CLI Reference
172
205
 
173
206
  ```bash
174
207
  # === Client Commands ===
175
208
  npx moltspay init # Create wallet
209
+ npx moltspay init --chain polygon # Create wallet for Polygon
176
210
  npx moltspay status # Check balance
177
211
  npx moltspay config # Update limits
178
212
  npx moltspay services <url> # List provider's services
179
213
  npx moltspay pay <url> <service> # Pay and execute service
180
214
 
215
+ # === Pay with Chain Selection ===
216
+ npx moltspay pay <url> <service> --chain base # Pay on Base (default)
217
+ npx moltspay pay <url> <service> --chain polygon # Pay on Polygon
218
+
181
219
  # === Server Commands ===
182
220
  npx moltspay start <skill-dir> # Start server
183
221
  npx moltspay stop # Stop server
@@ -185,7 +223,8 @@ npx moltspay validate <path> # Validate manifest
185
223
 
186
224
  # === Options ===
187
225
  --port <port> # Server port (default 3000)
188
- --chain <chain> # Chain: base, polygon, ethereum
226
+ --chain <chain> # Chain: base, polygon (for pay/init)
227
+ --token <token> # Token: USDC, USDT
189
228
  --max-per-tx <amount> # Spending limit per transaction
190
229
  --max-per-day <amount> # Daily spending limit
191
230
  ```
@@ -227,30 +266,53 @@ server.listen(3000);
227
266
 
228
267
  | Chain | ID | Type |
229
268
  |-------|-----|------|
230
- | base | 8453 | Mainnet |
231
- | polygon | 137 | Mainnet |
232
- | ethereum | 1 | Mainnet |
233
- | base_sepolia | 84532 | Testnet |
269
+ | Base | 8453 | Mainnet |
270
+ | Polygon | 137 | Mainnet |
271
+ | Ethereum | 1 | Mainnet |
272
+ | Base Sepolia | 84532 | Testnet |
234
273
 
235
- ## Example: Zen7 Video Generation
274
+ ## Live Example: Zen7 Video Generation
236
275
 
237
276
  Live service at `https://juai8.com/zen7/`
238
277
 
239
278
  **Services:**
240
- - `text-to-video` - $0.99 USDC
241
- - `image-to-video` - $1.49 USDC
279
+ - `text-to-video` - $0.99 USDC - Generate video from text prompt
280
+ - `image-to-video` - $1.49 USDC - Animate a static image
281
+
282
+ **Supported Chains:** Base, Polygon
242
283
 
243
- **Test it:**
284
+ **Try it:**
244
285
  ```bash
286
+ # List services
245
287
  npx moltspay services https://juai8.com/zen7
288
+
289
+ # Pay on Base (default)
246
290
  npx moltspay pay https://juai8.com/zen7 text-to-video --prompt "a happy cat"
291
+
292
+ # Pay on Polygon
293
+ npx moltspay pay https://juai8.com/zen7 text-to-video --chain polygon --prompt "a happy cat"
247
294
  ```
248
295
 
296
+ ## Use Cases
297
+
298
+ - **AI Video Generation** - Pay per video generated
299
+ - **Image Processing** - Pay for AI image editing/enhancement
300
+ - **Data APIs** - Monetize proprietary datasets
301
+ - **Compute Services** - Sell GPU time to other agents
302
+ - **Content Generation** - AI writing, music, code generation
303
+
304
+ ## Related Projects
305
+
306
+ - [moltspay-python](https://github.com/Yaqing2023/moltspay-python) - Python SDK with LangChain integration
307
+ - [x402 Protocol](https://www.x402.org/) - The HTTP payment standard
308
+
249
309
  ## Links
250
310
 
311
+ - **Website:** https://moltspay.com
251
312
  - **npm:** https://www.npmjs.com/package/moltspay
252
- - **GitHub:** https://github.com/Yaqing2023/moltspay
313
+ - **PyPI:** https://pypi.org/project/moltspay/
253
314
  - **x402 Protocol:** https://www.x402.org/
315
+ - **Coinbase CDP:** https://portal.cdp.coinbase.com/
254
316
 
255
317
  ## License
256
318
 
package/dist/cdp/index.js CHANGED
@@ -30382,7 +30382,7 @@ var CHAINS = {
30382
30382
  polygon: {
30383
30383
  name: "Polygon",
30384
30384
  chainId: 137,
30385
- rpc: "https://polygon-rpc.com",
30385
+ rpc: "https://polygon-bor-rpc.publicnode.com",
30386
30386
  tokens: {
30387
30387
  USDC: {
30388
30388
  address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",