> ## 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.

# Token Creation

> Here are some code examples for creating tokens 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 reqwest::multipart::{Form, Part};
  use serde::{Deserialize, Serialize};
  use solana_client::rpc_client::RpcClient;
  use solana_sdk::{signature::Keypair, signer::Signer, transaction::VersionedTransaction};
  use std::{env, fs};

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

  #[derive(Serialize)]
  struct CreateRequest {
      #[serde(rename = "type")]
      tx_type: String,
      pool: String,
      payer: String,
      amount: u64,
      slippage_pct: f64,
      #[serde(rename = "prioFee")]
      prio_fee: f64,
      metadata: Metadata,
  }

  #[derive(Serialize)]
  struct Metadata {
      name: String,
      symbol: String,
      uri: String,
  }

  #[derive(Deserialize)]
  struct IpfsResponse {
      #[serde(rename = "metadataUri")]
      metadata_uri: String,
  }

  #[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);

      // Upload metadata to IPFS
      let image_bytes = fs::read("./token-image.png")?;
      let form = Form::new()
          .part("file", Part::bytes(image_bytes).file_name("token-image.png"))
          .text("name", "My Token")
          .text("symbol", "MTK")
          .text("description", "A token created via Blitzz API")
          .text("twitter", "https://twitter.com/mytoken")
          .text("telegram", "https://t.me/mytoken")
          .text("website", "https://mytoken.com")
          .text("showName", "true");

      let client = reqwest::Client::new();
      let ipfs_res: IpfsResponse = client
          .post("https://pump.fun/api/ipfs")
          .multipart(form)
          .send()
          .await?
          .json()
          .await?;

      // Build unsigned transaction
      let request = CreateRequest {
          tx_type: "create".to_string(),
          pool: "pump".to_string(),
          payer: keypair.pubkey().to_string(),
          amount: 10_000_000,
          slippage_pct: 0.5,
          prio_fee: 0.0005,
          metadata: Metadata {
              name: "My Token".to_string(),
              symbol: "MTK".to_string(),
              uri: ipfs_res.metadata_uri,
          },
      };

      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!("Token created! 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 create_token_local_mode():
      keypair = Keypair.from_base58_string(os.environ["SOLANA_PRIVATE_KEY"])

      # Upload metadata to IPFS
      with open("./token-image.png", "rb") as f:
          files = {"file": ("token-image.png", f, "image/png")}
          data = {
              "name": "My Token",
              "symbol": "MTK",
              "description": "A token created via Blitzz API",
              "twitter": "https://twitter.com/mytoken",
              "telegram": "https://t.me/mytoken",
              "website": "https://mytoken.com",
              "showName": "true"
          }
          ipfs_res = requests.post("https://pump.fun/api/ipfs", files=files, data=data)
          metadata_uri = ipfs_res.json()["metadataUri"]

      # Build unsigned transaction
      tx_res = requests.post(f"{BLITZZ_API}/local-trade", json={
          "type": "create",
          "pool": "pump",
          "payer": str(keypair.pubkey()),
          "amount": 10_000_000,
          "slippage_pct": 0.5,
          "prioFee": 0.0005,
          "metadata": {
              "name": "My Token",
              "symbol": "MTK",
              "uri": metadata_uri
          }
      })

      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"Token created! Signature: {signature}")
      return signature

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

  ```javascript Javascript theme={null}
  import fs from 'fs/promises';
  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 createTokenLocalMode() {
    const keypair = Keypair.fromSecretKey(bs58.decode(process.env.SOLANA_PRIVATE_KEY));

    // Upload metadata to IPFS
    const formData = new FormData();
    formData.append('file', await fs.openAsBlob('./token-image.png'));
    formData.append('name', 'My Token');
    formData.append('symbol', 'MTK');
    formData.append('description', 'A token created via Blitzz API');
    formData.append('twitter', 'https://twitter.com/mytoken');
    formData.append('telegram', 'https://t.me/mytoken');
    formData.append('website', 'https://mytoken.com');
    formData.append('showName', 'true');

    const metadataRes = await fetch('https://pump.fun/api/ipfs', {
      method: 'POST',
      body: formData
    });
    const { metadataUri } = await metadataRes.json();

    // Build unsigned transaction
    const txRes = await fetch(`${BLITZZ_API}/local-trade`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        type: 'create',
        pool: 'pump',
        payer: keypair.publicKey.toBase58(),
        amount: 10000000, // 0.01 SOL initial buy
        slippage_pct: 0.5,
        prioFee: 0.0005,
        metadata: {
          name: 'My Token',
          symbol: 'MTK',
          uri: metadataUri
        }
      })
    });

    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('Token created! Signature:', signature);
    return signature;
  }

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

## Blitzz Mode

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

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

  #[derive(Serialize)]
  struct CreateRequest {
      #[serde(rename = "type")]
      tx_type: String,
      pool: String,
      amount: u64,
      slippage_pct: f64,
      #[serde(rename = "prioFee")]
      prio_fee: f64,
      #[serde(rename = "privateKey")]
      private_key: String,
      metadata: Metadata,
  }

  #[derive(Serialize)]
  struct Metadata {
      name: String,
      symbol: String,
      uri: String,
  }

  #[derive(Deserialize)]
  struct IpfsResponse {
      #[serde(rename = "metadataUri")]
      metadata_uri: 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")?;

      // Upload metadata to IPFS
      let image_bytes = fs::read("./token-image.png")?;
      let form = Form::new()
          .part("file", Part::bytes(image_bytes).file_name("token-image.png"))
          .text("name", "My Token")
          .text("symbol", "MTK")
          .text("description", "A token created via Blitzz API")
          .text("twitter", "https://twitter.com/mytoken")
          .text("telegram", "https://t.me/mytoken")
          .text("website", "https://mytoken.com")
          .text("showName", "true");

      let client = reqwest::Client::new();
      let ipfs_res: IpfsResponse = client
          .post("https://pump.fun/api/ipfs")
          .multipart(form)
          .send()
          .await?
          .json()
          .await?;

      // Build, sign, and send in one call
      let request = CreateRequest {
          tx_type: "create".to_string(),
          pool: "pump".to_string(),
          amount: 10_000_000,
          slippage_pct: 0.5,
          prio_fee: 0.0005,
          private_key,
          metadata: Metadata {
              name: "My Token".to_string(),
              symbol: "MTK".to_string(),
              uri: ipfs_res.metadata_uri,
          },
      };

      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!("Token created! Status: {}", res.status.unwrap());
      println!("Signature: {}", res.signature.unwrap());
      Ok(())
  }
  ```

  ```python Python theme={null}
  import os
  import requests

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

  def create_token_blitzz_mode():
      private_key = os.environ["SOLANA_PRIVATE_KEY"]

      # Upload metadata to IPFS
      with open("./token-image.png", "rb") as f:
          files = {"file": ("token-image.png", f, "image/png")}
          data = {
              "name": "My Token",
              "symbol": "MTK",
              "description": "A token created via Blitzz API",
              "twitter": "https://twitter.com/mytoken",
              "telegram": "https://t.me/mytoken",
              "website": "https://mytoken.com",
              "showName": "true"
          }
          ipfs_res = requests.post("https://pump.fun/api/ipfs", files=files, data=data)
          metadata_uri = ipfs_res.json()["metadataUri"]

      # Build, sign, and send in one call
      res = requests.post(f"{BLITZZ_API}/blitzz", json={
          "type": "create",
          "pool": "pump",
          "amount": 10_000_000,
          "slippage_pct": 0.5,
          "prioFee": 0.0005,
          "privateKey": private_key,
          "metadata": {
              "name": "My Token",
              "symbol": "MTK",
              "uri": metadata_uri
          }
      })

      result = res.json()
      if "error" in result:
          raise Exception(result["error"])

      print(f"Token created! Status: {result['status']}")
      print(f"Signature: {result['signature']}")
      return result["signature"]

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

  ```javascript Javascript theme={null}
  import fs from 'fs/promises';
  import bs58 from 'bs58';

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

  async function createTokenBlitzzMode() {
    const privateKey = bs58.encode(Buffer.from(process.env.SOLANA_PRIVATE_KEY, 'hex'));

    // Upload metadata to IPFS
    const formData = new FormData();
    formData.append('file', await fs.openAsBlob('./token-image.png'));
    formData.append('name', 'My Token');
    formData.append('symbol', 'MTK');
    formData.append('description', 'A token created via Blitzz API');
    formData.append('twitter', 'https://twitter.com/mytoken');
    formData.append('telegram', 'https://t.me/mytoken');
    formData.append('website', 'https://mytoken.com');
    formData.append('showName', 'true');

    const metadataRes = await fetch('https://pump.fun/api/ipfs', {
      method: 'POST',
      body: formData
    });
    const { metadataUri } = await metadataRes.json();

    // 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: 'create',
        pool: 'pump',
        amount: 10000000, // 0.01 SOL initial buy
        slippage_pct: 0.5,
        prioFee: 0.0005,
        privateKey,
        metadata: {
          name: 'My Token',
          symbol: 'MTK',
          uri: metadataUri
        }
      })
    });

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

    console.log('Token created! Status:', status);
    console.log('Signature:', signature);
    return signature;
  }

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