moltspay 0.2.5 → 0.2.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 +53 -1
- 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 +35 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,7 +80,59 @@ Complete support for pure-conversation payment between AI Agents.
|
|
|
80
80
|
START → 能力识别 → 能力协商 → Onboarding → 服务请求 → 报价 → 支付 → 验证 → 交付 → 收据 → END
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
###
|
|
83
|
+
### Client Agent: Auto-Setup (Recommended - v0.2.5+)
|
|
84
|
+
|
|
85
|
+
The simplest way for a client agent to get started:
|
|
86
|
+
|
|
87
|
+
**First-time setup is automatic:**
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Install (agent does this automatically when calling a paid service)
|
|
90
|
+
npm install moltspay
|
|
91
|
+
|
|
92
|
+
# 2. Initialize wallet (automatic, no gas needed)
|
|
93
|
+
npx moltspay init --chain base
|
|
94
|
+
|
|
95
|
+
# Output:
|
|
96
|
+
# ✅ Agent wallet initialized
|
|
97
|
+
# Address: 0xABC123...
|
|
98
|
+
# Storage: ~/.moltspay
|
|
99
|
+
```
|
|
100
|
+
|
|
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
|
|
105
|
+
|
|
106
|
+
**Agent pays for services:**
|
|
107
|
+
```bash
|
|
108
|
+
npx moltspay transfer --to 0xSERVICE_PROVIDER --amount 0.99 --chain base
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Code Example (Auto-Initialize)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { AgentWallet } from 'moltspay';
|
|
115
|
+
|
|
116
|
+
// Auto-creates wallet on first use (no gas needed)
|
|
117
|
+
const wallet = new AgentWallet({ chain: 'base' });
|
|
118
|
+
console.log('Agent address:', wallet.address);
|
|
119
|
+
// Tell Owner to send USDC to this address
|
|
120
|
+
|
|
121
|
+
// Check balance
|
|
122
|
+
const balance = await wallet.getBalance();
|
|
123
|
+
console.log('USDC balance:', balance.usdc);
|
|
124
|
+
|
|
125
|
+
// Pay for services
|
|
126
|
+
const result = await wallet.transfer({
|
|
127
|
+
to: '0xServiceProvider...',
|
|
128
|
+
amount: 0.99,
|
|
129
|
+
});
|
|
130
|
+
console.log('Paid:', result.txHash);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Buyer Agent: Create Wallet & Pay (Manual)
|
|
134
|
+
|
|
135
|
+
For more control, you can manually manage wallet creation:
|
|
84
136
|
|
|
85
137
|
```typescript
|
|
86
138
|
import { createWallet, loadWallet, PermitWallet } from 'moltspay';
|