0

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: [
            "BgAAAAAAAAD+AAAAAAAAAAcAAAAAAAAAwAAAAAAAAAIAAAAAAAAAAkAAAAAAAAAAQAAAAAAAAAAAAAAAAAAKCGAQAAAAAA9AEAAAAAAABAS0wAAAAAABAnAAAAAAAAoIYBAAAAAAABAAAAAAAAAADKmjsAAAAAAMqaOwAAAAAFAAAAAAAAABAnAAAAAAAGQAAAAAAAAAQJ wAAAAAAAAAwAAAAAAAAAZAAAAAAAZAAAAAAAAABAnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABk45dlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFiHtgyBPocCAAAAAAAAAABndpeydAAAAAAAAAAAA2UPJTwAAAADftnmqfAAAAAAAAAAAAAAAG5Ct/zQFMQMAAAAAAAAAAONCjXs8ngEAfb6UWLDXGRn9fLOO yaE1RL3P1f88SOi/0uzC3iWV5tUZ3gMmtETy3rLZtotJl8BUuU0LBVbU5dxLKdBjnOnB2JQFPty3wQ1hV0tpnjbr2VNroHEaXbCwC+f+Qx3KL0FcBpuIV/6rgYT7aH9jRhjANdrEOdwa6ztV mKDwAAAAAAGSCBfgAivwg9yl06mIFns7yaitmbCIl+ByYjLvR4JlqdOqPI4Bcf7VzvUpDEXtH2k+pH/kA8hWf0xZM2kgCw9yuARDwGJH/VfGJAOiPXWt0albGhOM+uKqaSuchF7q0jINB1GoKC2mEwX+KZw 3uZjlhHHbETUDcxD4vhBFpgr27sQODi4QaL1jU/ZzCbeybkDLZ5K/3dB2lx1HU8INflY7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOW2K2XLO72m9WiI5m/ujmTcVWAZnA +IsR/ic70Fnoqhx208k3gdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
            "base64",
          ],
          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
  • 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

0

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.

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