0

Hello I would like to get all transaction for a given wallet address with additional details like the from wallet address, the to wallet address, destination, lamport, fee, txhash, ect.. I found a post earlier that is close to what I want just need additional details. The code below was from https://solana.stackexchange.com/a/277/1452

const solanaweb3 = require('@solana/web3.js');
const SrchAddress = "5HcS2Qej4uPKop4pNaDHnVywx42Y2qUhceUYmbFKPG8g";

const SrchAddress = "5HcS2Qej4uPKop4pNaDHnVywx42Y2qUhceUYmbFKPG8g";
const endpoint = "https://api.mainnet-beta.solana.com";

const SolanaConnection = new solanaweb3.Connection(endpoint);
const getParsedTransactions = async (address) => {
    let transactionListLength = 1
    const allTransactions = []
    const pubkey = new solanaweb3.PublicKey(address);
    let transactionList = await SolanaConnection.getSignaturesForAddress(pubkey);
    allTransactions.push(transactionList)
    while (transactionListLength >= 1) {
      const lastSignature = transactionList[transactionList.length - 1];
      const nextSignatures = await SolanaConnection.getSignaturesForAddress(pubkey, { before: lastSignature.signature });
      allTransactions.push(nextSignatures)
      transactionList = nextSignatures
      transactionListLength = nextSignatures.length;
      console.log('current:',transactionList.length);
      console.log('total:',allTransactions.length)
    }
  return allTransactions.flat()
};

getParsedTransactions(SrchAddress).then((res) => console.log(res))

2 Answers 2

2

This isn't a mean feat as it is very implicit what each transaction instruction does.

A transaction instruction is a program id, an array of account metas and data. There is no way to deduce anything very human readable from this without some post-processing to decode each instruction.

You can see in this file how sollet.io does it

https://github.com/project-serum/spl-token-wallet/blob/master/src/utils/transactions.ts

Each instruction needs to be decoded, a title added and each account meta is labelled.

Another option is to use the Anchor IDL to decode the instruction when the program is an anchor program, but i wouldn't consider this fully user readable.

0

Your approach is not optimal. Try getting all token Accounts owned by the wallet Address then filter all transaction from specific token accounts and decode buys and sells.

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.