How to subscribe (listen) to SPL token transactions with full data using @solana/web3.js
How to subscribe (listen) to SPL token transactions with full data using @solana/web3.js
Loading saved threads...
Mike Wazowski · External communityPost link
External question — Solana Stack Exchange
Author: Mike Wazowski
Original post: https://solana.stackexchange.com/questions/12416
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I've searched a lot and can't find a solution. I want to track SPL token swap transactions to calculate the token price and get information about wallets. I found several solutions, but still have problems:
I can subscribe to two token accounts that are connected to a raydium pair using onAccountChange, get the amount of each account (WSOL, SPL token) and calculate the price, but it doesn't give me information about wallets, fees...
I can subscribe to the onLogs method, listen to all the logs of the pair, check if the transfer exists in the logs, using the signature and the Connection.getParsedTransaction method I can get all the information I need and it works.
But the second method is using a fetch request to get the transaction data and this is not good because the request takes time and one spl token can do many such requests per second, more than 100, and of course if I listen to logs of 10-100 different spl tokens at the same time I get error 429 Too Many Requests.
A good solution is to use a WSS connection to get transaction data and it works well without fetching the data using the getParsedTransaction method. I checked the documentation and can't find a way to subscribe to transactions with data, maybe I'm missing something? Can anyone help me or maybe I have the wrong direction of research.
There must be a solution because services like dexscreener.com and dextools.io can track new pairs, their price and other information in real time.
Quote
Report
Akshat Meena · External communityPost link
External answer — Solana Stack Exchange
Author: Akshat Meena
Original post: https://solana.stackexchange.com/a/13137
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Use
Bitquery Solana DEXTrades API
to track SPL token swap transactions to calculate the token price and get information about wallets. Register as a developer to get free points on
Bitquery IDE
. And run this
saved query
.
Bitquery has many powerful APIs to get on chain data for different chains like ethereum, bsc, arbitrum, solana, matic, etc.
If you have any questions, reach out to support through
telegram channel
.
Full Disclosure: I work at Bitquery in Developer Relations Team.
Quote
Report
Post Reply
Checking account access…