[英]How to send a transaction to an onchain program in solana with javascript?
我尝试向 SOLANA 中的链上程序发送带有指令的交易。 我收到此错误:错误:发送交易失败:交易模拟失败:错误处理指令 0:指令从它不拥有的帐户余额中花费
我的 Javascript 代码是:
var solana_web3 = require('@solana/web3.js');
const { SSL_OP_EPHEMERAL_RSA } = require('constants');
const url = 'https://devnet.solana.com' ;
const sigSecretKey1 = [39,90,157,237,...] ;
const sigSecretKey2 = [39,90,157,237,...] ;
const progID = 'FpbcvcsCB...' ;
connection = new solana_web3.Connection(url, 'singleGossip');
const account_signer_source = new solana_web3.Account( Buffer.from(sigSecretKey1) );
const account_signer_destination = new solana_web3.Account( Buffer.from(sigSecretKey2) );
const pub_programId = new solana_web3.PublicKey(progID) ;
const instruction = new solana_web3.TransactionInstruction({
keys: [
{pubkey : account_signer_source.publicKey, isSigner : true, isWritable: true},
{pubkey : account_signer_destination.publicKey, isSigner : false, isWritable: true},
],
programId : pub_programId,
data: Buffer.from([]),
});
const transaction = new solana_web3.Transaction().add(instruction);
//transaction.addSignature(account_signer_source.publicKey, Buffer.from(sigSecretKey1));
await solana_web3.sendAndConfirmTransaction(
connection,
transaction,
[account_signer_source],
{commitment: 'singleGossip', preflightCommitment: 'singleGossip',}
).then(()=>{console.log('done')}).catch((e)=>{console.log(e)});
请问你能帮帮我吗?
谢谢礼萨
您正在从该程序不拥有的帐户中取走灯。 您只能从程序拥有的帐户中扣除灯,即我的代币交换程序可以在它拥有的所有帐户上扣除灯,而不能从其他帐户中扣除灯。 如果你想在你的程序中移动灯,你需要调用 system_instruction::transfer
该错误消息基本上意味着该程序不是其余额被花费的帐户的所有者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.