0

I intend to get the newest SPL transfers that happen in an account and have tried the WSS methods like programSubscribe and accountSubscribe on the Raydium Authority V4 program account.

socket.addEventListener("open", () => {
  const subscribeMessage = {
    jsonrpc: "2.0",
    id: 1,
    method: "accountSubscribe",
    params: [
      "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
      {
        encoding: "jsonParsed",
      },
    ],
  };

  console.log("WSS stream started");
  const messageString = JSON.stringify(subscribeMessage);
  socket.send(messageString);
});

socket.addEventListener("message", async (event) => {
  const receivedMessage = JSON.parse(event.data.toString());
  const { params } = receivedMessage;

  console.log(params);
});

I am not sure on which method to use to get something similar to the SPL tranfers tab on solscan as seen here. Any way to get the latest SPL transfers for an account or program?

1 Answer 1

1

If you use accountSubscribe you will only get state change updates, therefore you will be able to detect when the token account balances change but you will not receive any transaction information.

If you want something similar to what you see on the explorer, you will have to do a combination of getSignaturesForAddress and getTransaction.

Helius has a websocket transaction streaming endpoint that seems to be what you are looking for https://docs.helius.dev/webhooks-and-websockets/websockets#transaction-subscribe but it's not a standard Solana RPC method.

2
  • The thing with using getSignaturesForAddress and getTransaction is that these RPCs methods can't handle the sheer amount of signatures that being made to Raydium Authority V4. Any idea on that?
    – Zero
    Commented Feb 4 at 14:47
  • If the RPC and websocket endpoints aren't enough, you might need to subscribe to a service with higher limits or run your own node.
    – Jon C
    Commented Feb 6 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.