@mixrpay/agent-sdk 0.8.6 → 0.8.9

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
@@ -2,15 +2,71 @@
2
2
 
3
3
  Enable AI agents to make payments to MixrPay-powered APIs.
4
4
 
5
+ ## Getting Started: Claim an Access Code
6
+
7
+ Agents get spending authorization by claiming an **Access Code** from a human wallet owner.
8
+
9
+ ### Step 1: Human Creates Access Code
10
+
11
+ The human logs in at [mixrpay.com/manage/invites](https://www.mixrpay.com/manage/invites), deposits funds, and creates an Access Code (e.g., `mixr-abc123`) with a budget.
12
+
13
+ ### Step 2: Agent Claims the Access Code
14
+
15
+ ```typescript
16
+ import { AgentWallet } from '@mixrpay/agent-sdk';
17
+
18
+ // Claim the Access Code to get your session key
19
+ const result = await AgentWallet.claimInvite({
20
+ inviteCode: 'mixr-abc123', // From the human
21
+ privateKey: process.env.AGENT_WALLET_KEY as `0x${string}`,
22
+ });
23
+
24
+ // IMPORTANT: Save this immediately — shown ONCE, cannot be recovered!
25
+ console.log('Session Key:', result.sessionKey); // sk_live_xxx
26
+ console.log('Budget:', result.limits.budgetUsd);
27
+ console.log('Invited by:', result.inviterName);
28
+ ```
29
+
30
+ ### Step 3: Use the Session Key
31
+
32
+ ```typescript
33
+ const wallet = new AgentWallet({
34
+ sessionKey: result.sessionKey, // or process.env.MIXRPAY_SESSION_KEY
35
+ });
36
+
37
+ // All spending is authorized from the human's wallet
38
+ const response = await wallet.fetch('https://api.example.com/paid-endpoint');
39
+ ```
40
+
41
+ ## Understanding Wallet Addresses
42
+
43
+ When you claim an Access Code, two addresses are involved:
44
+
45
+ | Address | What it is | Purpose |
46
+ |---------|-----------|---------|
47
+ | `info.address` | Session key's derived address | Used for signing requests |
48
+ | `info.walletAddress` | Human's funded wallet | Where funds are charged FROM |
49
+
50
+ **Verify which wallet you're spending from:**
51
+
52
+ ```typescript
53
+ const info = await wallet.getSessionKeyInfo();
54
+ console.log('Session key:', info.address); // Your signing key
55
+ console.log('Spending from:', info.walletAddress); // Human's wallet (funding source)
56
+ console.log('Budget remaining:', info.limits.totalUsd);
57
+ ```
58
+
59
+ This is important: your session key authorizes spending from the **human's wallet**, not your own external wallet. The human controls the budget and can revoke access at any time.
60
+
5
61
  ## Important: Session Key Security
6
62
 
7
63
  Your session key (`sk_live_...`) is a **private key**. Treat it like a password:
8
64
 
9
- - **Save it immediately** when you receive it (from `claimInvite()` or dashboard)
65
+ - **Save it immediately** when you receive it (from `claimInvite()`)
10
66
  - **Store it securely** (environment variable, secrets manager)
11
67
  - **Never commit it** to version control
12
68
  - **Never log it** to console or files
13
- - **It cannot be recovered** if lost - you will need a new invite
69
+ - **It cannot be recovered** if lost - you will need a new Access Code
14
70
 
15
71
  The session key is shown **only once** when claimed. MixrPay does not store it.
16
72
 
@@ -39,8 +95,6 @@ const response = await wallet.callMerchantApi({
39
95
  const data = await response.json();
40
96
  ```
41
97
 
42
- Get session keys at [mixrpay.com/wallet/sessions](https://www.mixrpay.com/wallet/sessions).
43
-
44
98
  ## Core Methods
45
99
 
46
100
  ```typescript