### Complete Solana Transaction Workflow with Jito Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/07-solana-service.md This example demonstrates the full process of creating, signing, and sending a bundle of transactions, including a main transaction and a tip transaction, using the Bags SDK and Jito relayers. Ensure you have the necessary imports and wallet setup before execution. ```typescript import { BagsSDK, sendBundleAndConfirm, createTipTransaction } from '@bagsfm/bags-sdk'; const sdk = new BagsSDK('api-key', connection); // 1. Get recent fees const fees = await sdk.solana.getJitoRecentFees(); const tipAmount = Math.ceil(fees.landed_tips_50th_percentile); // 2. Create main transactions (swap, claim, etc.) const mainTx = await sdk.trade.createSwapTransaction({...}); // 3. Create tip transaction const tipTx = await createTipTransaction( connection, 'processed', payerWallet, tipAmount ); // 4. Sign transactions const keypair = Keypair.fromSecretKey(...); mainTx.transaction.sign([keypair]); tipTx.sign([keypair]); // 5. Send bundle and wait for confirmation try { const bundleId = await sendBundleAndConfirm( [mainTx.transaction, tipTx], sdk, 'mainnet' ); console.log('Success:', bundleId); } catch (error) { console.error('Failed:', error.message); } ``` -------------------------------- ### BagsSDK Usage Example Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/01-bags-sdk-main.md Example demonstrating how to initialize the BagsSDK and access its various service modules for common operations. ```APIDOC ### Usage Example ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { Connection, PublicKey } from '@solana/web3.js'; // Initialize with your API key and RPC connection const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=your-key'); const sdk = new BagsSDK('your-bags-api-key', connection, 'processed'); // Access services const creators = await sdk.state.getTokenCreators( new PublicKey('your-token-mint') ); const quote = await sdk.trade.getQuote({ inputMint: new PublicKey('So11111111111111111111111111111111111111112'), outputMint: new PublicKey('your-token-mint'), amount: 1_000_000_000, slippageMode: 'auto', }); const claimable = await sdk.fee.getAllClaimablePositions(walletPublicKey); // Send bundle via Jito const bundleId = await sdk.solana.sendBundle([signedTransaction], 'mainnet'); ``` ``` -------------------------------- ### Common Trade Workflow Example Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/04-trade-service.md Demonstrates the typical sequence for executing a trade: getting a quote, verifying it, building the transaction, and then signing and sending it. ```typescript // 1. Get a quote const quote = await sdk.trade.getQuote({ inputMint: wrappedSOL, outputMint: tokenMint, amount: amountInLamports, slippageMode: 'auto', }); // 2. Verify the quote looks good console.log('Price Impact:', quote.priceImpactPct); console.log('Min Out:', quote.minOutAmount); // 3. Build the swap transaction const swapTx = await sdk.trade.createSwapTransaction({ quoteResponse: quote, userPublicKey: userWallet, }); // 4. Sign and send keypair.sign([swapTx.transaction]); await sdk.solana.sendBundle([swapTx.transaction], 'mainnet'); ``` -------------------------------- ### Install Dependencies Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Install project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install bags-sdk Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Install the SDK using npm. Ensure Node.js version 18.0.0 or higher is used. ```bash npm install @bagsfm/bags-sdk ``` -------------------------------- ### Execute Partner Claim Transactions Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/08-partner-service.md Example demonstrating how to get, sign, and execute partner claim transactions. It highlights the importance of executing the final transaction last and suggests parallel execution for non-final transactions. ```typescript const claimTxs = await sdk.partner.getPartnerConfigClaimTransactions(partnerWallet); console.log(`Got ${claimTxs.length} claim transactions`); // Sign all transactions const keypair = Keypair.fromSecretKey(...); const signedTxs = claimTxs.map(({ transaction }) => { transaction.sign([keypair]); return transaction; }); // Execute non-final transactions in parallel const keypair = Keypair.fromSecretKey(...); const nonFinalTxs = signedTxs.slice(0, -1); const finalTx = signedTxs[signedTxs.length - 1]; // Send non-final transactions (can be in parallel) const promises = nonFinalTxs.map(tx => connection.sendTransaction(tx, { skipPreflight: true, maxRetries: 0 }) ); await Promise.all(promises); // Wait a moment for confirmation await new Promise(r => setTimeout(r, 1000)); // Send final transaction (must be after others) const finalSig = await connection.sendTransaction(finalTx, { skipPreflight: true, maxRetries: 0, }); console.log('Final claim signature:', finalSig); ``` -------------------------------- ### Start Payment Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Initiates the payment process for incorporation. This method sets up the payment order and returns transaction details. ```APIDOC ## POST /incorporation/startPayment ### Description Initiates the payment process for incorporation. This method sets up the payment order and returns transaction details. ### Method POST ### Endpoint /incorporation/startPayment ### Parameters #### Request Body - **payerWallet** (PublicKey) - Required - The wallet address of the payer. - **payWithSol** (boolean) - Required - Specifies if the payment should be made with SOL. ``` -------------------------------- ### StartPaymentResult Interface Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/12-types-reference.md The result of starting a payment. ```typescript interface StartPaymentResult { orderUUID: string; recipientWallet: string; priceUSDC: string; transaction: VersionedTransaction; lastValidBlockHeight: number; } ``` -------------------------------- ### StartPaymentParams Type Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/12-types-reference.md Parameters required to start a payment. ```typescript type StartPaymentParams = { payerWallet: PublicKey; payWithSol?: boolean; } ``` -------------------------------- ### Start Incorporation Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Initiates the formal incorporation process after all prerequisites, such as KYC and forms, are completed. ```APIDOC ## POST /incorporation/startIncorporation ### Description Initiates the formal incorporation process after all prerequisites, such as KYC and forms, are completed. ### Method POST ### Endpoint /incorporation/startIncorporation ### Parameters #### Request Body - **tokenAddress** (PublicKey) - Required - The address of the token associated with the incorporation. ``` -------------------------------- ### Initialize and Use BagsSDK Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Initialize the SDK with an API key, Solana connection, and optional commitment level. Demonstrates querying token creators, getting swap quotes, and claiming fees. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { Connection, PublicKey } from '@solana/web3.js'; // Initialize the SDK const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=your-helius-api-key'); // Or any other RPC provider const sdk = new BagsSDK('your-bags-api-key', connection, 'processed'); // Query token creators const tokenMint = new PublicKey('your-token-mint-address'); const creators = await sdk.state.getTokenCreators(tokenMint); console.log('Token creators:', creators); // Get a swap quote const quote = await sdk.trade.getQuote({ inputMint: 'So11111111111111111111111111111111111111112', outputMint: 'your-token-mint-address', amount: 1_000_000_000, // 1 SOL in lamports slippageMode: 'dynamic', }); console.log('Swap quote:', quote); // Claim fees const claimable = await sdk.fee.getAllClaimablePositions(walletPublicKey); console.log('Claimable positions:', claimable); ``` -------------------------------- ### Start Payment for Token Incorporation Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Initiates a payment for token incorporation. Use this method to get payment details and a transaction to be signed and sent. Ensure you have the BagsSDK initialized with an API key and a Solana connection. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { PublicKey, Keypair } from '@solana/web3.js'; const sdk = new BagsSDK('api-key', connection); const payerWallet = new PublicKey('YourWallet'); const payment = await sdk.incorporation.startPayment({ payerWallet: payerWallet, payWithSol: false, }); console.log('Order UUID:', payment.orderUUID); console.log('Price:', payment.priceUSDC, 'USDC'); // Sign and send const keypair = Keypair.fromSecretKey(...); payment.transaction.sign([keypair]); const signature = await connection.sendTransaction(payment.transaction); console.log('Payment signature:', signature); ``` -------------------------------- ### Start Incorporation Process Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Initiate the formal incorporation process after all prerequisites are met. This method requires the token mint address. ```typescript async startIncorporation(params: StartIncorporationParams): Promise ``` ```typescript interface StartIncorporationResponse { tokenAddress: string; incorporationStarted: boolean; } ``` ```typescript const result = await sdk.incorporation.startIncorporation({ tokenAddress: new PublicKey('TokenMint'), }); if (result.incorporationStarted) { console.log('Incorporation process started!'); } ``` -------------------------------- ### Error Handling Guide Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/GENERATED.txt Comprehensive guide on error handling within the BAGS SDK. ```APIDOC ## 16-error-handling.md ### Description Comprehensive guide for understanding and implementing error handling patterns within the BAGS SDK. ``` -------------------------------- ### Example: Using getConfigCreationLookupTableTransactions Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/06-config-service.md Demonstrates how to call getConfigCreationLookupTableTransactions and handle the returned LUT addresses and extend transactions. Ensure 'claimerArray' and 'payerWallet' are defined. ```typescript const lutResult = await sdk.config.getConfigCreationLookupTableTransactions({ feeClaimers: claimerArray, payer: payerWallet, }, { tipWallet: new PublicKey('TipAccount'), tipLamports: 100_000, }); if (lutResult) { console.log('LUT Address:', lutResult.lutAddresses[0].toBase58()); console.log('Extend transactions:', lutResult.extendTransactions.length); } ``` -------------------------------- ### Complete Incorporation Workflow with Bags SDK Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md This snippet demonstrates the full incorporation process using the Bags SDK. It covers starting and signing a payment, registering incorporation details, handling founder KYC and forms, initiating the incorporation process, and checking its status. Ensure you have the necessary API key and Solana connection established. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { PublicKey, Keypair } from '@solana/web3.js'; const sdk = new BagsSDK('api-key', connection); const payerWallet = new PublicKey('YourWallet'); const tokenMint = new PublicKey('YourToken'); const keypair = Keypair.fromSecretKey(...); // 1. Start payment const payment = await sdk.incorporation.startPayment({ payerWallet, payWithSol: false, }); // 2. Sign and send payment payment.transaction.sign([keypair]); const paymentSig = await connection.sendTransaction(payment.transaction); console.log('Payment sent:', paymentSig); // 3. Register incorporation details const incorporation = await sdk.incorporation.incorporate({ orderUUID: payment.orderUUID, paymentSignature: paymentSig, projectName: 'MyProject', tokenAddress: tokenMint, category: 'AI', twitterHandle: '@myproject', incorporationShareBasisPoint: 500, preferredCompanyNames: ['MyProject Corp', 'MyProject Inc'], founders: [ { firstName: 'Alice', lastName: 'Johnson', email: 'alice@example.com', nationalityCountry: 'US', taxResidencyCountry: 'US', residentialAddress: '123 Main St, US', shareBasisPoint: 5000, }, ], }); // 4. Founders complete KYC and forms incorporation.founders.forEach(founder => { console.log(`${founder.firstName}: Complete KYC at ${founder.kycUrl}`); if (founder.formUrl) { console.log(` Complete form at ${founder.formUrl}`); } }); // 5. Once all KYC/PEP/IP attribution done, start incorporation const started = await sdk.incorporation.startIncorporation({ tokenAddress: tokenMint, }); if (started.incorporationStarted) { console.log('Incorporation process has started!'); } // 6. Check status const status = await sdk.incorporation.getDetails({ tokenAddress: tokenMint, }); console.log('Current status:', status.incorporationStatus); ``` -------------------------------- ### Complete Fee Share Admin Workflow Example Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/14-fee-share-admin-service.md Demonstrates a full workflow for managing fee share administration, including listing tokens, updating configurations, handling lookup tables, and transferring admin rights. Ensure you have the Bags SDK, Solana web3.js, and a valid connection established. ```typescript import { BagsSDK, BAGS_FEE_SHARE_ADMIN_MAX_CLAIMERS_NON_LUT } from '@bagsfm/bags-sdk'; import { PublicKey, Keypair } from '@solana/web3.js'; const sdk = new BagsSDK('api-key', connection); const adminWallet = new PublicKey('AdminWallet'); const keypair = Keypair.fromSecretKey(...); // 1. List tokens managed const adminMints = await sdk.feeShareAdmin.getAdminTokenMints(adminWallet); console.log(`Managing ${adminMints.length} tokens`); // 2. Update fee distribution const newClaimers = [ { user: new PublicKey('NewClaimer1'), userBps: 5000 }, { user: new PublicKey('NewClaimer2'), userBps: 5000 }, ]; // 3. Check if LUT needed let lutAddresses: Array | undefined; if (newClaimers.length > BAGS_FEE_SHARE_ADMIN_MAX_CLAIMERS_NON_LUT) { const lutTxs = await sdk.feeShareAdmin.getUpdateConfigLookupTableTransactions({ feeClaimers: newClaimers, payer: adminWallet, }); if (lutTxs) { // Create LUT first lutTxs.creationTransaction.sign([keypair]); await connection.sendTransaction(lutTxs.creationTransaction); await new Promise(r => setTimeout(r, 1000)); // Extend LUT for (const tx of lutTxs.extendTransactions) { tx.sign([keypair]); await connection.sendTransaction(tx); } lutAddresses = lutTxs.addresses; } } // 4. Update config const updateTxs = await sdk.feeShareAdmin.getUpdateConfigTransactions({ baseMint: new PublicKey(adminMints[0]), feeClaimers: newClaimers, payer: adminWallet, additionalLookupTables: lutAddresses, }); // 5. Send update transactions for (const { transaction } of updateTxs) { transaction.sign([keypair]); const sig = await connection.sendTransaction(transaction); console.log('Updated:', sig); await new Promise(r => setTimeout(r, 500)); } // 6. Transfer admin (if needed) const { transaction: transferTx } = await sdk.feeShareAdmin.getTransferAdminTransaction({ baseMint: new PublicKey(adminMints[0]), currentAdmin: adminWallet, newAdmin: new PublicKey('NewAdminWallet'), payer: adminWallet, }); transferTx.sign([keypair]); const transferSig = await connection.sendTransaction(transferTx); console.log('Admin transferred:', transferSig); ``` -------------------------------- ### Create Bags Fee Share Config (Large Claimer Set) Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/06-config-service.md This example demonstrates the process for creating a fee-share configuration with a large number of fee claimers, which requires pre-creating and extending a lookup table (LUT). It outlines the steps for LUT creation, extension, and then using the LUT with the config creation method. ```typescript // For >15 claimers, you need to create a lookup table first const lutResult = await sdk.config.getConfigCreationLookupTableTransactions({ feeClaimers: largeClaimerArray, payer: payerWallet, }); if (lutResult) { // Execute LUT creation first const keypair = Keypair.fromSecretKey(...); // 1. Create the LUT lutResult.creationTransaction.sign([keypair]); await connection.sendTransaction(lutResult.creationTransaction); // 2. Wait for LUT to be available await new Promise(r => setTimeout(r, 1000)); // 3. Extend the LUT with account addresses for (const extendTx of lutResult.extendTransactions) { extendTx.sign([keypair]); await connection.sendTransaction(extendTx); } } // Now create config with LUT const configResult = await sdk.config.createBagsFeeShareConfig({ baseMint: tokenMint, payer: payerWallet, feeClaimers: largeClaimerArray, additionalLookupTables: lutResult?.lutAddresses, }); ``` -------------------------------- ### Complete Dexscreener Order Workflow Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/09-dexscreener-service.md This snippet shows the full process of listing a token on Dexscreener. It includes checking availability, creating the order, handling the payment transaction, and confirming the payment. Ensure you have the necessary API keys and wallet setup. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { PublicKey, Keypair, VersionedTransaction } from '@solana/web3.js'; import bs58 from 'bs58'; const sdk = new BagsSDK('api-key', connection); const tokenMint = new PublicKey('YourTokenMint'); const payerWallet = new PublicKey('YourWallet'); const keypair = Keypair.fromSecretKey(...); // 1. Check if listing is available const availability = await sdk.dexscreener.checkOrderAvailability({ tokenAddress: tokenMint, }); if (!availability.available) { console.log('Order already exists'); process.exit(1); } // 2. Create the order const order = await sdk.dexscreener.createOrder({ tokenAddress: tokenMint, description: 'Next generation token with AI-powered features', iconImageUrl: 'https://example.com/logo.png', headerImageUrl: 'https://example.com/banner.png', payerWallet: payerWallet, links: [ { url: 'https://mytoken.com', label: 'Website' }, { url: 'https://twitter.com/mytoken', label: 'Twitter' }, ], }); console.log('Order created. UUID:', order.orderUUID); console.log('Price:', order.priceUSDC, 'USDC'); // 3. Prepare and sign payment const decodedTx = bs58.decode(order.transaction); const paymentTx = VersionedTransaction.deserialize(decodedTx); paymentTx.sign([keypair]); // 4. Send payment const paymentSig = await connection.sendTransaction(paymentTx, { skipPreflight: true, maxRetries: 0, }); console.log('Payment sent:', paymentSig); // 5. Wait for payment confirmation let confirmed = false; for (let i = 0; i < 30; i++) { const status = await connection.getSignatureStatus(paymentSig); if (status.value?.confirmationStatus) { confirmed = true; break; } await new Promise(r => setTimeout(r, 500)); } if (!confirmed) { throw new Error('Payment not confirmed in time'); } // 6. Submit payment confirmation const confirmation = await sdk.dexscreener.submitPayment({ orderUUID: order.orderUUID, paymentSignature: paymentSig, }); console.log('Order confirmed:', confirmation); console.log('Your token is now listed on Dexscreener!'); ``` -------------------------------- ### Validate API Key on Startup Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/15-auth-service.md Verify the API key is functional when the application starts. This prevents runtime errors due to invalid credentials. ```typescript const verified = await sdk.auth.me().then(() => true).catch(() => false); if (!verified) { console.error('Invalid API key - exiting'); process.exit(1); } ``` -------------------------------- ### getPartnerConfigCreationTransaction Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/08-partner-service.md Generates a transaction that can be used to create a new partner configuration. This is useful for initiating the setup process for a new partner. ```APIDOC ## getPartnerConfigCreationTransaction ### Description Get a transaction to create a partner configuration. ### Method `async getPartnerConfigCreationTransaction( partner: PublicKey ): Promise<{ transaction: VersionedTransaction; blockhash: BlockhashWithExpiryBlockHeight }>` ### Parameters #### Path Parameters - **partner** (PublicKey) - Yes - The partner wallet address ### Returns An object containing the `transaction` and `blockhash` for creating the partner configuration. ```typescript { transaction: VersionedTransaction; blockhash: BlockhashWithExpiryBlockHeight; } ``` ### Throws `ApiError` - When transaction cannot be built ### Example ```typescript const partnerWallet = new PublicKey('PartnerAddress'); const { transaction, blockhash } = await sdk.partner.getPartnerConfigCreationTransaction(partnerWallet); // Sign and send const keypair = Keypair.fromSecretKey(...); transaction.sign([keypair]); const signature = await connection.sendTransaction(transaction); console.log('Partner config created:', signature); ``` ``` -------------------------------- ### Get Launch Wallet V2 Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Fetches the launch wallet associated with a social media username. Requires the username and the social media provider. ```typescript async getLaunchWalletV2( username: string, provider: SupportedSocialProvider ): Promise ``` ```typescript interface BagsGetFeeShareWalletV2State { wallet: PublicKey; provider: SocialProvider; platformData: { id: string; username: string; display_name: string; avatar_url: string; }; } ``` ```typescript const walletData = await sdk.state.getLaunchWalletV2('elonmusk', 'twitter'); console.log('Launch Wallet:', walletData.wallet.toBase58()); console.log('Display Name:', walletData.platformData.display_name); ``` -------------------------------- ### Retrieve Authenticated User Profile Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/15-auth-service.md Example of how to use the `auth.me()` method to fetch the current user's profile information and log specific details. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; const sdk = new BagsSDK('your-bags-api-key', connection); const userProfile = await sdk.auth.me(); console.log('Username:', userProfile.user.username); console.log('Display Name:', userProfile.user.pref_name); console.log('Rank:', userProfile.user.rank); console.log('Points:', userProfile.user.points); console.log('Referral Count:', userProfile.user.referral_count); console.log(' Twitter:'); console.log(' Handle:', userProfile.user.twitter_data.url); console.log(' Verified:', userProfile.user.twitter_data.verified); console.log(' Followers:', userProfile.user.twitter_data.followers_count); console.log(' Following:', userProfile.user.twitter_data.following_count); ``` -------------------------------- ### Get Partner Configuration Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/08-partner-service.md Retrieves the configuration details for a specific partner wallet. Ensure the BagsSDK is initialized with an API key and Solana connection. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { PublicKey } from '@solana/web3.js'; const sdk = new BagsSDK('api-key', connection); const partnerWallet = new PublicKey('PartnerAddress'); const config = await sdk.partner.getPartnerConfig(partnerWallet); console.log('Total Claimed:', Number(config.totalClaimedFees), 'lamports'); console.log('Currently Accumulated:', Number(config.totalAccumulatedFees), 'lamports'); console.log('Lifetime Total:', Number(config.totalLifetimeAccumulatedFees), 'lamports'); console.log('Fee Allocation:', config.bps, 'bps'); ``` -------------------------------- ### Get Incorporation Project Details Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Retrieves detailed information for a specific incorporation project using its token address. Ensure the PublicKey is correctly instantiated. ```typescript async getDetails(params: GetIncorporationDetailsParams): Promise ``` ```typescript interface IncorporationDetailsResponse { tokenAddress: string; incorporationStatus: string; incorporationShareBasisPoint: number; category: string | null; twitterHandle: string | null; createdAt: string; preferredCompanyNames: string[]; isReadyForIncorporation: boolean; } ``` ```typescript const details = await sdk.incorporation.getDetails({ tokenAddress: new PublicKey('TokenMint'), }); console.log('Status:', details.incorporationStatus); console.log('Category:', details.category); console.log('Ready for incorporation:', details.isReadyForIncorporation); console.log('Preferred names:', details.preferredCompanyNames); ``` -------------------------------- ### Get Incorporation Project Details Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Fetches detailed information for a specific incorporation project using its token address. Returns an IncorporationDetailsResponse object with comprehensive project data. ```APIDOC ## getDetails ### Description Get detailed information about a specific incorporation project. ### Method ```typescript async getDetails(params: GetIncorporationDetailsParams): Promise ``` ### Parameters #### Path Parameters - **params.tokenAddress** (PublicKey) - Required - Token mint address ### Returns `IncorporationDetailsResponse` - Project details ### IncorporationDetailsResponse Structure ```typescript interface IncorporationDetailsResponse { tokenAddress: string; incorporationStatus: string; incorporationShareBasisPoint: number; category: string | null; twitterHandle: string | null; createdAt: string; preferredCompanyNames: string[]; isReadyForIncorporation: boolean; } ``` ### Example ```typescript const details = await sdk.incorporation.getDetails({ tokenAddress: new PublicKey('TokenMint'), }); console.log('Status:', details.incorporationStatus); console.log('Category:', details.category); console.log('Ready for incorporation:', details.isReadyForIncorporation); console.log('Preferred names:', details.preferredCompanyNames); ``` ``` -------------------------------- ### Get Launch Wallet V2 Bulk Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Retrieves launch wallets for multiple social media users in a single batched request. The response may contain null entries for users not found. ```typescript async getLaunchWalletV2Bulk( items: Array ): Promise> ``` ```typescript const results = await sdk.state.getLaunchWalletV2Bulk([ { username: 'user1', provider: 'twitter' }, { username: 'user2', provider: 'tiktok' }, { username: 'user3', provider: 'github' }, ]); results.forEach(result => { if (result.wallet) { console.log(`${result.username}: ${result.wallet.toBase58()}`); } else { console.log(`${result.username}: Not found`); } }); ``` -------------------------------- ### Build Project Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Build the project artifacts. ```bash npm run build ``` -------------------------------- ### Initialize BagsSDK and Access Services Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/01-bags-sdk-main.md Demonstrates how to initialize the BagsSDK with an API key and Solana connection, and then access various service modules for common operations. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { Connection, PublicKey } from '@solana/web3.js'; // Initialize with your API key and RPC connection const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=your-key'); const sdk = new BagsSDK('your-bags-api-key', connection, 'processed'); // Access services const creators = await sdk.state.getTokenCreators( new PublicKey('your-token-mint') ); const quote = await sdk.trade.getQuote({ inputMint: new PublicKey('So11111111111111111111111111111111111111112'), outputMint: new PublicKey('your-token-mint'), amount: 1_000_000_000, slippageMode: 'auto', }); const claimable = await sdk.fee.getAllClaimablePositions(walletPublicKey); // Send bundle via Jito const bundleId = await sdk.solana.sendBundle([signedTransaction], 'mainnet'); ``` -------------------------------- ### Initialize Bags SDK and Access Services Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/README.md Demonstrates how to initialize the BagsSDK with an API key and Solana connection, and then access various services like state, trade, and fee management. Ensure you replace placeholders with your actual API key, RPC URL, and relevant public keys. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { Connection, PublicKey } from '@solana/web3.js'; // Initialize SDK const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=your-key'); const sdk = new BagsSDK('your-bags-api-key', connection, 'processed'); // Access services const creators = await sdk.state.getTokenCreators(new PublicKey('...')); const quote = await sdk.trade.getQuote({...}); const claimable = await sdk.fee.getAllClaimablePositions(walletAddress); ``` -------------------------------- ### getTokenCreators Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Get all creators associated with a token. ```APIDOC ## getTokenCreators ### Description Get all creators associated with a token. ### Method async ### Parameters #### Path Parameters - **tokenMint** (PublicKey) - Required - The mint address of the token ### Returns `Array` - Array of creator objects ### Throws `ApiError` - When the request fails ### TokenLaunchCreator Structure ```typescript interface TokenLaunchCreator { username: string; pfp: string; royaltyBps: number; isCreator: boolean; wallet: string; provider: SocialProvider | 'unknown' | null; providerUsername: string | null; twitterUsername?: string; bagsUsername?: string; isAdmin?: boolean; } ``` ### Example ```typescript const creators = await sdk.state.getTokenCreators(tokenMint); creators.forEach(creator => { console.log(`${creator.username} (${creator.provider}): ${creator.royaltyBps} bps`); }); ``` ``` -------------------------------- ### createLaunchTransaction Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/02-token-launch-service.md Create a token launch transaction ready for signing and submission. This method takes metadata URL, token mint, launch wallet, initial buy amount, and configuration keys as parameters. ```APIDOC ## POST /tokenLaunch/createLaunchTransaction ### Description Creates a token launch transaction ready for signing and submission. ### Method POST ### Endpoint /tokenLaunch/createLaunchTransaction ### Parameters #### Request Body - **metadataUrl** (string) - Required - IPFS or other metadata URL for the token - **tokenMint** (PublicKey) - Required - The mint address of the token being launched - **launchWallet** (PublicKey) - Required - The wallet that will initiate the token launch - **initialBuyLamports** (number) - Required - Initial buy amount in lamports (e.g., 1 SOL = 1,000,000,000 lamports) - **configKey** (PublicKey) - Required - The fee-share configuration key - **tipConfig** (TransactionTipConfig) - Optional - Optional tip configuration for prioritization - **tipWallet** (PublicKey) - Jito tip account - **tipLamports** (number) - Tip amount in lamports ### Request Example { "metadataUrl": "ipfs://QmXxxx...", "tokenMint": "TokenMintAddress", "launchWallet": "LaunchWalletAddress", "initialBuyLamports": 1000000000, "configKey": "ConfigKeyAddress", "tipConfig": { "tipWallet": "TipAccountAddress", "tipLamports": 100000 } } ### Response #### Success Response (200) - **VersionedTransaction** (VersionedTransaction) - The launch transaction, ready to be signed and sent #### Response Example { "versionedTransaction": "" } ERROR HANDLING: - **ApiError**: When the API request fails ``` -------------------------------- ### getTokenClaimStats Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Get claim statistics for all creators of a token. ```APIDOC ## getTokenClaimStats ### Description Get claim statistics for all creators of a token. ### Method async ### Parameters #### Path Parameters - **tokenMint** (PublicKey) - Required - The mint address of the token ### Returns `Array` - Creators with claim statistics ### Example ```typescript const stats = await sdk.state.getTokenClaimStats(tokenMint); stats.forEach(creator => { console.log(`${creator.wallet}: ${creator.totalClaimed} lamports claimed`); }); ``` ``` -------------------------------- ### startPayment Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Initiates a payment for token incorporation. It returns payment details and a transaction ready to be signed and sent. ```APIDOC ## startPayment ### Description Initiate a payment for token incorporation. ### Method POST ### Endpoint /incorporation/startPayment ### Parameters #### Request Body - **payerWallet** (PublicKey) - Required - Wallet paying for incorporation - **payWithSol** (boolean) - Optional - Pay with SOL instead of USDC ### Response #### Success Response (200) - **orderUUID** (string) - Unique payment order ID - **recipientWallet** (string) - Fee recipient wallet - **priceUSDC** (string) - Price in USDC - **transaction** (VersionedTransaction) - Ready-to-sign payment transaction - **lastValidBlockHeight** (number) - Transaction expiry height ### Request Example ```json { "payerWallet": "YourWalletPublicKey", "payWithSol": false } ``` ### Response Example ```json { "orderUUID": "some-uuid", "recipientWallet": "FeeRecipientWalletPublicKey", "priceUSDC": "100.00", "transaction": "base64EncodedTransaction", "lastValidBlockHeight": 123456789 } ``` ``` -------------------------------- ### getTopTokensByLifetimeFees Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Get the top tokens by lifetime fees as a leaderboard. ```APIDOC ## getTopTokensByLifetimeFees ### Description Get the top tokens by lifetime fees as a leaderboard. ### Method async ### Returns `Array` - Leaderboard items sorted by lifetime fees ### Example ```typescript const leaderboard = await sdk.state.getTopTokensByLifetimeFees(); leaderboard.slice(0, 10).forEach((item, i) => { console.log(`${i + 1}. ${item.tokenMint}: ${item.lifetimeFees} SOL`); }); ``` ``` -------------------------------- ### Run Tests Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Execute the project's test suite. ```bash npm test ``` -------------------------------- ### getPoolConfigKeysByFeeClaimerVaults Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/03-state-service.md Get pool configuration keys for fee claimer vaults. ```APIDOC ## getPoolConfigKeysByFeeClaimerVaults ### Description Get pool configuration keys for fee claimer vaults. ### Method async ### Parameters #### Path Parameters - **feeClaimerVaults** (Array) - Required - Array of fee claimer vault addresses ### Returns `Array` - Configuration public keys (may include null values) ### Note This function has a 3-minute timeout on first run due to potential large config sets. Results are cached after first run. ### Throws `ApiError` - When the request fails ### Example ```typescript const vaults = [vault1, vault2, vault3]; const configKeys = await sdk.state.getPoolConfigKeysByFeeClaimerVaults(vaults); console.log('Config Keys:', configKeys); ``` ``` -------------------------------- ### Trade Service Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Get swap quotes and build swap transactions. ```APIDOC ## Trade Service ### Description Provides functionality to get swap quotes and build swap transactions. ### Methods #### getQuote - **Description**: Fetches a swap quote for a given token pair and amount. - **Parameters**: - **inputMint** (string) - Required - The mint address of the input token. - **outputMint** (string) - Required - The mint address of the output token. - **amount** (number) - Required - The amount of input tokens to swap (in lamports). - **slippageMode** (string) - Required - The slippage mode ('exact' or 'dynamic'). - **Returns**: A swap quote object. ``` -------------------------------- ### Get Incorporation Details Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Retrieves the current status and details of an ongoing incorporation process. ```APIDOC ## GET /incorporation/getDetails ### Description Retrieves the current status and details of an ongoing incorporation process. ### Method GET ### Endpoint /incorporation/getDetails ### Parameters #### Query Parameters - **tokenAddress** (PublicKey) - Required - The address of the token associated with the incorporation. ``` -------------------------------- ### startIncorporation Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/10-incorporation-service.md Begins the formal incorporation process after all prerequisites are met. This is a preparatory step before full incorporation. ```APIDOC ## startIncorporation ### Description Begin the formal incorporation process after all prerequisites are met. ### Method Signature ```typescript async startIncorporation(params: StartIncorporationParams): Promise ``` ### Parameters #### params - **tokenAddress** (PublicKey) - Required - Token mint address ### Returns `StartIncorporationResponse` #### StartIncorporationResponse Structure ```typescript interface StartIncorporationResponse { tokenAddress: string; incorporationStarted: boolean; } ``` ### Throws `ApiError` - When incorporation cannot start (prerequisites not met) ### Example ```typescript const result = await sdk.incorporation.startIncorporation({ tokenAddress: new PublicKey('TokenMint'), }); if (result.incorporationStarted) { console.log('Incorporation process started!'); } ``` ``` -------------------------------- ### BagsSDK Constructor Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Initializes the main SDK class, providing access to all services. Requires an API key, a Solana Connection instance, and an optional commitment level. ```APIDOC ## BagsSDK Constructor ### Description Initializes the main SDK class that provides access to all services. ### Parameters - **apiKey** (string) - Required - Your Bags API key - **connection** (Connection) - Required - Solana web3.js Connection instance - **commitment** (Commitment) - Optional - Transaction commitment level (default: 'processed') ``` -------------------------------- ### Get Admin Token Mints Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/14-fee-share-admin-service.md Retrieves a list of token mints that the specified admin wallet is managing. ```APIDOC ## GET /feeShareAdmin/getAdminTokenMints ### Description Retrieves a list of token mints managed by a given admin wallet. ### Method GET ### Endpoint /feeShareAdmin/getAdminTokenMints ### Parameters #### Query Parameters - **adminWallet** (PublicKey) - Required - The public key of the admin wallet. ### Response #### Success Response (200) - **adminMints** (Array) - A list of token mint public keys. ``` -------------------------------- ### StartPaymentParams Interface Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/12-types-reference.md Parameters required to initiate a payment for an incorporation. ```APIDOC ## Interface: StartPaymentParams ### Description Defines the parameters needed to start a payment process. ### Fields - **payerWallet** (PublicKey) - Required - The wallet address of the payer. - **payWithSol** (boolean) - Optional - If true, the payment will be made with SOL; otherwise, USDC is used. ``` -------------------------------- ### Get Partner Configuration Claim Transactions Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/08-partner-service.md Generates the necessary transactions for a partner to claim their accumulated fees. ```APIDOC ## getPartnerConfigClaimTransactions ### Description Generates claim transactions for a partner. ### Method `sdk.partner.getPartnerConfigClaimTransactions(partnerWallet: PublicKey)` ### Parameters #### Path Parameters - **partnerWallet** (PublicKey) - Required - The public key of the partner wallet. ### Response #### Success Response (200) - **transaction** (Transaction) - The transaction object for claiming fees. ### Response Example ```json { "transaction": "" } ``` ``` -------------------------------- ### Get Transfer Admin Transaction Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/14-fee-share-admin-service.md Generates a transaction to transfer administrative control of a token mint to a new admin. ```APIDOC ## POST /feeShareAdmin/getTransferAdminTransaction ### Description Generates a transaction to transfer administrative control of a token mint from the current admin to a new admin. ### Method POST ### Endpoint /feeShareAdmin/getTransferAdminTransaction ### Parameters #### Request Body - **baseMint** (PublicKey) - Required - The mint ID of the token. - **currentAdmin** (PublicKey) - Required - The public key of the current admin. - **newAdmin** (PublicKey) - Required - The public key of the new admin. - **payer** (PublicKey) - Required - The public key of the payer for the transaction. ### Request Example ```json { "baseMint": "PublicKey", "currentAdmin": "PublicKey", "newAdmin": "PublicKey", "payer": "PublicKey" } ``` ### Response #### Success Response (200) - **transferTx** (Transaction) - The transaction to transfer admin ownership. ``` -------------------------------- ### Verify API Key with Bags SDK Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/15-auth-service.md Demonstrates how to initialize the Bags SDK with an API key and connection, then verify the API key's validity by fetching the authenticated user's profile. This is essential for making authenticated requests. ```typescript import { BagsSDK } from '@bagsfm/bags-sdk'; import { Connection } from '@solana/web3.js'; const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=your-helius-key'); const apiKey = process.env.BAGS_API_KEY || 'your-bags-api-key'; const sdk = new BagsSDK(apiKey, connection); async function verifyApiKey() { try { const profile = await sdk.auth.me(); console.log('✓ API Key is valid'); console.log(`User: @${profile.user.username}`); return true; } catch (error) { console.error('✗ API Key authentication failed:', error.message); return false; } } const isValid = await verifyApiKey(); if (!isValid) { process.exit(1); } ``` -------------------------------- ### Get Update Config Transactions Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/14-fee-share-admin-service.md Generates transactions to update the fee distribution configuration for a given token mint. ```APIDOC ## POST /feeShareAdmin/getUpdateConfigTransactions ### Description Generates transactions to update the fee distribution configuration for a specific token mint. ### Method POST ### Endpoint /feeShareAdmin/getUpdateConfigTransactions ### Parameters #### Request Body - **baseMint** (PublicKey) - Required - The mint ID of the token whose fee configuration is being updated. - **feeClaimers** (Array) - Required - An array of objects, each specifying a user and their basis points. - **payer** (PublicKey) - Required - The public key of the payer for the transactions. - **additionalLookupTables** (Array) - Optional - An array of additional LUT addresses to use. ### Request Example ```json { "baseMint": "PublicKey", "feeClaimers": [ { "user": "PublicKey1", "userBps": 5000 }, { "user": "PublicKey2", "userBps": 5000 } ], "payer": "PublicKey", "additionalLookupTables": ["PublicKey"] } ``` ### Response #### Success Response (200) - **updateTxs** (Array<{ transaction: Transaction }>) - An array of transactions to update the configuration. ``` -------------------------------- ### Check Formatting Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Check if the source files are correctly formatted. ```bash npm run format:check ``` -------------------------------- ### GetTradeQuoteParams Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/12-types-reference.md Parameters required to get a trade quote. This includes input and output mints, the amount to trade, and optional slippage settings. ```APIDOC ## GetTradeQuoteParams ### Description Parameters required to get a trade quote. This includes input and output mints, the amount to trade, and optional slippage settings. ### Type Definition ```typescript type GetTradeQuoteParams = { inputMint: PublicKey; outputMint: PublicKey; amount: number; slippageMode?: TradeSlippageMode; slippageBps?: number; } ``` ``` -------------------------------- ### Format Source Files Source: https://github.com/bagsfm/bags-sdk/blob/main/README.md Format the source files according to the project's code style. ```bash npm run format ``` -------------------------------- ### Get Partner Configuration Claim Statistics Source: https://github.com/bagsfm/bags-sdk/blob/main/_autodocs/08-partner-service.md Retrieves the current fee claim statistics for a given partner, including claimed and unclaimed fees. ```APIDOC ## getPartnerConfigClaimStats ### Description Retrieves the fee claim statistics for a partner. ### Method `sdk.partner.getPartnerConfigClaimStats(partnerWallet: PublicKey)` ### Parameters #### Path Parameters - **partnerWallet** (PublicKey) - Required - The public key of the partner wallet. ### Response #### Success Response (200) - **claimedFees** (string) - Lamports already claimed. - **unclaimedFees** (string) - Lamports available to claim. ### Response Example ```json { "claimedFees": "1000000", "unclaimedFees": "500000" } ``` ```