跳转到主要内容
Track buy and sell events on Pump.fun in real-time using Yellowstone gRPC. This guide is essential for building trading bots, market analysis tools, and automated trading systems that need instant transaction detection.

Overview

Tracking buy and sell events on Pump.fun is crucial for trading bots and market analysis. This guide details how to utilize Solana’s Yellowstone gRPC stream to efficiently capture and parse real-time transaction data, enabling instant detection of token swaps.
What you’ll learn:
  • Stream Pump.fun transactions in real-time
  • Parse transactions with IDL-based parsing
  • Identify buy vs sell transactions
  • Extract trade amounts, prices, and participants

Architecture

This implementation consists of three key components:
  1. Stream Transactions - Subscribe to Pump.fun transactions via gRPC
  2. Parse Transactions - Decode instructions and events using IDL
  3. Identify Buy/Sell - Detect transaction type based on events

Installation

Install the required dependencies:

Complete Working Example

Here’s a production-ready Pump.fun trading bot that detects all buy/sell events:

Environment Setup

Create a .env file:

IDL File

Download the Pump.fun IDL and save it as idl/pump_0.1.0.json. The full IDL is long, so keep it in a separate file and load it from disk as shown in the example above.

Advanced Features

Price Tracking

Track price movements across trades:

Large Trade Alerts

Alert on significant trades:

Buy/Sell Pressure

Calculate market pressure:

Performance Optimization

Use CONFIRMED Commitment

Balance speed and finality with CommitmentLevel.CONFIRMED

Async Processing

Process transactions asynchronously to avoid blocking the stream

Efficient Parsing

Only parse transactions that match your criteria

Memory Management

Implement data cleanup and garbage collection for long-running bots

Resources

Account Streaming

Stream Pump.fun account updates

Best Practices

Optimize your implementation

Transaction Monitoring

General transaction monitoring guide