Solana: Listening to pump.fun token mint using only logsSubscribe
This guide shows you how to listen for pump.fun token creation events in real time using only the logsSubscribe method.
In the pump-fun-bot repository, there is the learning-examples/listen_new_direct_full_details.py
script demonstrates how to capture the new token’s name, symbol, mint address, user (creator), bonding curve address, and associated bonding curve address—no methods like blockSubscribe extra RPC calls like getTransaction are required.
There's difference in speed in how blockSubscribe
and logsSubscribe
work. Also, blockSubscribe
is available on all Chainstack plans, but with other providers, it may not be available on the free tier plans or even lower tier paid plans.
There is also difference in how blockSubscribe
and logsSubscribe
work, hence this article and example.
blockSubscribe
— extracts and decodes transactions as the are streamed in the blocks produced. And the script in the bot decodes them on the fly. This means that we get all the necessary data to do our sniping using theblockSubscribe
method.logsSubscribe
— only prints the pump.fun program logs, in our case—for token mints. The problem is we can get and decode from the logs the new token’s name, symbol, mint address, user (creator), and bonding curve address. But the logs do not contain the associated bonding curve address, which we need to do a sniping/buying transaction.
The script discussed in this article and that is the learning-examples/listen_new_direct_full_details.py
script solves the issue by computing the associated bonding curve address from the bonding curve address on the fly and prints it. This way it makes it possible to snipe tokens on pump.fun using the logsSubscribe
method only. which in general has better availability across providers and may work faster for you.
How it works
- The script subscribes to Solana logs mentioning the pump.fun program (
PUMP_PROGRAM
). - Whenever the program logs an
Instruction: Create
event, the script looks at theProgram data:
line in the logs. - It decodes the data on-the-fly and extracts:
- The token name
- The token symbol
- The token URI
- The token mint address
- The bonding curve address
- The user (creator) address
- It then computes the associated bonding curve address (similar to how an associated token account is derived) via
Pubkey.find_program_address()
.
By using logsSubscribe
, you can get new token details almost immediately, which is especially handy if you want to “snipe” tokens the moment they are created.
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
Prerequisites
- A Solana WebSocket endpoint (e.g., from Chainstack).
- Python 3.8+ with the required dependencies installed:
pip install -r requirements.txt
- A properly configured
config.py
file that includes your WebSocket endpoint (WSS_ENDPOINT
).
Usage
-
Run:
python listen_new_direct_full_details.py
-
Watch the console for output like this:
Listening for new token creations from program: 6EF8rrecthR5... Subscription response: {"jsonrpc":"2.0","result":{"subscription":...}} Signature: 5TYqzsc... name: MyToken symbol: MYTK uri: https://arweave.net/... mint: 8cYMHFE... bondingCurve: 6GUb... user: Hwz3... Associated Bonding Curve: 5YvN... ##########################################################################################
Script overview
-
Subscribe to logs
UseslogsSubscribe
to monitor logs referencing the pump.fun program ID. -
Look for “Program log: Instruction: Create”
When that shows in the logs, the script checks subsequent logs forProgram data:
lines. -
Decode and parse
The script decodes the base64-encodedProgram data:
and extracts:- name (token name)
- symbol (token symbol)
- uri (metadata URI)
- mint (the newly minted token address)
- bondingCurve (the bonding curve address)
- user (the token creator)
It then calculates the associated bonding curve address via:
derived_address, _ = Pubkey.find_program_address( [ bytes(bonding_curve), bytes(TOKEN_PROGRAM_ID), bytes(mint), ], ATA_PROGRAM_ID )
-
Print details
Outputs the transaction signature, plus the fields noted above, along with the computed associated bonding curve.
Because we rely on logs only, we do not need extra calls like getTransaction
. This approach is ideal if you want to immediately act on the new token creation events in your trading or monitoring workflows.
Compare performance
You can run:
python listen_create_from_blocksubscribe.py
alongside:
python listen_new_direct_full_details.py
to see which one delivers the event data faster in your environment.
Next steps
- Integrate this script’s output into your buy/sell logic to snipe tokens right as they are created.
- Optionally use a separate script or your own logic to monitor the token price (via the bonding curve) to decide when to buy or sell.
With logsSubscribe
alone, you can get the essential details for any new pump.fun token almost instantly.
See also:
Updated about 23 hours ago