Skip to main content
In this guide, you’ll learn how to launch a Solana token using the Bags TypeScript SDK with Node.js. Token Launch v2 requires fee sharing configuration, where all fees are shared with the creator’s wallet by default. You can optionally share fees with additional fee claimers.

Prerequisites

Before starting, make sure you have:
  • Completed our TypeScript and Node.js Setup Guide.
  • Got your API key from the Bags Developer Portal.
  • A Solana wallet with some SOL for transactions.
  • A token image URL (recommended) or image file.
  • Installed the additional dependencies for this guide:
Optional: If you want to include a partner configuration in your token launch, you’ll need to create a partner key first. See the Create Partner Key guide for details. Once you have a partner key, you can include it when launching tokens using the partner and partnerConfig parameters.

1. Set Up Environment Variables

This guide requires your wallet’s private key. Add it to your base .env file:
You can export your private key from wallets like Bags, Phantom, or Backpack.

2. The Token Launch Script

Here is the complete script for launching a token. Save it as launch-token.ts. The script follows the Token Launch v2 flow:
  1. Create metadata
  2. Create config (fee share configuration)
  3. Get token creation transaction
  4. Sign transaction
  5. Broadcast transaction

Endpoints Used Under the Hood

This SDK flow calls these documented endpoints: This guide also uses SDK Solana helper methods for Jito bundle/tip workflows. Those helper endpoints are currently undocumented in this docs set, so they are intentionally not linked here.

3. Understanding Fee Sharing

Token Launch v2 requires fee sharing configuration with explicit BPS (basis points) allocation. Important rules:

Key Rules

  1. Creators must always explicitly set their BPS: To receive all fees, creators must give themselves the maximum BPS (10000) explicitly, no matter what. Creator fees must always be set explicitly in the fee claimers array.
  2. When sharing fees: Give fee claimers their BPS and then explicitly also give the creator their BPS. Both the creator and all fee claimers must have their BPS values set explicitly in the configuration.
  3. Total BPS must equal 10000: The sum of all BPS values (creator + all fee claimers) must equal exactly 10,000 (100%).
  4. Maximum fee earners: You can have up to 100 fee earners (including the creator) per token launch.
  5. Supported platforms: Fee claimers can be identified using supported social platforms: twitter, kick, and github.
  6. Lookup Tables (LUTs): When you have more than 15 fee claimers, you need to create lookup tables before creating the fee share config. The script automatically handles this by:
    • Calling getConfigCreationLookupTableTransactions() to get LUT creation transactions
    • Executing the LUT creation transaction
    • Waiting for one slot to pass (required by Solana)
    • Executing all LUT extend transactions
    • Passing the LUT addresses to createBagsFeeShareConfig via additionalLookupTables

Partner Configuration

You can include a partner configuration in your fee share setup by providing:
  • partner: The partner wallet address (PublicKey)
  • partnerConfig: The partner config PDA (PublicKey) - can be derived using the helper function shown in the examples
Partners receive a share of fees from token launches that include their partner configuration. This is useful for platforms or partnerships that want to collect fees from multiple token launches.
To create a partner key, see the Create Partner Key guide.

Alternative: Using the Bags CLI

This section requires the Bags CLI. See Install and Set Up the Bags CLI to get started.
The CLI wraps the entire multi-step launch flow (metadata upload, fee share config, lookup tables, Jito bundles, and launch transaction) into a single command: Launch with all fees to creator:
Launch with fee sharing:
The creator automatically receives the remaining BPS (in the example above, 50%). Launch with a partner:
If you omit the flags, the CLI guides you through an interactive wizard that lets you add fee claimers one at a time (by social username or wallet address) and set their BPS allocation.

4. Run Your Script

To launch your token, edit the launchToken function call at the bottom of launch-token.ts with your token’s details, especially the imageUrl. Then, run the script from your terminal:

5. Troubleshooting

The script includes comprehensive error handling. Common issues include:
  • API Key Issues: Ensure your API key is valid.
  • Private Key Format: Your private key must be base58 encoded.
  • Insufficient SOL: Your wallet needs SOL for transaction fees.
  • Image URL: The URL to your token image must be accessible and valid.
  • Invalid Fee Claimer: Ensure the fee claimer provider and username are valid and the user has a registered wallet.
For more details, see the API Reference.