claude-sdk 0.1.2 → 0.1.4
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 +96 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,23 +2,104 @@
|
|
|
2
2
|
|
|
3
3
|
SDK for managing Solana wallets with an AI agent (Claude).
|
|
4
4
|
|
|
5
|
+
> Goal: give an AI agent a *safe* way to propose wallet actions (read balance, build tx, send tx),
|
|
6
|
+
> while **private keys stay local** and every action can be validated and confirmed.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
5
10
|
## Install
|
|
6
|
-
```bash
|
|
7
|
-
npm i claude-sdk
|
|
8
|
-
```
|
|
9
|
-
import { Connection } from "@solana/web3.js";
|
|
10
|
-
import { ClaudeAgent, keypairFromSource, getBalanceLamports } from "claude-sdk";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
npm i claude-sdk
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
### 1) Check RPC + ask agent for a plan
|
|
19
|
+
|
|
20
|
+
import { Connection } from "@solana/web3.js";
|
|
21
|
+
import { ClaudeAgent } from "claude-sdk";
|
|
22
|
+
|
|
23
|
+
const conn = new Connection("https://api.devnet.solana.com");
|
|
24
|
+
console.log("slot:", await conn.getSlot());
|
|
25
|
+
|
|
26
|
+
const agent = new ClaudeAgent({ apiKey: process.env.CLAUDE_API_KEY ?? "dummy" });
|
|
27
|
+
console.log(await agent.decide("check balance"));
|
|
28
|
+
|
|
29
|
+
### 2) Read wallet balance (keys stay local)
|
|
30
|
+
|
|
31
|
+
import { Connection } from "@solana/web3.js";
|
|
32
|
+
import { keypairFromSource, getBalanceLamports } from "claude-sdk";
|
|
33
|
+
|
|
34
|
+
const conn = new Connection("https://api.devnet.solana.com");
|
|
35
|
+
|
|
36
|
+
// DO NOT commit secrets
|
|
37
|
+
const payer = keypairFromSource({
|
|
38
|
+
kind: "secretKeyBase58",
|
|
39
|
+
secretKeyBase58: process.env.SOLANA_SECRET_BASE58!,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const bal = await getBalanceLamports(conn, payer.publicKey);
|
|
43
|
+
console.log("balance lamports:", bal);
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## What this package provides
|
|
48
|
+
|
|
49
|
+
### Solana helpers (local signing)
|
|
50
|
+
- `keypairFromSource(...)` — load a `Keypair` from Base58 or JSON secret key
|
|
51
|
+
- `getBalanceLamports(conn, pubkey)` — get SOL balance in lamports
|
|
52
|
+
- `transferSol(conn, payer, to, lamports)` — send SOL (signs locally)
|
|
53
|
+
|
|
54
|
+
### Agent interface (Claude)
|
|
55
|
+
- `ClaudeAgent` — returns a structured decision (currently a stub; you can plug real Claude API calls)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Security model (important)
|
|
60
|
+
|
|
61
|
+
This SDK is designed with a strict rule:
|
|
62
|
+
|
|
63
|
+
- **Private keys never go to Claude**
|
|
64
|
+
- Claude returns a *plan* (structured actions)
|
|
65
|
+
- Your app validates the plan (limits, allowlists, confirmations)
|
|
66
|
+
- Only then a transaction is signed locally and sent
|
|
67
|
+
|
|
68
|
+
Recommended safety checks in your app:
|
|
69
|
+
- allowlist destination addresses
|
|
70
|
+
- max lamports per tx
|
|
71
|
+
- require manual confirmation for transfers
|
|
72
|
+
- run on devnet while testing
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Environment variables
|
|
77
|
+
|
|
78
|
+
Suggested env vars for examples:
|
|
79
|
+
|
|
80
|
+
- `CLAUDE_API_KEY` — your Claude API key (when you connect real API calls)
|
|
81
|
+
- `SOLANA_SECRET_BASE58` — Base58 secret key for a test wallet (devnet)
|
|
82
|
+
- `SOLANA_RPC_URL` — custom RPC URL (optional)
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
|
|
86
|
+
export CLAUDE_API_KEY="..."
|
|
87
|
+
export SOLANA_SECRET_BASE58="..."
|
|
88
|
+
export SOLANA_RPC_URL="https://api.devnet.solana.com"
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Roadmap
|
|
93
|
+
|
|
94
|
+
Planned:
|
|
95
|
+
- real Claude API integration (tool-calling / structured outputs)
|
|
96
|
+
- policy/guardrails module (limits, allowlists, confirmations)
|
|
97
|
+
- SPL token helpers (balances, transfers)
|
|
98
|
+
- transaction simulation before signing
|
|
99
|
+
- optional integrations (Phantom/Ledger) — no raw secret keys
|
|
13
100
|
|
|
14
|
-
|
|
15
|
-
console.log(await agent.decide("check balance"));
|
|
101
|
+
---
|
|
16
102
|
|
|
17
|
-
|
|
18
|
-
const payer = keypairFromSource({
|
|
19
|
-
kind: "secretKeyBase58",
|
|
20
|
-
secretKeyBase58: process.env.SOLANA_SECRET_BASE58!,
|
|
21
|
-
});
|
|
103
|
+
## License
|
|
22
104
|
|
|
23
|
-
|
|
24
|
-
console.log("balance lamports:", bal);
|
|
105
|
+
MIT
|