headsetWSS 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

  1. RPC URL

  2. mint pubkey to filter trades on; leave as "" for no filter

    1. 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
}

Last updated