ある Solana アドレスから別のアドレスにトークンを転送しようとしていますが、データを要求することはできましたが、金額は常に空白です。
多くの微調整と変更により、金額はゼロのままのようです。金額を含めないと行が表示されませんが、入れると金額が表示されません。
function writeBigU_Int64LE(buf, value, offset, min, max) {
let lo = Number(value & BigInt('0xffffffff'))
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
lo = lo >> 8
buf[offset++] = lo
let hi = Number((value >> BigInt(32)) & BigInt('0xffffffff'))
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
hi = hi >> 8
buf[offset++] = hi
return offset
}
let AMOUNT = BigInt(1000)
const b = buffer.Buffer.alloc(10)
b.writeUInt8(3, 0)
writeBigU_Int64LE(b, AMOUNT, 1, BigInt(0), BigInt('0xffffffffffffffff'))
const instruction = new solanaWeb3.TransactionInstruction({
keys: [
{ pubkey: token, isSigner: false, isWritable: true },
{ pubkey: provider.publicKey, isSigner: false, isWritable: true },
{ pubkey: provider.publicKey, isSigner: true, isWritable: true },
],
programId : program_id,
data: b
});
let transaction = new solanaWeb3.Transaction()
transaction.add(instruction);
let { blockhash } = await connection.getRecentBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = provider.publicKey;
let signed = await provider.signTransaction(transaction, connection);
console.log(signed);
let signature = await connection.sendRawTransaction(signed.serialize());
console.log(signature);
await connection.confirmTransaction(signature);