admin管理员组文章数量:1410705
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.
本文标签:
版权声明:本文标题:node.js - Unable to decode the value of the data field of the instruction in the Solana blockchain transaction - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744849302a2628399.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论