0

I'd like to know how i can get information on transfers on solana tokens in a format similar to that of solscan, i.e: signature, time, action , from, to, value of transaction

For a specific mint i get the signatures using the getSignaturesForAddress RPC Method however when parsing the transactions with the getTransaction RPC Method I am unsure how to extract the required information from the Json output. I tried subtracting pre token balances from post token balances however it doesn't seem to work.

Also how would it be possible to calculate the value/price of the swap? Given that raydium accepts other tokens as means of trade is it possible to put a price on these trades?

I'm sure it is a simple answer but help is appreciated Thanks

1 Answer 1

1

You might want to check out Helius' parsed transaction API.

const response = await fetch('https://api.helius.xyz/v0/transactions', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();

It's far richer than the default getTransaction method, if you don't want the hustle of going through the hassle of interpreting the instruction, post and pre balances.

[
  {
    "description": "Human readable interpretation of the transaction",
    "type": "UNKNOWN",
    "source": "FORM_FUNCTION",
    "fee": 5000,
    "feePayer": "8cRrU1NzNpjL3k2BwjW3VixAcX6VFc29KHr4KZg8cs2Y",
    "signature": "yy5BT9benHhx8fGCvhcAfTtLEHAtRJ3hRTzVL16bdrTCWm63t2vapfrZQZLJC3RcuagekaXjSs2zUGQvbcto8DK",
    "slot": 148277128,
    "timestamp": 1656442333,
    "nativeTransfers": [
      {
        "fromUserAccount": "text",
        "toUserAccount": "text"
      }
    ],
    "tokenTransfers": [
      {
        "fromUserAccount": "text",
        "toUserAccount": "text",
        "fromTokenAccount": "text",
        "toTokenAccount": "text",
        "tokenAmount": 0,
        "mint": "DsfCsbbPH77p6yeLS1i4ag9UA5gP9xWSvdCx72FJjLsx"
      }
    ],
    "accountData": [
      {
        "account": "text",
        "nativeBalanceChange": 0,
        "tokenBalanceChanges": [
          {
            "userAccount": "F54ZGuxyb2gA7vRjzWKLWEMQqCfJxDY1whtqtjdq4CJ",
            "tokenAccount": "2kvmbRybhrcptDnwyNv6oiFGFEnRVv7MvVyqsxkirgdn",
            "mint": "DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ",
            "rawTokenAmount": {
              "tokenAmount": "text"
            }
          }
        ]
      }
    ],
    "transactionError": {
      "error": "text"
    },
    "instructions": [
      {
        "accounts": [
          "8uX6yiUuH4UjUb1gMGJAdkXorSuKshqsFGDCFShcK88B"
        ],
        "data": "kdL8HQJrbbvQRGXmoadaja1Qvs",
        "programId": "MEisE1HzehtrDpAAT8PnLHjpSSkRYakotTuJRPjTpo8",
        "innerInstructions": [
          {
            "accounts": [
              "text"
            ],
            "data": "text",
            "programId": "text"
          }
        ]
      }
    ],
    "events": {
      "nft": {
        "description": "text",
        "type": "NFT_SALE",
        "source": "FORM_FUNCTION",
        "amount": 1000000,
        "fee": 5000,
        "feePayer": "8cRrU1NzNpjL3k2BwjW3VixAcX6VFc29KHr4KZg8cs2Y",
        "signature": "4jzQxVTaJ4Fe4Fct9y1aaT9hmVyEjpCqE2bL8JMnuLZbzHZwaL4kZZvNEZ6bEj6fGmiAdCPjmNQHCf8v994PAgDf",
        "slot": 148277128,
        "timestamp": 1656442333,
        "saleType": "AUCTION",
        "buyer": "text",
        "seller": "text",
        "staker": "text",
        "nfts": [
          {
            "mint": "DsfCsbbPH77p6yeLS1i4ag9UA5gP9xWSvdCx72FJjLsx",
            "tokenStandard": "NonFungible"
          }
        ]
      },
      "swap": {
        "nativeInput": {
          "account": "2uySTNgvGT2kwqpfgLiSgeBLR3wQyye1i1A2iQWoPiFr",
          "amount": "100000000"
        },
        "nativeOutput": {
          "account": "2uySTNgvGT2kwqpfgLiSgeBLR3wQyye1i1A2iQWoPiFr",
          "amount": "100000000"
        },
        "tokenInputs": [
          {
            "userAccount": "F54ZGuxyb2gA7vRjzWKLWEMQqCfJxDY1whtqtjdq4CJ",
            "tokenAccount": "2kvmbRybhrcptDnwyNv6oiFGFEnRVv7MvVyqsxkirgdn",
            "mint": "DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ",
            "rawTokenAmount": {
              "tokenAmount": "text"
            }
          }
        ],
        "tokenOutputs": [
          {
            "userAccount": "F54ZGuxyb2gA7vRjzWKLWEMQqCfJxDY1whtqtjdq4CJ",
            "tokenAccount": "2kvmbRybhrcptDnwyNv6oiFGFEnRVv7MvVyqsxkirgdn",
            "mint": "DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ",
            "rawTokenAmount": {
              "tokenAmount": "text"
            }
          }
        ],
        "tokenFees": [
          {
            "userAccount": "F54ZGuxyb2gA7vRjzWKLWEMQqCfJxDY1whtqtjdq4CJ",
            "tokenAccount": "2kvmbRybhrcptDnwyNv6oiFGFEnRVv7MvVyqsxkirgdn",
            "mint": "DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ",
            "rawTokenAmount": {
              "tokenAmount": "text"
            }
          }
        ],
        "nativeFees": [
          {
            "account": "2uySTNgvGT2kwqpfgLiSgeBLR3wQyye1i1A2iQWoPiFr",
            "amount": "100000000"
          }
        ],
        "innerSwaps": [
          {
            "tokenInputs": [
              {
                "fromUserAccount": "text",
                "toUserAccount": "text",
                "fromTokenAccount": "text",
                "toTokenAccount": "text",
                "tokenAmount": 0,
                "mint": "DsfCsbbPH77p6yeLS1i4ag9UA5gP9xWSvdCx72FJjLsx"
              }
            ],
            "tokenOutputs": [
              {
                "fromUserAccount": "text",
                "toUserAccount": "text",
                "fromTokenAccount": "text",
                "toTokenAccount": "text",
                "tokenAmount": 0,
                "mint": "DsfCsbbPH77p6yeLS1i4ag9UA5gP9xWSvdCx72FJjLsx"
              }
            ],
            "tokenFees": [
              {
                "fromUserAccount": "text",
                "toUserAccount": "text",
                "fromTokenAccount": "text",
                "toTokenAccount": "text",
                "tokenAmount": 0,
                "mint": "DsfCsbbPH77p6yeLS1i4ag9UA5gP9xWSvdCx72FJjLsx"
              }
            ],
            "nativeFees": [
              {
                "fromUserAccount": "text",
                "toUserAccount": "text"
              }
            ],
            "programInfo": {
              "source": "ORCA",
              "account": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc",
              "programName": "ORCA_WHIRLPOOLS",
              "instructionName": "whirlpoolSwap"
            }
          }
        ]
      }
    }
  }
]

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.