moltspay 0.9.6 → 0.9.7
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 +68 -45
- package/dist/cli/index.js +23 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +23 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.js +11 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +11 -1
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# MoltsPay
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/moltspay)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](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** -
|
|
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
|
|
|
@@ -63,13 +78,39 @@ npx moltspay init --chain base
|
|
|
63
78
|
```
|
|
64
79
|
|
|
65
80
|
**2. Fund your wallet:**
|
|
66
|
-
|
|
81
|
+
Send USDC to your wallet address. No ETH needed!
|
|
67
82
|
|
|
68
83
|
**3. Use paid services:**
|
|
69
84
|
```bash
|
|
70
85
|
npx moltspay pay https://server.com text-to-video --prompt "a cat dancing"
|
|
71
86
|
```
|
|
72
87
|
|
|
88
|
+
## How x402 Protocol Works
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Client Server CDP Facilitator
|
|
92
|
+
│ │ │
|
|
93
|
+
│ POST /execute │ │
|
|
94
|
+
│ ─────────────────────────> │ │
|
|
95
|
+
│ │ │
|
|
96
|
+
│ 402 + payment requirements │ │
|
|
97
|
+
│ <───────────────────────── │ │
|
|
98
|
+
│ │ │
|
|
99
|
+
│ [Sign EIP-3009 - NO GAS] │ │
|
|
100
|
+
│ │ │
|
|
101
|
+
│ POST + X-Payment header │ │
|
|
102
|
+
│ ─────────────────────────> │ Verify signature │
|
|
103
|
+
│ │ ─────────────────────────> │
|
|
104
|
+
│ │ │
|
|
105
|
+
│ │ Execute transfer (pays gas) │
|
|
106
|
+
│ │ <───────────────────────── │
|
|
107
|
+
│ │ │
|
|
108
|
+
│ 200 OK + result │ │
|
|
109
|
+
│ <───────────────────────── │ │
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Key insight:** Client signs a payment authorization, server submits it. Neither party pays gas - the CDP facilitator handles settlement.
|
|
113
|
+
|
|
73
114
|
## Skill Structure
|
|
74
115
|
|
|
75
116
|
MoltsPay reads your skill's existing structure:
|
|
@@ -81,10 +122,6 @@ my-skill/
|
|
|
81
122
|
└── moltspay.services.json # Only file you add!
|
|
82
123
|
```
|
|
83
124
|
|
|
84
|
-
**Entry point discovery:**
|
|
85
|
-
1. If `package.json` exists → uses `main` field
|
|
86
|
-
2. Otherwise → defaults to `index.js`
|
|
87
|
-
|
|
88
125
|
**Your functions stay untouched.** Just add the JSON config.
|
|
89
126
|
|
|
90
127
|
## Services Manifest Schema
|
|
@@ -119,8 +156,6 @@ my-skill/
|
|
|
119
156
|
|
|
120
157
|
```bash
|
|
121
158
|
npx moltspay validate ./my-skill
|
|
122
|
-
# or
|
|
123
|
-
npx moltspay validate ./moltspay.services.json
|
|
124
159
|
```
|
|
125
160
|
|
|
126
161
|
## Server Setup (Mainnet)
|
|
@@ -141,33 +176,6 @@ npx moltspay start ./my-skill --port 3000
|
|
|
141
176
|
|
|
142
177
|
Server does NOT need a private key - the x402 facilitator handles settlement.
|
|
143
178
|
|
|
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
179
|
## CLI Reference
|
|
172
180
|
|
|
173
181
|
```bash
|
|
@@ -227,30 +235,45 @@ server.listen(3000);
|
|
|
227
235
|
|
|
228
236
|
| Chain | ID | Type |
|
|
229
237
|
|-------|-----|------|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
233
|
-
|
|
|
238
|
+
| Base | 8453 | Mainnet |
|
|
239
|
+
| Polygon | 137 | Mainnet |
|
|
240
|
+
| Ethereum | 1 | Mainnet |
|
|
241
|
+
| Base Sepolia | 84532 | Testnet |
|
|
234
242
|
|
|
235
|
-
## Example: Zen7 Video Generation
|
|
243
|
+
## Live Example: Zen7 Video Generation
|
|
236
244
|
|
|
237
245
|
Live service at `https://juai8.com/zen7/`
|
|
238
246
|
|
|
239
247
|
**Services:**
|
|
240
|
-
- `text-to-video` - $0.99 USDC
|
|
241
|
-
- `image-to-video` - $1.49 USDC
|
|
248
|
+
- `text-to-video` - $0.99 USDC - Generate video from text prompt
|
|
249
|
+
- `image-to-video` - $1.49 USDC - Animate a static image
|
|
242
250
|
|
|
243
|
-
**
|
|
251
|
+
**Try it:**
|
|
244
252
|
```bash
|
|
245
253
|
npx moltspay services https://juai8.com/zen7
|
|
246
254
|
npx moltspay pay https://juai8.com/zen7 text-to-video --prompt "a happy cat"
|
|
247
255
|
```
|
|
248
256
|
|
|
257
|
+
## Use Cases
|
|
258
|
+
|
|
259
|
+
- **AI Video Generation** - Pay per video generated
|
|
260
|
+
- **Image Processing** - Pay for AI image editing/enhancement
|
|
261
|
+
- **Data APIs** - Monetize proprietary datasets
|
|
262
|
+
- **Compute Services** - Sell GPU time to other agents
|
|
263
|
+
- **Content Generation** - AI writing, music, code generation
|
|
264
|
+
|
|
265
|
+
## Related Projects
|
|
266
|
+
|
|
267
|
+
- [moltspay-python](https://github.com/Yaqing2023/moltspay-python) - Python SDK with LangChain integration
|
|
268
|
+
- [x402 Protocol](https://www.x402.org/) - The HTTP payment standard
|
|
269
|
+
|
|
249
270
|
## Links
|
|
250
271
|
|
|
272
|
+
- **Website:** https://moltspay.com
|
|
251
273
|
- **npm:** https://www.npmjs.com/package/moltspay
|
|
252
|
-
- **
|
|
274
|
+
- **PyPI:** https://pypi.org/project/moltspay/
|
|
253
275
|
- **x402 Protocol:** https://www.x402.org/
|
|
276
|
+
- **Coinbase CDP:** https://portal.cdp.coinbase.com/
|
|
254
277
|
|
|
255
278
|
## License
|
|
256
279
|
|
package/dist/cli/index.js
CHANGED
|
@@ -293,7 +293,17 @@ var MoltsPayClient = class {
|
|
|
293
293
|
throw new Error(`Insufficient balance: need $${amount}, have ${balances.usdc} USDC / ${balances.usdt} USDT`);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
if (token === "USDT") {
|
|
297
|
+
const balances = await this.getBalance();
|
|
298
|
+
if (balances.native < 1e-4) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`USDT requires ETH for gas (~$0.01 on Base). Your ETH balance: ${balances.native.toFixed(6)} ETH. Please add a small amount of ETH to your wallet, or use USDC (gasless).`
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
console.log(`[MoltsPay] \u26A0\uFE0F USDT requires gas (~$0.01). Proceeding with payment...`);
|
|
304
|
+
} else {
|
|
305
|
+
console.log(`[MoltsPay] Signing payment: $${amount} ${token} (gasless)`);
|
|
306
|
+
}
|
|
297
307
|
const payTo = req.payTo || req.resource;
|
|
298
308
|
if (!payTo) {
|
|
299
309
|
throw new Error("Missing payTo address in payment requirements");
|
|
@@ -2036,6 +2046,18 @@ program.command("pay <server> <service> [params]").description("Pay for a servic
|
|
|
2036
2046
|
}
|
|
2037
2047
|
const imageDisplay = params.image_url || (params.image_base64 ? `[local file: ${options.image}]` : null);
|
|
2038
2048
|
const token = (options.token || "USDC").toUpperCase();
|
|
2049
|
+
if (token === "USDT") {
|
|
2050
|
+
const balance = await client.getBalance();
|
|
2051
|
+
if (balance.native < 1e-4) {
|
|
2052
|
+
console.log("\n\u26A0\uFE0F USDT requires a small amount of ETH for gas (~$0.01)");
|
|
2053
|
+
console.log(` Your ETH balance: ${balance.native.toFixed(6)} ETH`);
|
|
2054
|
+
console.log(" Please add a tiny amount of ETH to your wallet.\n");
|
|
2055
|
+
process.exit(1);
|
|
2056
|
+
}
|
|
2057
|
+
if (!options.json) {
|
|
2058
|
+
console.log("\n\u26A0\uFE0F Note: USDT payments require gas (~$0.01 on Base)");
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2039
2061
|
if (!options.json) {
|
|
2040
2062
|
console.log(`
|
|
2041
2063
|
\u{1F4B3} MoltsPay - Paying for service
|