0

I have list of transactions in a file & I have grabbed all of them & I confirmed that they all were grabbed, what I am trying to do is get infos on all transactions 1 by 1

This code is returning me an error

D:\NFT\codes\node_modules@project-serum\anchor\node_modules@solana\web3.js\lib\index.cjs.js:6853 throw new SolanaJSONRPCError(res.error, 'failed to get transaction'); ^

SolanaJSONRPCError: failed to get transaction: Invalid param: WrongSize

import * as anchor from "@project-serum/anchor";
import base58 from "bs58";
import * as fs from "fs";
const endpoint = "https://api.mainnet-beta.solana.com";

const connect = new anchor.web3.Connection(endpoint);

const txids = fs.readFileSync("Dragon.csv", "utf-8").split("\n");
const URLs = txids.map((txid) => txid.split(",")[2]);
// console.log(URLs)
async function main() {
  for (let i = 0; i < URLs.length; i++) {
    const txn = URLs[i].split("tx/")[1];
    console.log(txn);
    const tx = await connect.getParsedTransaction(txn);
    console.log(tx);
  }
}
main();


1 Answer 1

1

I do not know what you file looks like but lets say you have a list of URLs.

This works for me to getting every tx on that list.

import * as anchor from "@project-serum/anchor";
import base58 from "bs58";
import * as fs from "fs";
const endpoint = "https://api.mainnet-beta.solana.com";

const connect = new anchor.web3.Connection(endpoint);


const URLs = [
    'https://solscan.io/tx/29UUC2jU95A2ykDJjPDsooYqZ8bdogbm4czJeAUzYrMsdXPW246cvtJTSyqsSPegFnbGEkyYqueWo9SZndCgc4LE',
    'https://solscan.io/tx/5a9drqixAFWse56k8HiXpS66SaMsP59FZjTJVoc5EAK1RPGzZqqeb4VKy6Mqc9HmN5xP5Xucb2evdiXhZPeDGjQs'
]

async function main(urls) {
  for(let url of urls){
    let signature = url.split('/tx/')[1]
    let tx = await connect.getTransaction(signature, 'confirmed');
    console.log(tx)
  }
}

main(URLs);

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.