Solana: Solana web3.js getParsedTransaction returning null

Here’s the question that you pursue with transaction on blockchain solana with the Web3.js:

Title: Solana Web3

Edit

In the qualities of the use of the distribution of the construction of the blockchain solana, the detailed transaction of the analysis has a resistant value for the Ponimania Program and the launch of the Polish logic. However, in this state, we dissatisfied with the problem, which will appear at the demand for access to the tanned transaction with the use of Web3.js on a defined cuts.

Problem: Parsisdracection Returing Null

Solana: Solana web3.js getParsedTransaction returning null

We have written the walls, which listens to the magazines solana by the concrete open key. The code is predetermined for the analysis of the transaction of the transaction of all times when the adjacent program is completed:

`Javascript

Const Solana = Require ("Solana-Web3");

const connection = new solana.connection ();

Connection.onlogs (PUBLICEY, (RESULT) => {

Const parsedtransaction = result.parsedtransaction;

Console.log (parsedtransaction);

});

After settling the script and connection to the Solana network, we drop the detail transaction in the massive “Parsidtransaction”. However, when we registrate the output of this code, we make sure that he is getting an empty object:

`JSON

{

"Oshybka": Null,

“Information”: null,

"Status": Null,

"Result": {

"Transaction": []

}

}

What has fallen wrong?

In Solana, when you are re -transaction with the use of connection.gentry, the result is the objectweb3transaction. However, in this case, we do not call this transaction. Aside we are overgrown with Massiv “parsedtransactions”, submitted by web3.js.

The problem appears from that that the method Getentry 'does not guarantee that all the records of transaction will be recovered by the use of result.parsedtrans. Facial, if the agreed program is completed and will not be appropriate transaction, result.Parsedtransactions Verut the empty massive (]). The code we have written, prefare that this massive is always empty.

resolution of the problem

To solve this problem, you can use the second under the detailed transaction analysis. Odin from the sake of it – bend all the transaction, and the filtering of tech, which is not appropriate to your condition:

`Javascript

Const Solana = Require ("Solana-Web3");

const connection = new solana.connection ();

Connection.onlogs (PUBLICEY, (Result) => {

Const parsedtransactions = result.parsedtransaction;

IF (! Parsedtransactions.length) Vurat; // Ignorate empty massives

Const MoskingTransactions = parsedtransaction.filter ((transaction) => {

// Realize the state of your program here

IF (/ Your Guard /) {

Returned Isstin;

}

Return the bed;

});

Console.log (MatchingTransaction);

});

In the qualities of alternatives, you can use the method of Getentries for all transaction records, and the presence of the establishment of identifies records with the intensity of the transaction of web3:

Javascript

Const Solana = Require ("Solana-Web3");

const connection = new solana.connection ();

Connection.onlogs (PUBLICEY, (RESULT) => {

Const Transactions = result.parsedtransctions;

Const inpurytotransactionmap = {};

for (Const Transaction transaction) {

Const intrintid = transaction.entryid.tostring ();

if (! entratotransactionmap [entryid]) {

InpitTotransactionmap [Intrintid] = {};

}

InpitTotransactionmap [intrintid] [transaction.id.tostring ()] = transaction;

}

console.log (intrytotransactmap);

});

Using one of these lodges, you should be in the state of the transaction, even if the program is not dusted.

Bài viết liên quan

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *