Shyft
Start BuildingSupportWebsite
  • Welcome
    • πŸ‘‹Introducing Shyft
    • πŸ—οΈStart Building
  • Solana Infrastructure
    • 🚁Shyft RPCs
  • Yellowstone gRPC Network
    • Decoding gRPC Latency
    • ⚑gRPC Docs
      • Introduction
      • Authentication
      • Subscribe Requests
      • FAQ
      • Getting Started
        • Initializing the Yellowstone Client
        • Making a gRPC connection
        • Adding a Reconnection Mechanism
        • πŸ”₯Replaying Slots with Solana yellowstone gRPCs
        • Modifying your Subscribe Request
        • Closing a gRPC Connection
      • Subscribing to Transactions
        • All Transactions of an address
        • Subscribing to all transactions of a Liquidity Pool
        • Subscribing to all transactions of multiple addresses
        • Subscribing to all transactions of a Token
      • Subscribing to Accounts
        • Account Updates for a Program
        • Account Updates for an Address
        • Account updates using memcmp
      • Streaming Blocks & BlocksMeta
        • Streaming Block Updates
        • Subscribing to BlocksMeta
      • Modifying & Unsubscribing
  • Solana defi data
    • DeFI APIs
      • Get Pool By Address
      • Get Pools By Token Pair
      • Get All Pools for a Token
      • Get Liquidity Details of a Pool
  • Callbacks
    • ☎️What are Callbacks?
      • Transaction Callbacks
      • Account Callbacks
    • πŸ“”Callback APIs
      • Response Structure
      • List Callbacks
      • Register callback
      • Remove callback
      • πŸ”₯Pause a callback
      • πŸ”₯Resume a callback
      • Update Callbacks
      • Add Addresses
      • Remove addresses
  • Solana Super Indexers
    • 🌩️GraphQL APIs
      • Getting Started
      • Building Queries
      • Paginating Response
      • Applying Filters
      • Ordering and Sorting Data
    • πŸ“€Case Studies
      • Tensor
        • Get Active Listings of a Wallet
        • Get Active Bids of a Wallet
        • Get Active Listings of a Collection
        • Get all Bids of a Collection
        • Get all Pools of a Margin Account
        • Get all Pools by Owner
      • Raydium
        • Get Pool By Address
        • Get Pools By Token Address
        • Get Pools Created Between Time
        • Get Pool Burn Percentage
        • Get Liquidity Details of a Pool
        • Get Pool and OpenBook Market Info
        • Get Token Supply Percentage In Pool
      • Orca Whirlpool
        • Get Pool by Address
        • Get Pool by Token Address
        • Get Positions for a Pool
        • Get Positions for a Wallet
        • Get Liquidity Details of a Pool
      • Kamino
        • Get Borrow Details of a Wallet
        • Get Deposit Details of a Wallet
        • Get Reserve Details
      • Cross Marketplace Queries
        • Get active listings across marketplaces for a wallet
        • Get listings for a collection across marketplaces
        • Get floor price of a collection
      • Cross Defi Queries
        • Fetch Liquidity Pools for Token
      • Native Staking
        • Get Stakes for a Wallet
        • Get Stakes For Validator
      • Governance/Realms
        • Get DAO Token Owners
        • Get Proposals For Governing Mint
        • Get All Proposals For DAO
        • Get DAO Treasury Info
        • Get All Active Proposals For Wallet
      • Meteora
        • Get All LB Position Pairs
        • Get Position of a User Wallet
        • Get Pool by Token Addresses
        • Get All Deposits for a User
        • Get All Withdraws for a User
        • Get All Fees Claimed by a User
        • Get All User Positions and Deposits for a Pool
        • Get All User Positions and Withdrawals for a Pool
      • Fluxbeam
        • Get Pool by Address
        • Get Pool by Token Addresses
      • Drift
        • Get User account for Delegate
        • Get User accounts based on authority
        • Get User details based on Referrer
        • Get Borrow/Deposit Amount for an User
        • Get PrepPositions for an User Account
        • Getting OrderId and userOrderId
        • Get OpenOrders for a User Account
      • πŸ”₯Pumpswap
        • πŸ”₯Get Pool by Address
        • πŸ”₯Get Pool by Creator Address
        • πŸ”₯Get Pools by Token Addresses
      • Raydium Launchpad
        • Get Bonding Curve Details by Pool Address
        • Get All Pools for a Creator
        • Get Pools by Token Addresses
        • Get Migration details of a Pool
  • Solana APIs
    • API Reference
    • Transactions
      • Parsed Transaction Structure
      • Transaction APIs
        • History
        • Parse Signature
        • Parse Multiple Signatures
        • Send
        • Send Multiple
    • NFT
      • πŸ”₯Create Gasless
      • Create
      • Read All
      • Burn
      • πŸ”₯Burn Multiple NFTs V2
      • Update
      • πŸ”₯Create NFT from Metadata
      • πŸ”₯Read Wallet Nfts
      • πŸ”₯Read Selected NFTs
      • πŸ”₯Get NFT Owners
      • πŸ”₯Update NFT Metadata Uri
      • πŸ”₯Update V2
      • Search
      • Transfer
      • Transfer Multiple NFTs
      • Mint
      • Read
    • Wallet
      • Get Balance
      • Get Token Balance
      • Get All Tokens Balance
      • Get Portfolio
      • Resolve Address
      • Get All Domains
      • Get Stake Accounts
    • Fungible Tokens
      • Create
      • Mint
      • Burn
      • πŸ”₯Update
      • Get Token Info
      • Transfer
      • Airdrop
  • πŸ“˜Dev Guides
    • πŸ“€gRPC Case Studies
      • Pumpfun
        • Streaming and Parsing Pump.fun Transactions
        • Streaming and Parsing Pump.fun Accounts
        • Detecting new Token launches on Pump.fun
        • Detecting Buy/Sell Transactions on Pump.fun
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
      • PumpSwap AMM
        • Streaming and Parsing Pump Swap Transactions
        • Streaming and Parsing Pump Swap AMM Accounts
        • Detecting Buy/Sell Transactions on Pump Swap AMM
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
Powered by GitBook
On this page
  • Step-by-Step Breakdown
  • Streaming Accounts Using gRPC
  • Decoding the received accounts
  • Important Links

Was this helpful?

  1. Dev Guides
  2. gRPC Case Studies
  3. Pumpfun

Streaming and Parsing Pump.fun Accounts

Real-Time Streaming and Parsing of Pump.fun Transactions Using Solana Yellowstone gRPC and IDL-Based Parsers

PreviousStreaming and Parsing Pump.fun TransactionsNextDetecting new Token launches on Pump.fun

Last updated 20 hours ago

Was this helpful?

For any Solana dApp, trading bots, or real-time analytics platform, efficient account data access is important. Solana gRPC streaming, leveraging technologies like the Geyser plugin and Yellowstone, offers a high-performance, low-latency alternative to traditional RPC calls and WebSockets. In this document, we will explore how we can stream and parse account data using Solana Yellowstone gRPCs

The complete source code for this project is available on GitHub.

Please feel free to clone the repository and try it out. Additionally, you will find other relevant and useful code examples related to gRPC and streaming .

Step-by-Step Breakdown

This project consists of two key components:

  1. Streaming Pump.fun Accounts via Yellowstone gRPC

  2. Decoding those accounts using the program's IDL

Streaming Accounts Using gRPC

The first step involves initializing the Solana Yellowstone Client. You can get Solana Yellowstone gRPC access from the Shyft Dashboard. Please check out our for more details.

Initializing the Client

Once you have the authentication details, you can initialize the client in the following manner,

import Client from "@triton-one/yellowstone-grpc";

const client = new Client(
  "YOUR-GRPC-ENDPOINT", //yellowstone grpc url
  "GRPC-ACCESS-TOKEN", //authentication token
  undefined
);
use yellowstone_grpc_client::{GeyserGrpcClient, Interceptor}

async fn connect(&self) -> anyhow::Result<GeyserGrpcClient<impl Interceptor>> {
     GeyserGrpcClient::build_from_shared(self.endpoint.clone())? //grpc url
            .x_token(Some(self.x_token.clone()))? //grpc auth token
            .connect_timeout(Duration::from_secs(10))
            .timeout(Duration::from_secs(10))
            .tls_config(ClientTlsConfig::new().with_native_roots())?
            .max_decoding_message_size(1024 * 1024 * 1024)
            .connect()
            .await
            .map_err(Into::into)
}

You can use any Yellowstone gRPC endpoint with this client. An access token is optional, as some gRPC services don't require authentication.

The Rust client supports several additional options, as demonstrated in the example above. Most of these options are also available for the TS client, where they are passed as the third argument to the Client constructor.

Specifying what data to stream from gRPC

To specify what on-chain data, we send a SubscribeRequest over the existing Solana Yellowstone gRPC client. These Request allows you to filter for specific accounts, transactions, slots, or other Solana on-chain events, giving you full control over the data you receive.

const req: SubscribeRequest = {
  "slots": {},
  "accounts": {
    "pumpfun": {
      "account": [],
      "filters": [],
      "owner": ["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"] // This field indicates 
    }
  },
  "transactions": {},
  "blocks": {},
  "blocksMeta": {},
  "accountsDataSlice": [],
  "commitment": CommitmentLevel.PROCESSED, // Subscribe to processed blocks for the fastest updates
  "entry": {},
  "transactionsStatus": {}
}
let mut accounts: AccountFilterMap = HashMap::new();

accounts.insert(
    "accountData".to_owned(),
    SubscribeRequestFilterAccounts {
        account: vec![],
        owner: vec!["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"],
        nonempty_txn_signature: None,
        filters: vec![]
    },
);
Ok(SubscribeRequest {
    accounts,
    slots: HashMap::default(),
    transactions: HashMap::default(),
    transactions_status: HashMap::default(),
    blocks: HashMap::default(),
    blocks_meta: HashMap::default(),
    entry: HashMap::default(),
    commitment: Some(CommitmentLevel::Processed as i32),
    accounts_data_slice: Vec::default(),
    ping: None,
    from_slot: None,
})

For example, to stream Pump.fun transaction accounts, you can set the owner field to the Pump.fun program ID. This ensures that only accounts associated with the Pump.fun program are streamed in real-timeβ€”ideal for use cases like meme coin trading bots, on-chain analytics, or DeFi dashboards requiring program-specific data.

Decoding the received accounts

As soon as the accounts are updated on chain, the updated account data is sent over the stream. The next step involves decoding the data. For JS/TS, we use BorshAccountCoder from @coral-xyz/anchor to parse the account data in the following manner.

import { BorshAccountsCoder } from "@coral-xyz/anchor";

const program_idl = JSON.parse(fs.readFileSync('./Idl/pump_0.1.0.json', 'utf8'));
const accountCoder = new BorshAccountsCoder(program_idl);

 const decodedData = accountCoder.decodeAny(data.account.account.data);
use pump_interface::accounts::{BondingCurve, BondingCurveAccount, Global, GlobalAccount, BONDING_CURVE_ACCOUNT_DISCM, GLOBAL_ACCOUNT_DISCM},

pub fn decode_account_data(buf: &[u8]) -> Result<DecodedAccount, AccountDecodeError> {
    if buf.len() < 8 {
        return Err(AccountDecodeError {
            message: "Buffer too short to contain a valid discriminator.".to_string(),
        });
    }

    let discriminator: [u8; 8] = buf[..8].try_into().expect("Failed to extract first 8 bytes");

    match discriminator {
        BONDING_CURVE_ACCOUNT_DISCM => {
            //println!("Bonding Curve Account detected. Proceeding with deserialization...");
            let data = BondingCurveAccount::deserialize(buf)
                .map_err(|e| AccountDecodeError {
                    message: format!("Failed to deserialize BondingCurveAccount: {}", e),
                })?;
            println!("\nDecoded Bonding Curve Structure: {:#?}", data);
            Ok(DecodedAccount::BondingCurve(data.0)) // Unwrapping the inner BondingCurve struct
        }
        GLOBAL_ACCOUNT_DISCM => {
            //println!("Global Account detected. Proceeding with deserialization...");
            let data = GlobalAccount::deserialize(buf)
                .map_err(|e| AccountDecodeError {
                    message: format!("Failed to deserialize GlobalAccount: {}", e),
                })?;
            println!("\nDecoded Global Structure: {:#?}", data);
            Ok(DecodedAccount::Global(data.0)) // Unwrapping the inner Global struct
        }
        _ => Err(AccountDecodeError {
            message: "Account discriminator not found.".to_string(),
        }),
    }
}

Important Links

use filters to determine what type of on-chain data to stream. When streaming account-level data, the account filter plays a crucial role. Specifically, the owner field within the filter allows you to stream data for accounts owned by a particular Solana program.

Once established, the stream will begin sending data directly to your application. You have the flexibility to on the fly, allowing you to change the data specifications you receive without stopping your stream. For more details on , or , you can find additional information in our .

On Rust however, we can use the Solores generated IDL like in our example.

– In-depth technical docs for implementing real-time streaming with Yellowstone gRPC and Geyser plugin on Solana.

– Guides, use cases, and performance benchmarks for building low-latency Solana applications using gRPC-based infrastructure.

– Ready-to-use code snippets and integrations for common DeFi protocols, transaction parsers, and real-time Solana data streaming use cases.

πŸ“˜
πŸ“€
modify your subscription
reconnecting and re-starting the stream from a specific slot
closing your gRPC connection
documentation
transaction parsing
Solana gRPC Documentation
Blogs on Solana gRPC Streaming
Solana DeFi Code Snippets & Examples
pump.fun
TypeScript
Rust
here
gRPC Authentication Docs
SubscribeRequests