4

I was trying to extract as much data as possible about confirmed transactions, using the method getTransactions(signatures[]).

First I'm fetching all signatures by using the method getSignaturesForAddress(). And then calling on them getTransactions() method.

Though, I do not see the required information. Like below:

  1. token address
  2. transaction amount (there is only pre/post balance)
  3. which of the accounts is sending/receiving

Is there any other method which would provide the required info? Or maybe there are some libraries for fetching transaction data.

Thanks!

2 Answers 2

1

Maybe you are looking something like this

import { Connection, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";

const conn = new Connection("https://api.devnet.solana.com/");

async function extractTransactionData(signatures: string[]) {
  
  const accounts: Map<string, number> = new Map();
  
  const transactions = await conn.getParsedTransactions(signatures);

  for (const transaction of transactions) {
    let { parsed } = transaction?.transaction.message.instructions[0];
    if(parsed.type === "transfer") {
      const { source, lamports, destination } = parsed.info;
      const sols = lamports * LAMPORTS_PER_SOL;
      console.log(`${source} sent ${sols} amount of SOL to ${destination}`);
    }
  }
}

await extractTransactionData([
"2o33gfsBkQN6QshgjECzBvHEjPx2ZPsb6YodJVX2BWiuYgJuXVjTC1bNoD7rbQUBTppVT3si9KaAXmuC4eyp8FnK",
"4kkKEdNN8UwfwcipTUGcrCmTGY13ak7QfcUrAEpzA8tjLDBSL4HQ4rgzubaUafXfEQkt67szywRb7ET4cKBeRnnz",
"5oaZrwwajXYMUn8EHbrnbedtDauwAhzWJUsMFpHXB8zeKSgu4zqBtfcBaQtPKbf2KMzwV74ZdramvwdHM4zhSTMJ"
]);
1

Bitquery provides Solana APIs for real-time data including transaction and instruction information.

This graphQL query gets all information about the latest confirmed transactions in realtime: https://ide.bitquery.io/Realtime-Solana-Transactions

Docs for more examples on Solana: https://docs.bitquery.io/docs/category/solana/

A free developer account should be enough for your tests.

Full disclosure, I work at Bitquery.

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.