Package Exports
- @gala-chain/launchpad-sdk
Readme
Gala Launchpad SDK v0.4.0
A comprehensive TypeScript SDK for the Gala Launchpad Backend API, providing type-safe authentication, trading, and real-time features for DeFi applications.
๐ Features
Wallet Creation with Auto-Detection:
- Auto-Detection: Automatically detects private key vs mnemonic input format
- Flexible Input: Supports 12/24-word mnemonics and 64-character hex private keys
- SDK Factory Functions: Simplified SDK initialization with
createLaunchpadSDK() - Input Validation: Built-in
validateWalletInput()for format validation - Test Support:
createTestLaunchpadSDK()for testing environments - Flat API Design: All methods directly on SDK root for simplicity
Developer Experience
import { createLaunchpadSDK, createWallet } from '@gala-chain/launchpad-sdk';
// Auto-detect wallet format and create SDK
const sdk = createLaunchpadSDK({
wallet: 'your-private-key-or-mnemonic' // Auto-detects format!
});
// Or create wallet separately with auto-detection
const wallet = createWallet('private-key-or-mnemonic');
const sdk = createLaunchpadSDK({ wallet });
// Test SDK with defaults
const testSDK = createTestLaunchpadSDK();๐ Flat API Architecture
All methods directly on SDK root - simple and clean:
// Everything is directly on sdk!
await sdk.fetchPools({ type: 'recent' });
await sdk.calculateBuyAmount({ tokenName: 'token', amount: '100', type: 'native' });
await sdk.buy({ tokenName: 'token', amount: '100', type: 'native' });
await sdk.fetchGalaBalance();
await sdk.postComment({ tokenName: 'token', content: 'Great project!' });๐ Key Features
- Type-Safe API Client: Full TypeScript support with comprehensive type definitions
- Signature Authentication: Ethereum wallet-based authentication with automatic signature generation
- Helper Functions: Auto-detecting wallet creation and SDK factory functions
- Flat API Design: All methods directly accessible on SDK root
- Pool Management: Create, fetch, and check token pools on the launchpad
- Token Trading: Buy and sell tokens with slippage protection via GalaChain
- User Operations: Portfolio management, token balances, and account management
- Comment System: Post and retrieve comments on token pools
- Comprehensive Validation: Input validation and error handling for all operations
- Multi-Environment Support: Production, staging, and custom backend URLs
๐ฆ Installation
npm install @gala-chain/launchpad-sdk@^0.4.0Or with yarn:
yarn add @gala-chain/launchpad-sdk@^0.4.0๐ Quick Start
Using Helper Functions (Recommended)
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
// Auto-detecting SDK creation (easiest method)
const sdk = createLaunchpadSDK({
wallet: 'your-private-key-or-mnemonic' // Auto-detects format!
});
// Flat API - All methods directly on SDK root
// Pool Management
const pools = await sdk.fetchPools({ type: 'recent', limit: 10 });
const badges = await sdk.fetchTokenBadges('dragnrkti');
const details = await sdk.fetchSaleDetails('dragnrkti');
// Price Calculations
const buyAmount = await sdk.calculateBuyAmount({
tokenName: 'dragnrkti',
amount: '1000000000000000000', // 1 GALA
type: 'native'
});
// Trading Operations
const buyResult = await sdk.buy({
tokenName: 'dragnrkti',
amount: '1000000000000000000',
type: 'native',
slippage: 5
});
// Data & Analytics
const trades = await sdk.fetchTrades({ tokenName: 'dragnrkti' });
const comments = await sdk.fetchComments({ tokenName: 'dragnrkti' });
const balance = await sdk.fetchGalaBalance();
// User Operations
const profile = await sdk.fetchProfile();
const tokenBalance = await sdk.fetchTokenBalance({
tokenName: 'dragnrkti',
walletAddress: sdk.getAddress()
});Manual SDK Creation (Alternative)
import { Wallet } from 'ethers';
import { LaunchpadSDK } from '@gala-chain/launchpad-sdk';
// Create wallet manually
const wallet = new Wallet(process.env.PRIVATE_KEY);
// Initialize SDK
const sdk = new LaunchpadSDK({
wallet: wallet,
baseUrl: 'https://lpad-backend-dev1.defi.gala.com',
timeout: 30000,
debug: false
});
// Same flat API available
const pools = await sdk.fetchPools({ type: 'recent' });๐ฏ Complete Example: Trading Flow
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
// 1. Create SDK with auto-detection
const sdk = createLaunchpadSDK({
wallet: 'your-private-key-or-mnemonic'
});
// 2. Check available pools
const pools = await sdk.fetchPools({
type: 'recent',
limit: 10
});
// 3. Get price quote
const quote = await sdk.calculateBuyAmount({
tokenName: 'tinyevil',
amount: '100',
type: 'native'
});
console.log(`Buying 100 GALA worth of tokens will get you: ${quote.outTokenAmount} TINYEVIL`);
// 4. Execute trade with slippage protection
const buyResult = await sdk.buy({
tokenName: 'tinyevil',
amount: '100',
type: 'native',
slippage: 5 // 5% slippage tolerance
});
// 5. Check trade history
const trades = await sdk.fetchTrades({ tokenName: 'tinyevil' });
// 6. Post a comment about your trade
await sdk.postComment({
tokenName: 'tinyevil',
content: 'Just bought some tokens! Great project!'
});
// 7. Check your balance
const balance = await sdk.fetchGalaBalance();
const tokenBalance = await sdk.fetchTokenBalance({
tokenName: 'tinyevil',
walletAddress: sdk.getAddress()
});
console.log(`GALA Balance: ${balance.balance}`);
console.log(`TINYEVIL Balance: ${tokenBalance.balance}`);๐ฏ Available Methods
Fetch Operations
fetchPools(options?)- Get pools (recent, popular, search)fetchTokenDistribution(tokenName)- Token holder distributionfetchTokenBadges(tokenName)- Volume and engagement badgesfetchSaleDetails(tokenName)- Token sale informationfetchGraphData(options)- Price chart datafetchTrades(options)- Trade historyfetchGalaBalance(walletAddress?)- User GALA balancefetchTokenBalance(options)- User token balancefetchComments(options)- Token commentsfetchProfile(walletAddress?)- User profile
Calculate Operations
calculateBuyAmount(options)- Calculate GALA cost for tokenscalculateSellAmount(options)- Calculate GALA received from tokenscalculateInitialBuyAmount(options)- Pre-mint calculations
Trading Operations
buy(options)- Buy tokens with slippage protectionsell(options)- Sell tokens with slippage protection
Content Operations
postComment(options)- Post comment on tokencreateTokenAndPool(data)- Create new token saleuploadTokenImage(options)- Upload token imageupdateProfile(data)- Update user profileuploadProfileImage(options)- Upload profile image
Validation & Utilities
isTokenNameAvailable(tokenName)- Check name availabilityisTokenSymbolAvailable(symbol)- Check symbol availabilitygetAddress()- Get backend format address (eth|...)getEthereumAddress()- Get Ethereum format address (0x...)resolveVaultAddress(tokenName)- Get token vault addresscleanup()- Cleanup resources
๐ง Helper Functions
Wallet Creation
import { createWallet, validateWalletInput } from '@gala-chain/launchpad-sdk';
// Auto-detect format and create wallet
const wallet = createWallet('private-key-or-24-word-mnemonic');
const randomWallet = createWallet(); // Generate random wallet
// Validate input format without creating wallet
const isValid = validateWalletInput('0x1234...'); // booleanSDK Factory Functions
import { createLaunchpadSDK, createTestLaunchpadSDK } from '@gala-chain/launchpad-sdk';
// Main factory with auto-detection
const sdk = createLaunchpadSDK({
wallet: 'your-private-key-or-mnemonic',
config: {
baseUrl: 'https://lpad-backend-dev1.defi.gala.com',
debug: true
}
});
// Test-optimized SDK
const testSDK = createTestLaunchpadSDK({
wallet: 'test-private-key'
});๐ง Configuration
interface LaunchpadSDKConfig {
wallet: Wallet; // ethers.js Wallet instance
baseUrl?: string; // Backend URL (default: dev environment)
galaChainBaseUrl?: string; // GalaChain gateway URL
bundleBaseUrl?: string; // Bundle service URL
webSocketUrl?: string; // WebSocket URL for monitoring
timeout?: number; // Request timeout (default: 30000ms)
debug?: boolean; // Enable debug logging
maxRetries?: number; // Retry attempts (default: 3)
retryDelay?: number; // Retry delay (default: 1000ms)
}๐งช Testing
# Run all tests
npm test
# Run integration tests (requires environment setup)
npm run test:integration
# Run type checking
npm run typecheck
# Run linting
npm run lint๐ Documentation
- SDK Method Reference - Complete flat API reference
- AI Agent Guide - Integration with AI agents
- API Documentation - Detailed API documentation
- Examples - Code examples and demos
๐ Environment URLs
- Development:
https://lpad-backend-dev1.defi.gala.com - Production:
https://lpad-backend-prod1.defi.gala.com
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Please read CONTRIBUTING.md for guidelines on contributing to this project.
๐ Support
- GitHub Issues: Report bugs and request features
- Documentation: Full documentation and examples
- API Status: All 22/22 endpoints working โ
Built with โค๏ธ for the Gala ecosystem