I currently have a demand for a project that needs to listen to SWAP transactions between tokens, preferably via websocket.

Currently I only found the programSubscribe method on the nodes, but it gives me transaction information in a coded form, like the one below:

  jsonrpc: "2.0",
  method: "programNotification",
  params: {
    result: {
      context: { slot: 240418289 },
      value: {
        pubkey: "8ZxRqWLQ7rdp9Y354krM3PHx1MbdC7JKN7u3ew77zX8R ",
        account: {
          lamports: 6124800,
          data: [
          owner: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
          executable: false,
          rentEpoch: 0,
          space: 752,
    subscription: 194814,

Does anyone have any idea what I can do? If there is any other way, or how could I decode these transactions above?

  • 1
    You'll need some sort of decoder for the accounts of this program. Check on GitHub to see if there's an official package provided by the project. This program, the Raydium AMM, does not have an Anchor IDL published on-chain, so you'll have to use a Raydium package to decode their accounts and structs. github.com/raydium-io/raydium-contract-instructions may be a good place to start
    – Jon C
    Commented Jan 11 at 11:46

1 Answer 1


I will go with logs subscribe with the raydium key that you have there. Find in logs init_pc_amount or initialize2 and then decode that info so you can have the poolkeys need it for swap.

  • Although the answer does answer the question. It can be improved by providing code/JSON example and providing snippet to decode the data which websocket returns. Commented Feb 16 at 18:23

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.