There is such a transaction in the Solana blockchain: 5Tkjtr2SnhaTbchug5TzeBZj6eehjdnDCLm9z6Hb3xFAcVtM6rAv2Ecxtvi6N8RbnfkRuRKR7aJv61RRNSPRxW77
There are instructions in it:
('Instruction Details' => 'View more details' => '#4 - Token Program: TransferChecked')
I can't figure out how to decode the value of the data field of this instruction to determine the transfer amount.
I am using NodeJs and the @solana/web3.js library to get transaction details.
Here is my code:
const BN = require("bn.js");
...
const transaction = await connection.getTransaction('5Tkjtr2SnhaTbchug5TzeBZj6eehjdnDCLm9z6Hb3xFAcVtM6rAv2Ecxtvi6N8RbnfkRuRKR7aJv61RRNSPRxW77', {
commitment: "confirmed",
maxSupportedTransactionVersion: 0,
encoding: "json"
});
const buffer = Buffer.from(message.instructions[3].data, "base64");
const instructionId = buffer.readUInt8(0);
const amount = new BN(buffer.slice(1, 9), "le").toString();
const decimals = buffer.readUInt8(9);
But it doesn't work:
- According to the documentation and examples I found,
instructionId
should be 12, but I get 130. - The value of the
amount
variable also doesn't look like what I need. I received value: 8508362885362758644 but it has to be 5 USDT.
The data field value itself seems to be very short to contain all the information needed for this instruction: gvQzKgr3xhN2h
Maybe I'm trying to decode the wrong field or I found incorrect information on how to do it. I would be very grateful for any hint, because I'm at a dead end.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744849303a4597031.html
评论列表(0条)