claude-sdk 0.1.3 → 0.1.5
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 +122 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,27 +2,131 @@
|
|
|
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
|
-
## Usage
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
## Memecoin trading
|
|
76
|
+
|
|
77
|
+
ClaudeSDK is designed to let Claude act as an AI trading agent on Solana, including memecoins.
|
|
78
|
+
|
|
79
|
+
How it works (high-level):
|
|
80
|
+
- The agent analyzes your instruction (e.g. “buy BONK for 0.1 SOL”).
|
|
81
|
+
- The agent returns a structured plan (token to buy/sell, amount, slippage, route).
|
|
82
|
+
- Your app validates the plan (limits, allowlists, confirmations).
|
|
83
|
+
- ClaudeSDK executes the swap via a DEX / aggregator integration (planned), then returns the transaction signature.
|
|
84
|
+
|
|
85
|
+
Important notes:
|
|
86
|
+
- Trading is risky. Memecoins are highly volatile.
|
|
87
|
+
- ClaudeSDK does NOT provide financial advice.
|
|
88
|
+
- You should use strict guardrails: max trade size, allowlist tokens, slippage caps, and manual confirmation.
|
|
89
|
+
|
|
90
|
+
Recommended guardrails for trading:
|
|
91
|
+
- Allowlist tokens (mints) that can be traded
|
|
92
|
+
- Max SOL per trade / max daily limit
|
|
93
|
+
- Max slippage (e.g. 0.5%–2%)
|
|
94
|
+
- Simulate transaction before sending
|
|
95
|
+
- Require manual confirmation for every swap (default)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Environment variables
|
|
100
|
+
|
|
101
|
+
Suggested env vars for examples:
|
|
102
|
+
|
|
103
|
+
- `CLAUDE_API_KEY` — your Claude API key (when you connect real API calls)
|
|
104
|
+
- `SOLANA_SECRET_BASE58` — Base58 secret key for a test wallet (devnet)
|
|
105
|
+
- `SOLANA_RPC_URL` — custom RPC URL (optional)
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
|
|
109
|
+
export CLAUDE_API_KEY="..."
|
|
110
|
+
export SOLANA_SECRET_BASE58="..."
|
|
111
|
+
export SOLANA_RPC_URL="https://api.devnet.solana.com"
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Roadmap
|
|
14
116
|
|
|
15
|
-
|
|
117
|
+
Planned:
|
|
118
|
+
- real Claude API integration (tool-calling / structured outputs)
|
|
119
|
+
- policy/guardrails module (limits, allowlists, confirmations)
|
|
120
|
+
- SPL token helpers (balances, transfers)
|
|
121
|
+
- transaction simulation before signing
|
|
122
|
+
- optional integrations (Phantom/Ledger) — no raw secret keys
|
|
123
|
+
- Swap module (Jupiter / DEX aggregator integration)
|
|
124
|
+
- Token discovery + validation (mint allowlist, decimals, freeze authority checks)
|
|
125
|
+
- Price/quote step before swap (expected out, price impact)
|
|
126
|
+
- Post-trade reporting (tx link, received amount, fees)
|
|
16
127
|
|
|
17
|
-
|
|
18
|
-
console.log(await agent.decide("check balance"));
|
|
128
|
+
---
|
|
19
129
|
|
|
20
|
-
|
|
21
|
-
const payer = keypairFromSource({
|
|
22
|
-
kind: "secretKeyBase58",
|
|
23
|
-
secretKeyBase58: process.env.SOLANA_SECRET_BASE58!,
|
|
24
|
-
});
|
|
130
|
+
## License
|
|
25
131
|
|
|
26
|
-
|
|
27
|
-
console.log("balance lamports:", bal);
|
|
28
|
-
```
|
|
132
|
+
MIT
|