2

I'm currently writing script to track wallet address by using connection.onLogs , and when i got the signature i called getParsedTransaction hoping to get the transaction details such as what wallet address initialize the transaction, what kind of transaction is it? swap, transfer or interact with a program? if swap what token was use to swap for what token? what's the amount? if it's transfer what token did the user transfer? what's the amount, what's the wallet address was used to send and receive and so on. when i console log the response from getParsedTransaction i keep getting different data field for each pair below, so i'm not sure how i can get these information if the data returned field changes everytime

// transaction signatures that i've been testing
  // failed sol/wif 3Zy8QA34fFEQ3dj8QySZz8ckBeDSRtVoFeVkvH8bx4J6aGXDQ6ks2iYd7hWSF4ENw3ak5ZhfMyppQiZjjpYFVdVy
  // success sol/wen H4GKYobNaSawaCkbu7Wcz7BL75FiZJXKS5vQvwuiNGbphAfBguYCVwxKjFb73e7MhB4qbf9fpL9M9WXUicnL9is
  // success wen/sol n7smLz4Z3uER45FbANJNWpqnukedVY3kqF1act3dAJ4ivSmQF5NQWosvegoKo2pGuRwYEdtWa43CamsnAPY1hTU
  // success usdc/sol imMSBZ1RASauuih51BN1hTnZx41f8QnEz7cAWa8K4CPaufCeLM2R5kKr5WJRJLo8JESoHELLjbPdjFjZuvQv1d6
// transfer cAkhXMsUcLTyUmNkFTNSRfCTVeToAqkooYo8QHmYcokAVj2XaDzHycB4Ytafx8acYusHp76YXJFm6ypN9GzCuVq
const transaction = await connection.getParsedTransaction(
    `H4GKYobNaSawaCkbu7Wcz7BL75FiZJXKS5vQvwuiNGbphAfBguYCVwxKjFb73e7MhB4qbf9fpL9M9WXUicnL9is `,
    { maxSupportedTransactionVersion: 0 },
  );

1 Answer 1

2

Manually doing it would be a difficult task as each different DeFi interaction and different program interaction would result in different instruction data for each transaction. You should instead try using Helius' parsed transaction API endpoint: https://docs.helius.dev/solana-apis/enhanced-transactions-api/parse-transaction-s

It is not perfect, but parses some common actions like Jupiter swaps, NFT actions, and anything related to SPL tokens.

2
  • yeah, using that right now. thank you!
    – irregular
    Commented Mar 10 at 16:16
  • Are you using helius?
    – papi
    Commented 23 hours ago

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.