@velociti/sdk 0.1.0 → 0.2.0

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/dist/types.d.ts CHANGED
@@ -10,6 +10,12 @@ export interface VelocitiConfig {
10
10
  network?: 'mainnet' | 'devnet';
11
11
  /** Custom API base URL (optional) */
12
12
  baseUrl?: string;
13
+ /** Enable retry logic for failed requests */
14
+ enableRetry?: boolean;
15
+ /** Max retry attempts (default: 3) */
16
+ maxRetries?: number;
17
+ /** Retry delay in ms (default: 1000) */
18
+ retryDelay?: number;
13
19
  }
14
20
  /** Token deployment configuration */
15
21
  export interface DeployTokenParams {
@@ -32,6 +38,25 @@ export interface DeployTokenParams {
32
38
  website?: string;
33
39
  };
34
40
  }
41
+ /** Batch deploy parameters */
42
+ export interface BatchDeployParams {
43
+ /** Array of tokens to deploy */
44
+ tokens: DeployTokenParams[];
45
+ /** Single payer for all tokens */
46
+ payerAddress: string;
47
+ }
48
+ /** Batch deploy result */
49
+ export interface BatchDeployResult {
50
+ /** Individual results for each token */
51
+ results: Array<{
52
+ index: number;
53
+ success: boolean;
54
+ mintAddress?: string;
55
+ error?: string;
56
+ }>;
57
+ /** Total estimated fee for all tokens */
58
+ totalEstimatedFee: number;
59
+ }
35
60
  /** Prepared transaction ready for signing */
36
61
  export interface PreparedTransaction {
37
62
  /** Base64 encoded serialized transaction */
@@ -80,6 +105,29 @@ export interface TokenInfo {
80
105
  /** Created at timestamp */
81
106
  createdAt: string;
82
107
  }
108
+ /** Token analytics data */
109
+ export interface TokenAnalytics {
110
+ /** Token mint address */
111
+ mintAddress: string;
112
+ /** Price history (hourly for last 24h) */
113
+ priceHistory: Array<{
114
+ timestamp: number;
115
+ price: number;
116
+ volume: number;
117
+ }>;
118
+ /** 24h volume in SOL */
119
+ volume24h: number;
120
+ /** 24h price change percentage */
121
+ priceChange24h: number;
122
+ /** Number of unique holders */
123
+ holders: number;
124
+ /** Total number of trades */
125
+ trades: number;
126
+ /** All-time high price in SOL */
127
+ allTimeHigh: number;
128
+ /** All-time low price in SOL */
129
+ allTimeLow: number;
130
+ }
83
131
  /** Fee claiming result */
84
132
  export interface ClaimFeesResult {
85
133
  /** Transaction signature */
@@ -100,6 +148,31 @@ export interface SubmitResult {
100
148
  /** Error message if failed */
101
149
  error?: string;
102
150
  }
151
+ /** Webhook configuration */
152
+ export interface WebhookConfig {
153
+ /** Webhook URL to receive events */
154
+ url: string;
155
+ /** Events to subscribe to */
156
+ events: WebhookEvent[];
157
+ /** Optional secret for signature verification */
158
+ secret?: string;
159
+ }
160
+ /** Webhook event types */
161
+ export type WebhookEvent = 'token.created' | 'token.graduated' | 'token.trade' | 'fees.claimed' | 'fees.available';
162
+ /** Webhook payload */
163
+ export interface WebhookPayload {
164
+ /** Event type */
165
+ event: WebhookEvent;
166
+ /** Event timestamp */
167
+ timestamp: number;
168
+ /** Event data */
169
+ data: {
170
+ mintAddress: string;
171
+ [key: string]: unknown;
172
+ };
173
+ /** Signature for verification */
174
+ signature?: string;
175
+ }
103
176
  /** API response wrapper */
104
177
  export interface ApiResponse<T> {
105
178
  success: boolean;
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@velociti/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official SDK for deploying and managing tokens on VELOCITI - the Solana tax token launchpad",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "velociti": "./dist/cli.js"
9
+ },
7
10
  "scripts": {
8
11
  "build": "tsc",
9
12
  "test": "jest",
10
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "docs": "typedoc --out docs/api src/index.ts"
11
15
  },
12
16
  "keywords": [
13
17
  "solana",
@@ -16,7 +20,9 @@
16
20
  "velociti",
17
21
  "tax-token",
18
22
  "token-2022",
19
- "ai-agent"
23
+ "ai-agent",
24
+ "cli",
25
+ "sdk"
20
26
  ],
21
27
  "author": "VELOCITI",
22
28
  "license": "MIT",
@@ -25,11 +31,24 @@
25
31
  },
26
32
  "devDependencies": {
27
33
  "@types/node": "^20.0.0",
34
+ "typedoc": "^0.25.0",
28
35
  "typescript": "^5.3.0"
29
36
  },
30
37
  "repository": {
31
38
  "type": "git",
32
39
  "url": "https://github.com/Velociti-Launchpad/velociti-sdk"
33
40
  },
34
- "homepage": "https://velociti.fun/developers"
41
+ "homepage": "https://velociti.fun/developers",
42
+ "bugs": {
43
+ "url": "https://github.com/Velociti-Launchpad/velociti-sdk/issues"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "README.md",
48
+ "LICENSE",
49
+ "CHANGELOG.md"
50
+ ],
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ }
35
54
  }
@@ -1,73 +0,0 @@
1
- # Getting Started with VELOCITI SDK
2
-
3
- This guide will help you set up and deploy your first token using the VELOCITI SDK.
4
-
5
- ## Prerequisites
6
-
7
- - Node.js 18+
8
- - npm or yarn
9
- - A VELOCITI API key
10
-
11
- ## Step 1: Get Your API Key
12
-
13
- 1. Visit [velociti.fun/developers](https://velociti.fun/developers)
14
- 2. Fill out the access request form with:
15
- - Your name and email
16
- - Project name and description
17
- - Intended use case
18
- 3. Wait for approval (usually within 24 hours)
19
- 4. Check your email for your API key
20
-
21
- ## Step 2: Install the SDK
22
-
23
- ```bash
24
- npm install @velociti/sdk
25
- ```
26
-
27
- ## Step 3: Initialize the Client
28
-
29
- ```typescript
30
- import { VelocitiClient } from '@velociti/sdk';
31
-
32
- const client = new VelocitiClient({
33
- apiKey: process.env.VELOCITI_API_KEY,
34
- network: 'devnet' // Start with devnet for testing
35
- });
36
- ```
37
-
38
- ## Step 4: Deploy Your First Token
39
-
40
- ```typescript
41
- const result = await client.deployToken({
42
- name: 'My First Token',
43
- symbol: 'MFT',
44
- description: 'My first token on VELOCITI',
45
- taxRate: 5, // 5% transfer tax
46
- });
47
-
48
- if (result.success) {
49
- console.log('Token deployed!', result.data?.mintAddress);
50
- } else {
51
- console.error('Failed:', result.error);
52
- }
53
- ```
54
-
55
- ## Step 5: Monitor and Claim Fees
56
-
57
- ```typescript
58
- // Check unclaimed fees
59
- const fees = await client.getUnclaimedFees(result.data.mintAddress);
60
- console.log('Unclaimed fees:', fees.data?.amount);
61
-
62
- // Claim fees to your wallet
63
- const claim = await client.claimFees(
64
- result.data.mintAddress,
65
- 'YourWalletAddress...'
66
- );
67
- ```
68
-
69
- ## Next Steps
70
-
71
- - Explore the [API Reference](./api-reference.md)
72
- - Check out [examples](../examples/)
73
- - Join our [Discord](https://discord.gg/velociti) for support
@@ -1,75 +0,0 @@
1
- /**
2
- * Example: Deploy a token on VELOCITI
3
- *
4
- * This example shows the 2-step flow:
5
- * 1. Prepare transaction (API builds it with all program addresses)
6
- * 2. Sign & submit (you pay the fees)
7
- *
8
- * Run with: npx ts-node examples/deploy-token.ts
9
- */
10
-
11
- import { VelocitiClient } from '../src';
12
- import { Keypair, Transaction } from '@solana/web3.js';
13
-
14
- async function main() {
15
- // Initialize the client with your API key
16
- const client = new VelocitiClient({
17
- apiKey: process.env.VELOCITI_API_KEY || 'your-api-key',
18
- network: 'devnet',
19
- });
20
-
21
- // Your wallet (in production, use wallet adapter)
22
- const wallet = Keypair.generate(); // Demo only!
23
-
24
- console.log('🚀 Preparing token deployment...\n');
25
- console.log(` Wallet: ${wallet.publicKey.toBase58()}`);
26
-
27
- // Step 1: Prepare the transaction
28
- // The API builds the full transaction with all program addresses,
29
- // PDAs, and accounts. You don't need to know any internal details!
30
- const prepared = await client.prepareTokenDeploy({
31
- name: 'My AI Token',
32
- symbol: 'AIT',
33
- description: 'A token deployed by an AI agent',
34
- taxRate: 5,
35
- payerAddress: wallet.publicKey.toBase58(), // You pay the fees
36
- socials: {
37
- twitter: '@myaitoken',
38
- website: 'https://myaitoken.com',
39
- },
40
- });
41
-
42
- if (!prepared.success || !prepared.data) {
43
- console.error('❌ Prepare failed:', prepared.error);
44
- return;
45
- }
46
-
47
- console.log('\n📋 Transaction prepared:');
48
- console.log(` Mint Address: ${prepared.data.mintAddress}`);
49
- console.log(` Estimated Fee: ${prepared.data.estimatedFee} SOL`);
50
-
51
- // Step 2: Sign the transaction with your wallet
52
- const tx = Transaction.from(Buffer.from(prepared.data.transaction, 'base64'));
53
- tx.sign(wallet); // In production: await walletAdapter.signTransaction(tx)
54
-
55
- // Step 3: Submit the signed transaction
56
- const signedBase64 = tx.serialize().toString('base64');
57
- const result = await client.submitTransaction(signedBase64);
58
-
59
- if (!result.success) {
60
- console.error('❌ Deployment failed:', result.error);
61
- return;
62
- }
63
-
64
- console.log('\n✅ Token deployed successfully!');
65
- console.log(` Signature: ${result.data?.signature}`);
66
- console.log(` View: https://velociti.fun/token/${prepared.data.mintAddress}`);
67
-
68
- // Check rate limit
69
- const rateLimit = client.getRateLimitInfo();
70
- if (rateLimit) {
71
- console.log(`\n📊 Rate Limit: ${rateLimit.remaining}/${rateLimit.limit} remaining`);
72
- }
73
- }
74
-
75
- main().catch(console.error);
package/src/client.ts DELETED
@@ -1,260 +0,0 @@
1
- /**
2
- * VELOCITI SDK Client
3
- * Main client class for interacting with the VELOCITI API
4
- */
5
-
6
- import {
7
- VelocitiConfig,
8
- DeployTokenParams,
9
- TokenInfo,
10
- ClaimFeesResult,
11
- ApiResponse,
12
- RateLimitInfo,
13
- PreparedTransaction,
14
- SubmitResult,
15
- } from './types';
16
-
17
- const DEFAULT_MAINNET_URL = 'https://velociti.fun/api/sdk';
18
- const DEFAULT_DEVNET_URL = 'https://devnet.velociti.fun/api/sdk';
19
-
20
- export class VelocitiClient {
21
- private apiKey: string;
22
- private baseUrl: string;
23
- private network: 'mainnet' | 'devnet';
24
- private rateLimitInfo: RateLimitInfo | null = null;
25
-
26
- constructor(config: VelocitiConfig) {
27
- if (!config.apiKey) {
28
- throw new Error('API key is required. Get one at velociti.fun/developers');
29
- }
30
-
31
- this.apiKey = config.apiKey;
32
- this.network = config.network || 'mainnet';
33
- this.baseUrl = config.baseUrl ||
34
- (this.network === 'mainnet' ? DEFAULT_MAINNET_URL : DEFAULT_DEVNET_URL);
35
- }
36
-
37
- /**
38
- * Make an authenticated request to the VELOCITI API
39
- */
40
- private async request<T>(
41
- endpoint: string,
42
- options: RequestInit = {}
43
- ): Promise<ApiResponse<T>> {
44
- const url = `${this.baseUrl}${endpoint}`;
45
-
46
- const response = await fetch(url, {
47
- ...options,
48
- headers: {
49
- 'Content-Type': 'application/json',
50
- 'X-API-Key': this.apiKey,
51
- ...options.headers,
52
- },
53
- });
54
-
55
- // Update rate limit info from headers
56
- const remaining = response.headers.get('X-RateLimit-Remaining');
57
- const limit = response.headers.get('X-RateLimit-Limit');
58
- const reset = response.headers.get('X-RateLimit-Reset');
59
-
60
- if (remaining && limit && reset) {
61
- this.rateLimitInfo = {
62
- remaining: parseInt(remaining, 10),
63
- limit: parseInt(limit, 10),
64
- reset: parseInt(reset, 10),
65
- };
66
- }
67
-
68
- if (response.status === 429) {
69
- return {
70
- success: false,
71
- error: 'Rate limit exceeded. Please try again later.',
72
- };
73
- }
74
-
75
- if (!response.ok) {
76
- const errorData = await response.json().catch(() => ({})) as { error?: string };
77
- return {
78
- success: false,
79
- error: errorData.error || `HTTP ${response.status}: ${response.statusText}`,
80
- };
81
- }
82
-
83
- const data = await response.json() as T;
84
- return { success: true, data };
85
- }
86
-
87
- /**
88
- * Prepare a token deployment transaction (Step 1)
89
- *
90
- * Returns an unsigned transaction that you must sign with your wallet.
91
- * After signing, call submitTransaction() to complete the deployment.
92
- *
93
- * @example
94
- * ```typescript
95
- * // Step 1: Prepare the transaction
96
- * const prepared = await client.prepareTokenDeploy({
97
- * name: 'My Token',
98
- * symbol: 'MTK',
99
- * taxRate: 5,
100
- * payerAddress: 'YourWalletAddress...'
101
- * });
102
- *
103
- * // Step 2: Sign with your wallet (example using @solana/web3.js)
104
- * const tx = Transaction.from(Buffer.from(prepared.data.transaction, 'base64'));
105
- * const signedTx = await wallet.signTransaction(tx);
106
- *
107
- * // Step 3: Submit the signed transaction
108
- * const result = await client.submitTransaction(signedTx.serialize().toString('base64'));
109
- * ```
110
- */
111
- async prepareTokenDeploy(params: DeployTokenParams): Promise<ApiResponse<PreparedTransaction>> {
112
- // Validate params
113
- if (!params.name || params.name.length > 32) {
114
- return { success: false, error: 'Name is required and must be <= 32 characters' };
115
- }
116
- if (!params.symbol || params.symbol.length > 10) {
117
- return { success: false, error: 'Symbol is required and must be <= 10 characters' };
118
- }
119
- if (!params.payerAddress) {
120
- return { success: false, error: 'Payer wallet address is required' };
121
- }
122
- if (params.taxRate !== undefined && (params.taxRate < 0 || params.taxRate > 10)) {
123
- return { success: false, error: 'Tax rate must be between 0 and 10%' };
124
- }
125
-
126
- return this.request<PreparedTransaction>('/deploy/prepare', {
127
- method: 'POST',
128
- body: JSON.stringify(params),
129
- });
130
- }
131
-
132
- /**
133
- * Submit a signed transaction (Step 2)
134
- *
135
- * @param signedTransaction - Base64 encoded signed transaction
136
- */
137
- async submitTransaction(signedTransaction: string): Promise<ApiResponse<SubmitResult>> {
138
- return this.request<SubmitResult>('/deploy/submit', {
139
- method: 'POST',
140
- body: JSON.stringify({ signedTransaction }),
141
- });
142
- }
143
-
144
- /**
145
- * Convenience method: Deploy token in one call (requires wallet adapter)
146
- *
147
- * This combines prepareTokenDeploy and submitTransaction.
148
- * You must provide a signTransaction function from your wallet.
149
- *
150
- * @example
151
- * ```typescript
152
- * const result = await client.deployToken({
153
- * name: 'My Token',
154
- * symbol: 'MTK',
155
- * taxRate: 5,
156
- * payerAddress: wallet.publicKey.toBase58()
157
- * }, async (tx) => {
158
- * return await wallet.signTransaction(tx);
159
- * });
160
- * ```
161
- */
162
- async deployToken(
163
- params: DeployTokenParams,
164
- signTransaction: (transaction: Uint8Array) => Promise<Uint8Array>
165
- ): Promise<ApiResponse<SubmitResult>> {
166
- // Step 1: Prepare
167
- const prepared = await this.prepareTokenDeploy(params);
168
- if (!prepared.success || !prepared.data) {
169
- return { success: false, error: prepared.error || 'Failed to prepare transaction' };
170
- }
171
-
172
- // Step 2: Sign
173
- try {
174
- const txBytes = Uint8Array.from(atob(prepared.data.transaction), c => c.charCodeAt(0));
175
- const signedBytes = await signTransaction(txBytes);
176
- const signedBase64 = btoa(String.fromCharCode(...signedBytes));
177
-
178
- // Step 3: Submit
179
- return this.submitTransaction(signedBase64);
180
- } catch (error: any) {
181
- return { success: false, error: `Signing failed: ${error.message}` };
182
- }
183
- }
184
-
185
- /**
186
- * Get token information by mint address
187
- */
188
- async getToken(mintAddress: string): Promise<ApiResponse<TokenInfo>> {
189
- return this.request<TokenInfo>(`/tokens/${mintAddress}`);
190
- }
191
-
192
- /**
193
- * Get all tokens created with this API key
194
- */
195
- async getMyTokens(): Promise<ApiResponse<TokenInfo[]>> {
196
- return this.request<TokenInfo[]>('/tokens/mine');
197
- }
198
-
199
- /**
200
- * Prepare fee claim transaction
201
- */
202
- async prepareClaimFees(
203
- mintAddress: string,
204
- walletAddress: string
205
- ): Promise<ApiResponse<PreparedTransaction>> {
206
- return this.request<PreparedTransaction>('/fees/prepare', {
207
- method: 'POST',
208
- body: JSON.stringify({ mintAddress, walletAddress }),
209
- });
210
- }
211
-
212
- /**
213
- * Claim accumulated transfer fees for a token
214
- * Combines prepare + sign + submit
215
- */
216
- async claimFees(
217
- mintAddress: string,
218
- walletAddress: string,
219
- signTransaction: (transaction: Uint8Array) => Promise<Uint8Array>
220
- ): Promise<ApiResponse<ClaimFeesResult>> {
221
- const prepared = await this.prepareClaimFees(mintAddress, walletAddress);
222
- if (!prepared.success || !prepared.data) {
223
- return { success: false, error: prepared.error || 'Failed to prepare claim' };
224
- }
225
-
226
- try {
227
- const txBytes = Uint8Array.from(atob(prepared.data.transaction), c => c.charCodeAt(0));
228
- const signedBytes = await signTransaction(txBytes);
229
- const signedBase64 = btoa(String.fromCharCode(...signedBytes));
230
-
231
- return this.request<ClaimFeesResult>('/fees/submit', {
232
- method: 'POST',
233
- body: JSON.stringify({ signedTransaction: signedBase64, mintAddress }),
234
- });
235
- } catch (error: any) {
236
- return { success: false, error: `Signing failed: ${error.message}` };
237
- }
238
- }
239
-
240
- /**
241
- * Get unclaimed fees for a token
242
- */
243
- async getUnclaimedFees(mintAddress: string): Promise<ApiResponse<{ amount: string; valueInSol: number }>> {
244
- return this.request(`/fees/${mintAddress}`);
245
- }
246
-
247
- /**
248
- * Get current rate limit status
249
- */
250
- getRateLimitInfo(): RateLimitInfo | null {
251
- return this.rateLimitInfo;
252
- }
253
-
254
- /**
255
- * Get the current network
256
- */
257
- getNetwork(): 'mainnet' | 'devnet' {
258
- return this.network;
259
- }
260
- }
package/src/index.ts DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * VELOCITI SDK
3
- * Official SDK for deploying and managing tokens on VELOCITI
4
- *
5
- * @example
6
- * ```typescript
7
- * import { VelocitiClient } from '@velociti/sdk';
8
- *
9
- * const client = new VelocitiClient({
10
- * apiKey: 'your-api-key',
11
- * network: 'devnet'
12
- * });
13
- *
14
- * const token = await client.deployToken({
15
- * name: 'My Token',
16
- * symbol: 'MTK',
17
- * taxRate: 5
18
- * });
19
- * ```
20
- */
21
-
22
- export { VelocitiClient } from './client';
23
- export * from './types';