> ## Documentation Index
> Fetch the complete documentation index at: https://blitzz.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Claim Creator Fees

> Here are some code examples for Claiming Creator Fees using Blitzz API

## Local Trade Mode

<Check>
  You can also include transferConfig in your requests to /local-trade if you want to send through a transaction processor (e.g. Astralane, Jito, Helius Sender etc)
</Check>

<CodeGroup>
  ```rust Rust theme={null}
  use anyhow::Result;
  use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
  use serde::{Deserialize, Serialize};
  use solana_client::rpc_client::RpcClient;
  use solana_sdk::{signature::Keypair, signer::Signer, transaction::VersionedTransaction};
  use std::env;

  const BLITZZ_API: &str = "https://api.blitzz.fun";
  const RPC_URL: &str = "https://api.mainnet-beta.solana.com";

  #[derive(Serialize)]
  struct ClaimRequest {
      #[serde(rename = "type")]
      tx_type: String,
      pool: String,
      creator: String,
      #[serde(rename = "prioFee")]
      prio_fee: f64,
  }

  #[derive(Deserialize)]
  struct TxResponse {
      tx: Option<String>,
      error: Option<String>,
  }

  #[tokio::main]
  async fn main() -> Result<()> {
      let private_key = env::var("SOLANA_PRIVATE_KEY")?;
      let keypair = Keypair::from_base58_string(&private_key);

      // Build unsigned transaction
      let request = ClaimRequest {
          tx_type: "claimCreatorFees".to_string(),
          pool: "pump".to_string(),
          creator: keypair.pubkey().to_string(),
          prio_fee: 0.0005,
      };

      let client = reqwest::Client::new();
      let tx_res: TxResponse = client
          .post(format!("{}/local-trade", BLITZZ_API))
          .json(&request)
          .send()
          .await?
          .json()
          .await?;

      if let Some(error) = tx_res.error {
          anyhow::bail!("API error: {}", error);
      }

      // Sign and send transaction
      let tx_bytes = BASE64.decode(tx_res.tx.unwrap())?;
      let mut transaction: VersionedTransaction = bincode::deserialize(&tx_bytes)?;
      transaction.sign(&[&keypair], transaction.message.recent_blockhash());

      let rpc_client = RpcClient::new(RPC_URL);
      let signature = rpc_client.send_and_confirm_transaction(&transaction)?;

      println!("Creator fees claimed! Signature: {}", signature);
      Ok(())
  }
  ```

  ```python Python theme={null}
  import os
  import base64
  import requests
  from solders.keypair import Keypair
  from solders.transaction import VersionedTransaction
  from solana.rpc.api import Client

  BLITZZ_API = "https://api.blitzz.fun"
  RPC_URL = "https://api.mainnet-beta.solana.com"

  def claim_creator_fees_local_mode():
      keypair = Keypair.from_base58_string(os.environ["SOLANA_PRIVATE_KEY"])
      
      # Build unsigned transaction
      tx_res = requests.post(f"{BLITZZ_API}/local-trade", json={
          "type": "claimCreatorFees",
          "pool": "pump",
          "creator": str(keypair.pubkey()),
          "prioFee": 0.0005
      })
      
      result = tx_res.json()
      if "error" in result:
          raise Exception(result["error"])
      
      # Sign and send transaction
      tx_bytes = base64.b64decode(result["tx"])
      transaction = VersionedTransaction.from_bytes(tx_bytes)
      transaction.sign([keypair])
      
      client = Client(RPC_URL)
      signature = client.send_transaction(transaction).value
      client.confirm_transaction(signature)
      
      print(f"Creator fees claimed! Signature: {signature}")
      return signature

  if __name__ == "__main__":
      claim_creator_fees_local_mode()
  ```

  ```javascript Javascript theme={null}
  import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
  import bs58 from 'bs58';

  const BLITZZ_API = 'https://api.blitzz.fun';
  const RPC_URL = 'https://api.mainnet-beta.solana.com';

  async function claimCreatorFeesLocalMode() {
    const keypair = Keypair.fromSecretKey(bs58.decode(process.env.SOLANA_PRIVATE_KEY));
    
    // Build unsigned transaction
    const txRes = await fetch(`${BLITZZ_API}/local-trade`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        type: 'claimCreatorFees',
        pool: 'pump',
        creator: keypair.publicKey.toBase58(),
        prioFee: 0.0005
      })
    });

    const { tx, error } = await txRes.json();
    if (error) throw new Error(error);

    // Sign and send transaction
    const connection = new Connection(RPC_URL);
    const transaction = VersionedTransaction.deserialize(Buffer.from(tx, 'base64'));
    transaction.sign([keypair]);

    const signature = await connection.sendTransaction(transaction);
    await connection.confirmTransaction(signature, 'confirmed');

    console.log('Creator fees claimed! Signature:', signature);
    return signature;
  }

  claimCreatorFeesLocalMode().catch(console.error);
  ```
</CodeGroup>

## Blitzz Mode

<CodeGroup>
  ```rust Rust theme={null}
  use anyhow::Result;
  use serde::{Deserialize, Serialize};
  use std::env;

  const BLITZZ_API: &str = "https://api.blitzz.fun";

  #[derive(Serialize)]
  struct ClaimRequest {
      #[serde(rename = "type")]
      tx_type: String,
      pool: String,
      creator: String,
      #[serde(rename = "prioFee")]
      prio_fee: f64,
      #[serde(rename = "privateKey")]
      private_key: String,
  }

  #[derive(Deserialize)]
  struct BlitzzResponse {
      status: Option<String>,
      signature: Option<String>,
      error: Option<String>,
  }

  #[tokio::main]
  async fn main() -> Result<()> {
      let private_key = env::var("SOLANA_PRIVATE_KEY")?;
      
      // Parse keypair to get public key for creator field
      use solana_sdk::{signature::Keypair, signer::Signer};
      let keypair = Keypair::from_base58_string(&private_key);
      let creator = keypair.pubkey().to_string();

      // Build, sign, and send in one call
      let request = ClaimRequest {
          tx_type: "claimCreatorFees".to_string(),
          pool: "pump".to_string(),
          creator,
          prio_fee: 0.0005,
          private_key,
      };

      let client = reqwest::Client::new();
      let res: BlitzzResponse = client
          .post(format!("{}/blitzz", BLITZZ_API))
          .json(&request)
          .send()
          .await?
          .json()
          .await?;

      if let Some(error) = res.error {
          anyhow::bail!("API error: {}", error);
      }

      println!("Creator fees claimed! Status: {}", res.status.unwrap());
      println!("Signature: {}", res.signature.unwrap());
      Ok(())
  }
  ```

  ```python Python theme={null}
  import os
  import requests
  from solders.keypair import Keypair

  BLITZZ_API = "https://api.blitzz.fun"

  def claim_creator_fees_blitzz_mode():
      private_key = os.environ["SOLANA_PRIVATE_KEY"]
      
      # Get creator public key from private key
      keypair = Keypair.from_base58_string(private_key)
      creator = str(keypair.pubkey())
      
      # Build, sign, and send in one call
      res = requests.post(f"{BLITZZ_API}/blitzz", json={
          "type": "claimCreatorFees",
          "pool": "pump",
          "creator": creator,
          "prioFee": 0.0005,
          "privateKey": private_key
      })
      
      result = res.json()
      if "error" in result:
          raise Exception(result["error"])
      
      print(f"Creator fees claimed! Status: {result['status']}")
      print(f"Signature: {result['signature']}")
      return result["signature"]

  if __name__ == "__main__":
      claim_creator_fees_blitzz_mode()
  ```

  ```javascript Javascript theme={null}
  import { Keypair } from '@solana/web3.js';
  import bs58 from 'bs58';

  const BLITZZ_API = 'https://api.blitzz.fun';

  async function claimCreatorFeesBlitzzMode() {
    const privateKey = process.env.SOLANA_PRIVATE_KEY;
    
    // Get creator public key from private key
    const keypair = Keypair.fromSecretKey(bs58.decode(privateKey));
    const creator = keypair.publicKey.toBase58();
    
    // Build, sign, and send in one call
    const res = await fetch(`${BLITZZ_API}/blitzz`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        type: 'claimCreatorFees',
        pool: 'pump',
        creator,
        prioFee: 0.0005,
        privateKey
      })
    });

    const { status, signature, error } = await res.json();
    if (error) throw new Error(error);

    console.log('Creator fees claimed! Status:', status);
    console.log('Signature:', signature);
    return signature;
  }

  claimCreatorFeesBlitzzMode().catch(console.error);
  ```
</CodeGroup>
