Building Pump.fun to PumpSwap and Raydium Migrations Listener with GetBlock
A step-by-step guide on how to build a real-time listener for Pump.fun token migrations to both PumpSwap and Raydium using GetBlock API
Pump.fun is a Solana-based memecoin launchpad that uses a bonding curve mechanism to initiate token distribution. When a token reaches an approximate market cap of $69,000, it graduates from the bonding curve. At this point, $12,000 of liquidity is deposited to either Raydium DEX or PumpSwap (Pump.fun's native DEX). This migration creates immediate trading opportunities for developers and traders who can detect these events in real-time.
How Pump.fun Migrations Work
Tokens on Pump.fun start trading on a bonding curve mechanism. When the bonding curve reaches completion (approximately $69,000 market cap), the protocol executes a migration.
Migration Flow:
Bonding Curve Phase: Token trades on Pump.fun using bonding curve pricing
Completion Trigger: Bonding curve reaches ~$69k market cap
Migration Transaction: Pump.fun migration account executes the migration
Liquidity Deployment: $12,000 of liquidity is deposited into either:
PumpSwap (Pump.fun's DEX) - Most common since March 2025
Raydium AMM - Less common, but still happens

Key Addresses
Pump.fun Program
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
Pump.fun Migration Account
39azUYFWPz3VHgKCf3VChUwbpURdCHRxjWVowf5jUJjg
Raydium Liquidity Pool V4
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
In this guide, you will learn how to:
Get a GetBlock Access Token for Solana's API endpoint
Build a WebSocket listener that detects Pump.fun migrations to both PumpSwap and Raydium
Process transaction logs to extract token and pool information
Distinguish between PumpSwap and Raydium migrations
Handle reconnections and error scenarios
Display migration data in a user-friendly format
Prerequisites
Basic understanding of JavaScript
A GetBlock account
Node.js installed (v18 or higher)
Technology Stack
Node.js: JavaScript runtime environment for building server applications
@solana/web3.js: Official Solana JavaScript SDK for blockchain interactions
ws: WebSocket client library for real-time connections
dotenv: Environment variable management for secure configuration
Step 1: Project Initialization
Set up your project directory using this command:
Install Dependencies:
Configure
package.json:
"type": "module"- Enables ES6 import/export syntax (required for modern JavaScript)"main": "server.js"- Specifies entry point of your application"scripts"- Defines shortcuts likenpm start
Get GetBlock's API Access Token
Log in to your GetBlock account
On your dashboard, scroll and click on Get Endpoint
Select the Solana Mainnet network
Under API Interface, select WebSocket (wss://)
Click on Create to get your endpoint
Your WebSocket endpoint will look like:
Also get the HTTP endpoint for transaction fetching:
Return to the dashboard
Select JSON-RPC (https://) under API Interface
Click Create
Your HTTP endpoint will look like:
Save both endpoints in a
.envfile in your project root:
Keep your endpoints safe, as they contain your access token
Project Structure
Create the following files to have a basic structure for your project:
Create a
.gitignorefile:
Step 2: Server File Setup
Your script will be written inside server.js
1. Import Dependencies and Configuration
What this does:
Imports necessary libraries for Solana interactions and WebSocket connections
Loads API endpoints securely from environment variables
Validates that the required configuration is present
Defines the key addresses we'll monitor for migrations
MIGRATION_ACCOUNT- This is the Pump.fun account that executes all migrationsRAYDIUM_PROGRAM- The Raydium program ID to detect Raydium migrations.PUMPFUN_PROGRAM- The Pump.fun program ID to detect PumpSwap migrations.
2. Create the Migration Listener Class
Breaking down the constructor:
The constructor initializes all the state we need to track. Let me explain each property:
this.ws- Will hold our WebSocket connection to GetBlockthis.connection- HTTP connection for fetching full transaction detailsthis.subscriptionId- The ID returned when we subscribe to logsthis.isConnected- Boolean flag to track connection statusthis.reconnectAttempts- Counter for reconnection attempts (we limit it to 10)this.raydiumMigrationCount&this.pumpswapMigrationCount- Separate counters for each migration typethis.migrations- Array to store all detected migrationsthis.startTime- Timestamp when listener started (for runtime tracking)this.totalLogsReceived- Counter for all logs received (helps with debugging)
3. Create an Interval check
What this does:
The
start()method kicks everything off. It checks if the Websocket is connected or not.The
checkRunning()method creates a timer that runs every 60 seconds (60000 milliseconds). This serves two purposes:It shows the listener is still running
It provides statistics: runtime, total logs received, and migrations detected by type
Migration isn't frequent and may not occur within an hour. This is good for debuggingβif no logs appear, it's a sign there's an issue with the subscription. This ensures that monitoring is active.
4. Create GetBlock Websocket Connection
What this does:
The
connect()method creates a new WebSocket connection to GetBlock. Then it sets up four event listeners:open- Called when the connection is establishedmessage- Called whenever we receive dataerror- Called if something goes wrongclose- Called when the connection drops
When the connection opens,
handleOpen()runs. It setsisConnectedto true, resets the reconnection counter (since you've successfully connected), and most importantly, subscribes to the logs you need.
5. Subscribe to Migration Events
What this does:
Uses Solana's
logsSubscribemethod to monitor transactionsFilters for transactions mentioning the Pump.fun migration account
Uses
confirmedcommitment for faster notifications (1-2 seconds)
6. Handle Incoming Messages
What this does:
Parses incoming WebSocket messages
Handles subscription confirmation and stores subscription ID
Processes log notifications for migration detection
7. Process Transaction Logs
What this does:
Checks transaction logs for migration keywords like:

Skips failed transactions
Fetches full transaction details when migration is detected
8. Fetch Full Transaction Details
What this does:
Waits 1 second for the transaction to propagate
Fetches complete transaction from Solana via HTTP
Extracts and displays migration data
9. Extract Migration Data
What this does:
Handles both versioned and legacy Solana transactions
Detects Raydium migrations by checking for Raydium program ID
Detects PumpSwap migrations by checking for Pump.fun program ID
Extracts relevant addresses (token, pool, LP mint)
10. Display Migration Results
What this does:
Displays Raydium migrations with pool and LP mint info
Displays PumpSwap migrations with bonding curve info
Provides links to Solscan and trading platforms
11. Handle Reconnections
What this does:
Implements exponential backoff for reconnections (2s, 4s, 8s, etc.)
Caps reconnection delay at 30 seconds
Exits after 10 failed reconnection attempts
12. Initialize and Run
What this does:
Handles graceful shutdown on Ctrl+C
Catches uncaught errors
Step 4: Testing Your Listener
Start your migration listener:
Expected Output:
Test 1: Real-time PumpSwap Migration
When a token migrates to PumpSwap:
Test 2: Real-time Raydium Migration
When a token migrates to Raydium (rare):
Test 3: Check if alive
Every minute:
Troubleshooting
1. Missing access token or Connection error
This means that:
You haven't set up your environment variable as follows in this guide
Your Access token is incorrect or incomplete
2. Only seeing PumpSwap migrations or no migration at all
This is expected. Since March 2025, most tokens (95%+) have migrated to PumpSwap instead of Raydium. Also, migration doesn't happen frequently.
Not receiving any logs
Solution:
Verify subscription succeeded (you should see
β Subscribed with ID)Check GetBlock dashboard for API usage limits
Verify transactions exist at Solscan
Conclusion
In this guide, you've built an app that listens to Pump.fun token migrations to both PumpSwap and Raydium using GetBlock's Solana infrastructure. You learn:
How to connect to GetBlock's WebSocket API for real-time blockchain data
How to subscribe to specific account activities on Solana
How to distinguish between PumpSwap and Raydium migrations
How to extract token addresses and pool information from transactions
How to handle versioned Solana transactions
How to implement robust reconnection logic
Additional Resources
Last updated
Was this helpful?