MCPcopy Index your code
hub / github.com/0xfnzero/pumpfun-sdk

github.com/0xfnzero/pumpfun-sdk @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
244 symbols 367 edges 31 files 38 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PumpFun Rust SDK

中文 | English | Telegram | Discord

A comprehensive Rust SDK for seamless interaction with the PumpFun Solana program. This SDK provides a robust set of tools and interfaces to integrate PumpFun functionality into your applications.

What This SDK Provides

PumpFun Rust SDK is a Solana trading and event subscription toolkit for applications that need Pump.fun token creation, buy/sell transactions, log streaming, and low-latency transaction submission.

Area Coverage
Pump.fun operations Token create, buy, sell, sell by percent
Event streams PumpFun program log subscription and Yellowstone gRPC subscriptions
Transaction submission Standard RPC, Jito bundle, Nextblock, and 0slot submission paths
Use cases Pump.fun trading bots, launch monitoring, memecoin tooling, low-latency Solana transaction workflows

Feature Summary

  1. Add create, buy, sell for pump.fun.
  2. Add logs_subscribe to subscribe the logs of the PumpFun program.
  3. Add yellowstone grpc to subscribe the logs of the PumpFun program.
  4. Add jito to send transaction with Jito.
  5. Add nextblock to send transaction with nextblock.
  6. Add 0slot to send transaction with 0slot.
  7. Submit a transaction using Jito, Nextblock, and 0slot simultaneously; the fastest one will succeed, while the others will fail.

Usage

cd `your project root directory`
git clone https://github.com/0xfnzero/pumpfun-sdk
# add to your Cargo.toml
pumpfun-sdk = { path = "./pumpfun-sdk", version = "2.4.3" }

logs subscription for token create and trade transaction

use pumpfun_sdk::{common::logs_events::PumpfunEvent, grpc::YellowstoneGrpc};

// create grpc client
let grpc_url = "http://127.0.0.1:10000";
let client = YellowstoneGrpc::new(grpc_url);

// Define callback function
let callback = |event: PumpfunEvent| {
    match event {
        PumpfunEvent::NewToken(token_info) => {
            println!("Received new token event: {:?}", token_info);
        },
        PumpfunEvent::NewDevTrade(trade_info) => {
            println!("Received dev trade event: {:?}", trade_info);
        },
        PumpfunEvent::NewUserTrade(trade_info) => {
            println!("Received new trade event: {:?}", trade_info);
        },
        PumpfunEvent::NewBotTrade(trade_info) => {
            println!("Received new bot trade event: {:?}", trade_info);
        }
        PumpfunEvent::Error(err) => {
            println!("Received error: {}", err);
        }
    }
};

let payer_keypair = Keypair::from_base58_string("your private key");
client.subscribe_pumpfun(callback, Some(payer_keypair.pubkey())).await?;

Init pumpfun instance for configs

use std::sync::Arc;
use pumpfun_sdk::{common::{Cluster, PriorityFee}, PumpFun};
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair, signer::Signer};

let priority_fee = PriorityFee{
    unit_limit: 190000,
    unit_price: 1000000,
    buy_tip_fee: 0.001,
    sell_tip_fee: 0.0001,
};

let cluster = Cluster {
    rpc_url: "https://api.mainnet-beta.solana.com".to_string(),
    block_engine_url: "https://block-engine.example.com".to_string(),
    nextblock_url: "https://nextblock.example.com".to_string(),
    nextblock_auth_token: "nextblock_api_token".to_string(),
    zeroslot_url: "https://zeroslot.example.com".to_string(),
    zeroslot_auth_token: "zeroslot_api_token".to_string(),
    use_jito: true,
    use_nextblock: false,
    use_zeroslot: false,
    priority_fee,
    commitment: CommitmentConfig::processed(),
};

// create pumpfun instance
let payer = Keypair::from_base58_string("your private key");
let pumpfun = PumpFun::new(
    Arc::new(payer), 
    &cluster,
).await;

pumpfun buy token

use pumpfun_sdk::PumpFun;
use solana_sdk::{native_token::sol_to_lamports, signature::Keypair, signer::Signer};

// create pumpfun instance
let pumpfun = PumpFun::new(Arc::new(payer), &cluster).await;

// Mint keypair
let mint_pubkey: Keypair = Keypair::new();

// buy token with tip
pumpfun.buy_with_tip(mint_pubkey, 10000, None).await?;

pumpfun sell token

use pumpfun_sdk::PumpFun;
use solana_sdk::{native_token::sol_to_lamports, signature::Keypair, signer::Signer};

// create pumpfun instance
let pumpfun = PumpFun::new(Arc::new(payer), &cluster).await;

// sell token with tip
pumpfun.sell_with_tip(mint_pubkey, 100000, None).await?;

// sell token by percent with tip
pumpfun.sell_by_percent_with_tip(mint_pubkey, 100, None).await?;

Telegram group:

https://t.me/fnzero_group

Extension points exported contracts — how you extend this code

EventTrait (Interface)
(no doc) [4 implementers]
src/common/logs_data.rs
FeeClientTrait (Interface)
(no doc) [3 implementers]
src/swqos/mod.rs
Api (Interface)
(no doc)
src/swqos/api.rs

Core symbols most depended-on inside this repo

clone
called by 45
src/swqos/api.rs
clone
called by 38
src/lib.rs
get_initial_buy_price
called by 7
src/accounts/global.rs
poll_transaction_confirmation
called by 4
src/swqos/common.rs
get_sol_balance
called by 3
src/pumpfun/common.rs
get_token_balance
called by 3
src/pumpfun/sell.rs
serialize_smart_transaction_and_encode
called by 3
src/swqos/common.rs
send_transaction
called by 3
src/swqos/mod.rs

Shape

Method 87
Class 73
Function 69
Enum 12
Interface 3

Languages

Rust100%

Modules by API surface

src/swqos/jito_grpc/searcher.rs30 symbols
src/swqos/api.rs30 symbols
src/pumpfun/common.rs20 symbols
src/lib.rs20 symbols
src/swqos/jito_grpc/bundle.rs18 symbols
src/swqos/mod.rs14 symbols
src/grpc/mod.rs11 symbols
src/accounts/global.rs9 symbols
src/swqos/jito_grpc/convert.rs8 symbols
src/pumpfun/sell.rs8 symbols
src/swqos/searcher_client.rs7 symbols
src/common/logs_data.rs7 symbols

For agents

$ claude mcp add pumpfun-sdk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact