moltspay 0.2.6 → 0.2.8
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 +25 -40
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +6 -14
- package/dist/index.d.ts +6 -14
- package/dist/index.js +25 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,26 +98,14 @@ npx moltspay init --chain base
|
|
|
98
98
|
# Storage: ~/.moltspay
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
**Owner signs (CLI or MetaMask):**
|
|
107
|
-
```bash
|
|
108
|
-
# Owner runs this with their private key
|
|
109
|
-
npx moltspay sign-permit \
|
|
110
|
-
--owner 0xOWNER_METAMASK \
|
|
111
|
-
--spender 0xAGENT_ADDRESS \
|
|
112
|
-
--amount 50 \
|
|
113
|
-
--deadline $(date -d '+7 days' +%s) \
|
|
114
|
-
--nonce 0 \
|
|
115
|
-
--chain base
|
|
116
|
-
```
|
|
101
|
+
**Owner funds the Agent (one-time):**
|
|
102
|
+
- Agent tells Owner its wallet address
|
|
103
|
+
- Owner sends USDC to the agent's address using Coinbase, MetaMask, etc.
|
|
104
|
+
- No complex signatures needed — just a simple transfer
|
|
117
105
|
|
|
118
|
-
**Agent
|
|
106
|
+
**Agent pays for services:**
|
|
119
107
|
```bash
|
|
120
|
-
npx moltspay
|
|
108
|
+
npx moltspay transfer --to 0xSERVICE_PROVIDER --amount 0.99 --chain base
|
|
121
109
|
```
|
|
122
110
|
|
|
123
111
|
### Code Example (Auto-Initialize)
|
|
@@ -128,19 +116,17 @@ import { AgentWallet } from 'moltspay';
|
|
|
128
116
|
// Auto-creates wallet on first use (no gas needed)
|
|
129
117
|
const wallet = new AgentWallet({ chain: 'base' });
|
|
130
118
|
console.log('Agent address:', wallet.address);
|
|
119
|
+
// Tell Owner to send USDC to this address
|
|
131
120
|
|
|
132
|
-
//
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
amount: 50, // $50 USDC allowance
|
|
136
|
-
});
|
|
137
|
-
console.log(request.message); // Send to Owner
|
|
138
|
-
|
|
139
|
-
// After Owner signs, store permit
|
|
140
|
-
wallet.storePermit(ownerPermit);
|
|
121
|
+
// Check balance
|
|
122
|
+
const balance = await wallet.getBalance();
|
|
123
|
+
console.log('USDC balance:', balance.usdc);
|
|
141
124
|
|
|
142
|
-
// Pay for services
|
|
143
|
-
const result = await wallet.
|
|
125
|
+
// Pay for services
|
|
126
|
+
const result = await wallet.transfer({
|
|
127
|
+
to: '0xServiceProvider...',
|
|
128
|
+
amount: 0.99,
|
|
129
|
+
});
|
|
144
130
|
console.log('Paid:', result.txHash);
|
|
145
131
|
```
|
|
146
132
|
|
|
@@ -238,25 +224,24 @@ Standard templates for natural A2A dialogue:
|
|
|
238
224
|
import { SellerTemplates, BuyerTemplates, parseStatusMarker } from 'moltspay';
|
|
239
225
|
|
|
240
226
|
// Seller templates
|
|
241
|
-
SellerTemplates.askPaymentCapability()
|
|
242
|
-
SellerTemplates.guideInstall()
|
|
243
|
-
SellerTemplates.guideFunding()
|
|
244
|
-
SellerTemplates.guidePermit(agentAddr, 10) // "请向 Boss 发送..."
|
|
227
|
+
SellerTemplates.askPaymentCapability() // "Do you have USDC payment capability?"
|
|
228
|
+
SellerTemplates.guideInstall() // "Install moltspay and init wallet..."
|
|
229
|
+
SellerTemplates.guideFunding(agentAddr, 10) // "Ask Owner to send USDC to your wallet"
|
|
245
230
|
SellerTemplates.quote({ service, price, recipientAddress })
|
|
246
231
|
SellerTemplates.verificationPassed(amount)
|
|
247
232
|
SellerTemplates.deliver({ downloadUrl, fileHash })
|
|
248
233
|
SellerTemplates.receipt(receipt)
|
|
249
234
|
|
|
250
235
|
// Buyer templates
|
|
251
|
-
BuyerTemplates.requestService('
|
|
252
|
-
BuyerTemplates.noCapability()
|
|
253
|
-
BuyerTemplates.walletCreated(address)
|
|
254
|
-
BuyerTemplates.
|
|
255
|
-
BuyerTemplates.
|
|
256
|
-
BuyerTemplates.paymentSent(txHash, amount)
|
|
236
|
+
BuyerTemplates.requestService('video generation')
|
|
237
|
+
BuyerTemplates.noCapability() // "I don't have a wallet"
|
|
238
|
+
BuyerTemplates.walletCreated(address) // "[status:wallet_ready]"
|
|
239
|
+
BuyerTemplates.fundingReceived(10) // "[status:funded USDC=10]"
|
|
240
|
+
BuyerTemplates.requestFunding(addr, 10) // "Owner, please send USDC to my wallet"
|
|
241
|
+
BuyerTemplates.paymentSent(txHash, amount) // "[status:payment_sent tx=...]"
|
|
257
242
|
|
|
258
243
|
// Parse status markers from messages
|
|
259
|
-
const status = parseStatusMarker('[
|
|
244
|
+
const status = parseStatusMarker('[status:payment_sent tx=0xabc amount=3.99 USDC]');
|
|
260
245
|
// { type: 'payment_sent', data: { txHash: '0xabc', amount: '3.99' } }
|
|
261
246
|
```
|
|
262
247
|
|