Skip to main content
In this guide, you’ll learn how to create a partner key (partner config key) for fee sharing. Partner keys allow you to receive a share of fees from token launches that include your partner configuration. You can create a partner key using either the Bags Dev Dashboard or the TypeScript SDK.
Transaction Fees: Creating a partner key requires a Solana transaction. Make sure your wallet has sufficient SOL balance to pay for transaction fees.
One key per wallet: Each wallet can have only one partner key. If you need multiple partner keys, use multiple wallets and create a partner key for each wallet via the SDK.Default fee share: By default, a partner key receives 25% (2,500 bps) of the fees generated by tokens launched via that partner key. If you need a custom percentage, reach out to us and we can configure it for your account.

Method 1: Using the Dev Dashboard

The easiest way to create a partner key is through the Bags Developer Dashboard.

Step 1: Access the Dashboard

  1. Go to https://dev.bags.fm and log in with your account.

Step 2: Create Partner Key

  1. Click the “Create partner key” button in the dashboard.
  2. Confirm creation in the confirmation modal by clicking the “Create partner key” button
  3. Note: Only one partner key can be created per wallet.
Create Partner Key Button Partner Key Table

Step 3: View Your Partner Config

  1. After creating your partner key, you can view it in the Partner Key table below.
  2. You can copy your partner config key (PDA) from the table.
  3. The table also displays your claim stats, including claimed and unclaimed fees.
Your partner config key is now ready to use in token launches! See the Launch a Token guide for details on how to include it.

Method 2: Using the SDK

You can also create a partner key programmatically using the Bags TypeScript SDK.

Prerequisites

Before starting, make sure you have:

1. Set Up Environment Variables

This guide requires your wallet’s private key. Add it to your base .env file:
# .env
BAGS_API_KEY=your_api_key_here
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
PRIVATE_KEY=your_base58_encoded_private_key_here  # Required for this guide
You can export your private key from wallets like Bags, Phantom, or Backpack.

2. The Partner Key Creation Script

Here is the complete script for creating a partner key. Save it as create-partner-key.ts.
import dotenv from "dotenv";
dotenv.config({ quiet: true });

import { BagsSDK, deriveBagsFeeShareV2PartnerConfigPda, signAndSendTransaction } from "@bagsfm/bags-sdk";
import {
  Keypair,
  PublicKey,
  Connection,
} from "@solana/web3.js";
import bs58 from "bs58";

// Initialize SDK
const BAGS_API_KEY = process.env.BAGS_API_KEY;
const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

if (!BAGS_API_KEY || !SOLANA_RPC_URL || !PRIVATE_KEY) {
  throw new Error("BAGS_API_KEY, SOLANA_RPC_URL, and PRIVATE_KEY are required");
}

const connection = new Connection(SOLANA_RPC_URL);
const sdk = new BagsSDK(BAGS_API_KEY, connection, "processed");

async function createPartnerKey(partnerWallet: PublicKey) {
  try {
    if (!PRIVATE_KEY) {
      throw new Error("PRIVATE_KEY is not set");
    }

    const keypair = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));

    console.log(
      `🔑 Creating partner key for wallet: ${partnerWallet.toBase58()}`
    );

    // Check if partner config already exists
    const partnerConfigPda = deriveBagsFeeShareV2PartnerConfigPda(partnerWallet);
    console.log(`📍 Partner Config PDA: ${partnerConfigPda.toBase58()}`);

    try {
      const existingConfig = await sdk.partner.getPartnerConfig(partnerWallet);
      console.log("♻️  Partner config already exists!");
      console.log(`   Partner: ${existingConfig.partner.toBase58()}`);
      console.log(`   BPS: ${existingConfig.bps}`);
      console.log(
        `   Total Claimed Fees: ${existingConfig.totalClaimedFees.toString()}`
      );
      return partnerConfigPda;
    } catch (error: any) {
      if (!error.message?.includes("not found")) {
        throw error;
      }
      // Partner config doesn't exist, proceed with creation
    }

    // Get the partner config creation transaction
    console.log("📝 Getting partner config creation transaction...");
    const { transaction, blockhash } =
      await sdk.partner.getPartnerConfigCreationTransaction(partnerWallet);

    // Sign and send the transaction
    const commitment = sdk.state.getCommitment();
    console.log("🔐 Signing and sending transaction...");
    const signature = await signAndSendTransaction(connection, commitment, transaction, keypair, blockhash);

    console.log("🎉 Partner key created successfully!");
    console.log(`📍 Partner Config PDA: ${partnerConfigPda.toBase58()}`);
    console.log(`🔑 Transaction Signature: ${signature}`);

    return partnerConfigPda;
  } catch (error) {
    console.error("🚨 Partner key creation failed:", error);
    throw error;
  }
}

// Example: Create a partner key for a specific wallet
// Replace with your partner wallet address
const partnerWallet = new PublicKey("YOUR_PARTNER_WALLET_ADDRESS_HERE");

createPartnerKey(partnerWallet)
  .then((partnerConfigPda) => {
    console.log(
      `\n✨ Partner key ready! Use this Partner Config PDA in your token launches:`
    );
    console.log(`   ${partnerConfigPda.toBase58()}`);
  })
  .catch((error) => {
    console.error("🚨 Unexpected error occurred:", error);
  });

3. Understanding Partner Keys

A partner key (partner config) is a program-derived address (PDA) that represents a partner’s configuration for receiving fee shares. When you create a partner key:
  1. Partner Wallet: The wallet address that will receive the partner’s share of fees
  2. Partner Config PDA: A derived address that uniquely identifies the partner configuration
  3. Fee Share: By default, partner keys receive 25% (2,500 bps) of fees from tokens launched via their key. Custom percentages are available on request—contact us to discuss.
  4. Per-Wallet Limit: Each wallet can have only one partner key. To use multiple partner keys, manage multiple wallets and create a partner key for each using the SDK.

When to Use Partner Keys

Partner keys are useful when:
  • You want to receive a share of fees from multiple token launches
  • You’re building a platform that launches tokens and wants to collect fees
  • You have a partnership agreement to receive fees from specific token launches

Using Partner Keys in Token Launches

Once you have a partner config PDA, you can use it when creating fee share configurations for token launches. See the Launch a Token guide for details on how to include partner and partnerConfig parameters.

4. Run Your Script

To create a partner key, edit the partnerWallet variable in create-partner-key.ts with the wallet address that should receive the partner fees. Then, run the script from your terminal:
npx ts-node create-partner-key.ts

5. Next Steps

After creating a partner key, you can:
  • Check Partner Stats: Use sdk.partner.getPartnerConfigClaimStats() to see accumulated fees
  • Claim Partner Fees: See the Claim Partner Fees guide for a complete walkthrough on checking and claiming your partner fees
  • Use in Token Launches: Include your partner config when launching tokens (see Launch a Token guide)

6. Troubleshooting

Common issues include:
  • Partner Config Already Exists: If the partner config already exists, the script will detect it and display the existing configuration.
  • Insufficient SOL: Your wallet needs SOL for transaction fees.
  • Invalid Wallet Address: Ensure the partner wallet address is a valid Solana public key.
For more details, see the API Reference.