admin管理员组文章数量:1431720
I try to send a transaction with an instruction to an onchain program in SOLANA. I get this error : Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: instruction spent from the balance of an account it does not own
My Javascript code is :
var solana_web3 = require('@solana/web3.js');
const { SSL_OP_EPHEMERAL_RSA } = require('constants');
const url = '' ;
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],
{mitment: 'singleGossip', preflightCommitment: 'singleGossip',}
).then(()=>{console.log('done')}).catch((e)=>{console.log(e)});
Could you help me please ?
Thx Reza
I try to send a transaction with an instruction to an onchain program in SOLANA. I get this error : Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: instruction spent from the balance of an account it does not own
My Javascript code is :
var solana_web3 = require('@solana/web3.js');
const { SSL_OP_EPHEMERAL_RSA } = require('constants');
const url = 'https://devnet.solana.' ;
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],
{mitment: 'singleGossip', preflightCommitment: 'singleGossip',}
).then(()=>{console.log('done')}).catch((e)=>{console.log(e)});
Could you help me please ?
Thx Reza
Share Improve this question asked Feb 26, 2021 at 15:34 Reza SReza S 311 silver badge2 bronze badges2 Answers
Reset to default 3you're taking away lamports from an account that the program doesn't own. You can only deduct lamports from accounts owned by the program, ie my token-swap program can deduct lamports on all accounts that it owns, and no others. If you want to move lamports within your program, you need to invoke system_instruction::transfer
The error message basically means the program is not the owner of the account whose balance being spent.
本文标签: blockchainHow to send a transaction to an onchain program in solana with javascriptStack Overflow
版权声明:本文标题:blockchain - How to send a transaction to an onchain program in solana with javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745562199a2663539.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论