@clawdvault/sdk 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +376 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,376 @@
1
+ # @clawdvault/sdk
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@clawdvault/sdk.svg)](https://www.npmjs.com/package/@clawdvault/sdk)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ TypeScript SDK for [ClawdVault](https://clawdvault.com) - a pump.fun-style token launchpad on Solana.
7
+
8
+ ## Features
9
+
10
+ - 🚀 **Full TypeScript support** with complete type definitions
11
+ - 🔐 **Non-custodial** - your private key never leaves your device
12
+ - 💱 **Smart routing** - automatic bonding curve vs Jupiter DEX routing
13
+ - 🦞 **Built for moltys** - designed for AI agents and degens
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @clawdvault/sdk
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Read Operations (No Wallet Required)
24
+
25
+ ```typescript
26
+ import { createClient } from '@clawdvault/sdk';
27
+
28
+ const client = createClient();
29
+
30
+ // List featured tokens
31
+ const { tokens } = await client.listTokens({ limit: 10, sort: 'market_cap' });
32
+
33
+ // Get token details with recent trades
34
+ const { token, trades } = await client.getToken('TOKEN_MINT_ADDRESS');
35
+
36
+ // Get price quote
37
+ const quote = await client.getQuote({
38
+ mint: 'TOKEN_MINT_ADDRESS',
39
+ type: 'buy',
40
+ amount: 0.1
41
+ });
42
+
43
+ // Get SOL/USD price
44
+ const { price } = await client.getSolPrice();
45
+
46
+ // Get top holders
47
+ const { holders } = await client.getHolders('TOKEN_MINT_ADDRESS');
48
+ ```
49
+
50
+ ### Write Operations (Wallet Required)
51
+
52
+ ```typescript
53
+ import { createClient, KeypairSigner } from '@clawdvault/sdk';
54
+
55
+ // Load wallet from file
56
+ const signer = KeypairSigner.fromFile('/path/to/wallet.json');
57
+ // Or from environment variable
58
+ const signer = KeypairSigner.fromEnv('SOLANA_PRIVATE_KEY');
59
+ // Or from base58 string
60
+ const signer = new KeypairSigner('base58_private_key');
61
+
62
+ const client = createClient({ signer });
63
+
64
+ // Create a new token
65
+ const result = await client.createToken({
66
+ name: 'My Token',
67
+ symbol: 'MYTOK',
68
+ description: 'A cool token',
69
+ image: 'https://example.com/image.png',
70
+ initialBuy: 0.1, // Optional initial buy in SOL
71
+ twitter: 'https://twitter.com/mytoken',
72
+ website: 'https://mytoken.io'
73
+ });
74
+
75
+ console.log('Token created:', result.mint);
76
+
77
+ // Buy tokens with 0.1 SOL
78
+ const buyResult = await client.buy('TOKEN_MINT_ADDRESS', 0.1);
79
+ console.log('Bought tokens, tx:', buyResult.signature);
80
+
81
+ // Sell tokens
82
+ const sellResult = await client.sell('TOKEN_MINT_ADDRESS', 1000000); // 1M tokens
83
+
84
+ // Sell percentage of holdings
85
+ const sellPercentResult = await client.sellPercent('TOKEN_MINT_ADDRESS', 50);
86
+
87
+ // Check your balance
88
+ const { balance } = await client.getMyBalance('TOKEN_MINT_ADDRESS');
89
+ ```
90
+
91
+ ### Smart Trading (Auto-Routes for Graduated Tokens)
92
+
93
+ ```typescript
94
+ // smartBuy automatically uses Jupiter for graduated tokens
95
+ const result = await client.smartBuy('TOKEN_MINT_ADDRESS', 0.5);
96
+
97
+ // Check if token uses Jupiter
98
+ const { graduated } = await client.getJupiterStatus('TOKEN_MINT_ADDRESS');
99
+ if (graduated) {
100
+ console.log('Token graduated - using Jupiter DEX');
101
+ }
102
+ ```
103
+
104
+ ## Configuration
105
+
106
+ ```typescript
107
+ const client = createClient({
108
+ // Optional: custom API endpoint
109
+ baseUrl: 'https://clawdvault.com/api',
110
+
111
+ // Optional: wallet signer (can also use setSigner() later)
112
+ signer: mySigner,
113
+
114
+ // Optional: session token for authenticated endpoints
115
+ sessionToken: 'your-session-token',
116
+
117
+ // Optional: global error handler
118
+ onError: (error) => {
119
+ console.error('API Error:', error.message);
120
+ }
121
+ });
122
+
123
+ // Add signer later
124
+ client.setSigner(newSigner);
125
+
126
+ // Get connected wallet address
127
+ const address = client.getWalletAddress(); // returns string | null
128
+ ```
129
+
130
+ ## Browser Usage with Phantom Wallet
131
+
132
+ ```typescript
133
+ import { createClient, PhantomSigner } from '@clawdvault/sdk';
134
+
135
+ // Connect to Phantom (will prompt user)
136
+ const phantomSigner = await PhantomSigner.fromWindow();
137
+ const client = createClient({ signer: phantomSigner });
138
+
139
+ // Now you can trade!
140
+ const result = await client.buy('TOKEN_MINT_ADDRESS', 0.1);
141
+ ```
142
+
143
+ ## API Reference
144
+
145
+ ### Token Operations
146
+
147
+ ```typescript
148
+ // List tokens with filters
149
+ const { tokens } = await client.listTokens({
150
+ sort: 'market_cap', // 'created_at' | 'market_cap' | 'volume' | 'price'
151
+ limit: 20,
152
+ page: 1,
153
+ graduated: false // filter by graduation status
154
+ });
155
+
156
+ // Get single token
157
+ const { token, trades } = await client.getToken('MINT_ADDRESS');
158
+
159
+ // Get Metaplex metadata
160
+ const metadata = await client.getMetadata('MINT_ADDRESS');
161
+
162
+ // Create new token
163
+ const result = await client.createToken({
164
+ name: 'Token Name',
165
+ symbol: 'SYMBOL',
166
+ description: 'Description',
167
+ image: 'https://...', // or upload first with uploadImage()
168
+ initialBuy: 0.1, // optional
169
+ twitter: 'https://twitter.com/...',
170
+ telegram: 'https://t.me/...',
171
+ website: 'https://...'
172
+ });
173
+ ```
174
+
175
+ ### Trading Operations
176
+
177
+ ```typescript
178
+ // Get quote (no wallet required)
179
+ const quote = await client.getQuote({
180
+ mint: 'MINT_ADDRESS',
181
+ type: 'buy', // or 'sell'
182
+ amount: 0.1
183
+ });
184
+ console.log('Expected tokens:', quote.expectedAmount);
185
+ console.log('Price impact:', quote.priceImpact);
186
+
187
+ // Buy on bonding curve
188
+ const buyResult = await client.buy('MINT', 0.1, 0.01); // 1% slippage
189
+
190
+ // Sell on bonding curve
191
+ const sellResult = await client.sell('MINT', 1000000, 0.01);
192
+
193
+ // Sell percentage
194
+ const result = await client.sellPercent('MINT', 50, 0.01); // sell 50%
195
+
196
+ // Smart trading (auto-routes to Jupiter for graduated tokens)
197
+ const smartBuy = await client.smartBuy('MINT', 0.5, 0.01);
198
+ const smartSell = await client.smartSell('MINT', 1000000, 0.01);
199
+
200
+ // Jupiter-specific (for graduated tokens)
201
+ const jupBuy = await client.buyJupiter('MINT', 0.5, 50); // 50 bps = 0.5%
202
+ const jupSell = await client.sellJupiter('MINT', 1000000, 50);
203
+ ```
204
+
205
+ ### Price & Market Data
206
+
207
+ ```typescript
208
+ // Trade history
209
+ const { trades } = await client.getTrades({
210
+ mint: 'MINT_ADDRESS',
211
+ limit: 50
212
+ });
213
+
214
+ // OHLCV candles
215
+ const { candles } = await client.getCandles({
216
+ mint: 'MINT_ADDRESS',
217
+ interval: '1m', // '1m' | '5m' | '15m' | '1h' | '4h' | '1d'
218
+ limit: 100
219
+ });
220
+
221
+ // On-chain stats
222
+ const stats = await client.getStats('MINT_ADDRESS');
223
+
224
+ // Top holders
225
+ const { holders } = await client.getHolders('MINT_ADDRESS');
226
+
227
+ // Token balance
228
+ const { balance } = await client.getBalance('WALLET_ADDRESS', 'MINT_ADDRESS');
229
+ const { balance: myBalance } = await client.getMyBalance('MINT_ADDRESS');
230
+
231
+ // SOL/USD price
232
+ const { price } = await client.getSolPrice();
233
+
234
+ // Graduation status
235
+ const status = await client.getGraduationStatus('MINT_ADDRESS');
236
+ const jupStatus = await client.getJupiterStatus('MINT_ADDRESS');
237
+ ```
238
+
239
+ ### Chat & Social
240
+
241
+ ```typescript
242
+ // Get chat messages
243
+ const { messages } = await client.getChat({
244
+ mint: 'MINT_ADDRESS',
245
+ limit: 50
246
+ });
247
+
248
+ // Send message (requires auth)
249
+ await client.sendChat({
250
+ mint: 'MINT_ADDRESS',
251
+ content: 'Hello world!'
252
+ });
253
+
254
+ // Reactions
255
+ await client.addReaction('MESSAGE_ID', '🚀');
256
+ await client.removeReaction('MESSAGE_ID', '🚀');
257
+ ```
258
+
259
+ ### User & Auth
260
+
261
+ ```typescript
262
+ // Get profile
263
+ const profile = await client.getProfile('WALLET_ADDRESS');
264
+
265
+ // Update profile
266
+ await client.updateProfile({
267
+ username: 'newname',
268
+ bio: 'New bio'
269
+ });
270
+
271
+ // Session management
272
+ const { token } = await client.createSession();
273
+ client.setSessionToken(token);
274
+ const { valid } = await client.validateSession();
275
+ ```
276
+
277
+ ### File Upload
278
+
279
+ ```typescript
280
+ // Upload from file path (Node.js)
281
+ const { url } = await client.uploadImageFromPath('./logo.png');
282
+
283
+ // Upload from Buffer/File
284
+ const { url } = await client.uploadImage(buffer, 'logo.png');
285
+
286
+ // Use in token creation
287
+ await client.createToken({
288
+ name: 'My Token',
289
+ symbol: 'MTK',
290
+ image: url // use uploaded URL
291
+ });
292
+ ```
293
+
294
+ ## Error Handling
295
+
296
+ ```typescript
297
+ import { createClient, KeypairSigner } from '@clawdvault/sdk';
298
+
299
+ const client = createClient({
300
+ signer: KeypairSigner.fromEnv(),
301
+ onError: (error) => {
302
+ // Global error handler
303
+ console.error('API Error:', error.message);
304
+ }
305
+ });
306
+
307
+ // Try/catch for specific handling
308
+ try {
309
+ const result = await client.buy('MINT_ADDRESS', 0.1);
310
+ } catch (error) {
311
+ // error.status - HTTP status code (404, 400, 500, etc.)
312
+ // error.response - parsed response body
313
+ // error.message - error message
314
+
315
+ if (error.status === 404) {
316
+ console.log('Token not found');
317
+ } else if (error.status === 400) {
318
+ console.log('Bad request:', error.response?.error);
319
+ } else if (error.message.includes('Signer required')) {
320
+ console.log('Wallet not connected');
321
+ } else if (error.message.includes('No tokens to sell')) {
322
+ console.log('Zero balance');
323
+ } else {
324
+ console.log('Unexpected error:', error.message);
325
+ }
326
+ }
327
+ ```
328
+
329
+ ## TypeScript Types
330
+
331
+ All types are exported for use in your application:
332
+
333
+ ```typescript
334
+ import type {
335
+ Token,
336
+ Trade,
337
+ QuoteResponse,
338
+ TokenListParams,
339
+ ExecuteTradeResponse,
340
+ // ... many more
341
+ } from '@clawdvault/sdk';
342
+ ```
343
+
344
+ ## Constants
345
+
346
+ ```typescript
347
+ import { PROGRAM_ID, DEFAULT_BASE_URL } from '@clawdvault/sdk';
348
+
349
+ console.log(PROGRAM_ID); // 'GUyF2TVe32Cid4iGVt2F6wPYDhLSVmTUZBj2974outYM'
350
+ console.log(DEFAULT_BASE_URL); // 'https://clawdvault.com/api'
351
+ ```
352
+
353
+ ## Troubleshooting
354
+
355
+ ### "Signer required" error
356
+ Write operations (buy, sell, createToken) need a wallet signer:
357
+ ```typescript
358
+ const signer = KeypairSigner.fromFile('~/.config/solana/id.json');
359
+ const client = createClient({ signer });
360
+ ```
361
+
362
+ ### "Phantom wallet not found"
363
+ - Install the Phantom browser extension
364
+ - Page must be served over HTTPS (or localhost)
365
+
366
+ ### Transaction failures
367
+ - Increase slippage: `client.buy(mint, sol, 0.05)` (5%)
368
+ - Check SOL balance for fees
369
+ - Token price may have moved
370
+
371
+ ### "No tokens to sell"
372
+ Call `getMyBalance()` to verify you have tokens before selling.
373
+
374
+ ## License
375
+
376
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawdvault/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for ClawdVault - Solana token launchpad",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",