moltspay 0.2.6 → 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 +15 -29
- 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
|
|