WSS Listen to new Trades
Listens to all new token trades through a WebSocket connection on Pumpfun
import solcoin.listen_pf_trades as lt
if __name__ == "__main__":
try:
lt.start_websocket("wss://solana-api.instantnodes.io/API_KEY", "")
except Exception as e:
print(f"Unexpected error in main event loop: {e}")
start websocket takes 2 arguments
RPC URL
mint pubkey to filter trades on; leave as "" for no filter
listen_pf_trades.start_websocket("wss://solana-api.instantnodes.io/API_KEY", "9tGpPyY8Je18pgTidgJ1jpzA7ywuk1RpLpryJT9Gpump") # filters to only show trades on the token 9tGpPyY8Je18pgTidgJ1jpzA7ywuk1RpLpryJT9Gpump
Example Output
{
'mint': mint pubkey,
'sol_amount': Amount of sol transacted,
'token_amount': Amount of tokens transacted,
'is_buy': If the transaction is buying an user buying a token,
'user': user who conducted the transaction,
'timestamp': time of transaction,
'virtual_sol_reserves': bonding curve's current virtural sol reserves in lamports,
'virtual_token_reserves': bonding curve's virtural token reserves x 10^6,
'txn_sig': transaction signature
}
{
'mint': '7S3apHy76FiMMhNn2EGoLuPetQVzdwr6SMoT4CuJpump',
'sol_amount': 1.1316e-05,
'token_amount': 324.414107,
'is_buy': True,
'user': 'Dv4TeifHSUaKqz7iPjTHWR31ZwzEPvtn6ggdpSnw4Vih',
'timestamp': 1742773880,
'virtual_sol_reserves': 33508441536,
'virtual_token_reserves': 960653451037445,
'txn_sig': '5uritv3eHozY2SGThXLsiVoATddr9WwrqjqpKq6PQKiyshADfdsytFEKRvx7sDBnDYnPYjC1JwBcxQrHa7nvKdtk'
}
Last updated