Launch

Launch a Token

POST /trade/local/launch

Create a local transaction to launch a token.

Body

Name
Type
Required
Description

mint

string

Yes

bs58 public key for the mint.

publicKey

string

Yes

bs58 public key of the dev wallet

amount

number

No, but if you want the dev wallet to buy you have to choose between amount or percentage; not both.

Amount to buy on the dev wallet denominated by ccy field.

ccy

"sol" | "lamports" | "token" | "usd"

Yes IF amount is provided; No IF using percentage or not buying on dev wallet.

Denomination for amount field (buy 1 sol, buy 1 usd, etc...)

percentage

number > 0 & <=100

No, but if you want the dev wallet to buy you have to choose between amount or percentage; not both.

Percentage of account to buy (1 =1%, 10=10%). Buying 10% means spending 10% of sol in your wallet. There is a known bug when buying super high percentages due to fees. We have acknowledged this issue and are actively working on a fix. We recommend not buying more than 80%.

priorityFee

number > 0.00001

No - defaults to 0.001

Priority Fee denominated in solana. The higher it is, the faster and higher success rate for the transaction is. You can get the optimal priority fee from Recommended Priority

tokenMetadata

object

Yes

An object containing the following fields.

tokenMetadata.name

string

Yes

The name of your token - must match one posted to pump.fun

tokenMetadata.symbol

string

Yes

The ticker of your token - must match one posted to pump.fun.

tokenMetadata.uri

string

Yes

The ipfs url received from posting metadata to pump.fun.

Response

Serialized V0 Transaction as bytes.

Tutorial

import { Connection, Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";
import "dotenv/config";
import fs from "fs";

// Initialize the connection to your rpc with a confirmation level of "confirmed"
const connection = new Connection(process.env.RPC_URL!, "confirmed");

// Initialize the keypair from a secret key or however you retrieve your wallet
const devWallet = Keypair.fromSecretKey(bs58.decode(process.env.SECRET_KEY!));

async function localLaunch() {
  // Create a random CA for the token
  const mint = Keypair.generate();

  // token metadata
  const tokenMetadata = new FormData();
  tokenMetadata.append("file", await fs.openAsBlob("./logo.png")); // Load image
  tokenMetadata.append("name", "name of token"); // Name of the token
  tokenMetadata.append("symbol", "ticker"); // Symbol (ticker) of the token
  tokenMetadata.append("description", "This is my description"); // Description of the token (optional)
  tokenMetadata.append("twitter", "https://x.com/"); // Twitter link (optional)
  tokenMetadata.append("telegram", "https://t.me/"); // Telegram link (optional)
  tokenMetadata.append("website", "https://pumplify.fun/"); // Website link (optional)

  // Upload metadata
  const metadataResponse = await fetch("https://pump.fun/api/ipfs", {
    method: "POST",
    body: tokenMetadata,
  });
  const metadataResponseJSON = await metadataResponse.json();

  // Create the transaction
  const response = await fetch(`https://api.pumplify.fun/trade/local/launch`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      publicKey: devWallet.publicKey.toBase58(), //dev wallet public key
      mint: mint.publicKey.toBase58(), //ca of the token
      tokenMetadata: {
        name: metadataResponseJSON.metadata.name, //keep this as is
        symbol: metadataResponseJSON.metadata.symbol, //keep this as is
        uri: metadataResponseJSON.metadataUri, //keep this as is
      },
      amount: 1, // dev buy
      ccy: "sol", // denomination of the amount
      priorityFee: 0.001,
    }),
  });

  // Check if the response succeeded
  if (!response.ok) {
    // If the response is not ok, print the error
    console.error("Launch failed:", await response.json());
    return;
  }

  // Get the array buffer from the response
  const serializedTxBuffer = await response.arrayBuffer();
  // Deserialize the transaction
  const tx = VersionedTransaction.deserialize(
    new Uint8Array(serializedTxBuffer)
  );
  // Sign the transaction with the dev wallet and the mint
  tx.sign([mint, devWallet]);
  // Send the transaction
  const signature = await connection.sendTransaction(tx);
  console.log("Transaction: https://solscan.io/tx/" + signature);
  console.log("pump.fun: https://pump.fun/coin/" + mint.publicKey.toBase58());
}

localLaunch();

Last updated