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 CHANGED
@@ -98,26 +98,14 @@ npx moltspay init --chain base
98
98
  # Storage: ~/.moltspay
99
99
  ```
100
100
 
101
- **Request Owner authorization (one-time):**
102
- ```bash
103
- npx moltspay auth-request --owner 0xOWNER_METAMASK --amount 50 --chain base
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 spends within allowance:**
106
+ **Agent pays for services:**
119
107
  ```bash
120
- npx moltspay spend --to 0xSERVICE_PROVIDER --amount 0.99 --chain base
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
- // Generate auth request for Owner
133
- const request = await wallet.generateAuthRequest({
134
- ownerAddress: '0xOWNER...',
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 (USDC comes from Owner's wallet)
143
- const result = await wallet.spend('0xServiceProvider...', 0.99);
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() // "你是否具备链上支付 USDC 的能力?"
242
- SellerTemplates.guideInstall() // "请安装 moltspay..."
243
- SellerTemplates.guideFunding() // "A) 直接转账 B) Permit授权"
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.choosePermit() // "我选择 B"
255
- BuyerTemplates.permitReceived(10) // "[状态:已具备支付额度 USDC=10]"
256
- BuyerTemplates.paymentSent(txHash, amount) // "[状态:已发起支付 tx=...]"
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('[状态:已发起支付 tx=0xabc amount=3.99 USDC]');
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