错误:无法发送交易:交易模拟失败:错误处理指令0:指令无效帐户数据
我试图将Sol从编程性创建的钱包转移到用户钱包(撤回操作)。我读了文件,说应该创建PDA帐户。我创建了一个具有我有限的知识的文件,但遇到了此错误 我用于PDA和提取的Rust Code是:
let accounts_iter = &mut accounts.iter();
let coinflip_account = next_account_info(accounts_iter)?;
let wallet_account = next_account_info(accounts_iter)?;
let pda_account = next_account_info(accounts_iter)?;
let system_program = next_account_info(accounts_iter)?;
let withdraw = spl_token::instruction::transfer(
system_program.key,
coinflip_account.key,
wallet_account.key,
&pda_account.key,
&[&pda],
lamports,
)?;
msg!("amount {:?} Fani", lamports);
invoke_signed(
&withdraw,
&[
system_program.clone(),
wallet_account.clone(),
coinflip_account.clone(),
pda_account.clone()
],
signers,
)?;
从打字稿中进行交易指令的密钥是:
keys: [
{ pubkey: coinflipPubKey, isSigner: false, isWritable: true },
{ pubkey: wallet.publicKey, isSigner: true, isWritable: true },
{ pubkey: pda, isSigner: false, isWritable: false },
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
],
Coinflippubkey在哪里发件人,钱包是用户钱包 /接收器。
i was trying to transfer sol from programmatically created wallet to user wallet(withdraw operation).i read documents saying that pda accounts should be create .i created one with my limited knowledge but encountered this error
my rust code for pda and withdraw is:
let accounts_iter = &mut accounts.iter();
let coinflip_account = next_account_info(accounts_iter)?;
let wallet_account = next_account_info(accounts_iter)?;
let pda_account = next_account_info(accounts_iter)?;
let system_program = next_account_info(accounts_iter)?;
let withdraw = spl_token::instruction::transfer(
system_program.key,
coinflip_account.key,
wallet_account.key,
&pda_account.key,
&[&pda],
lamports,
)?;
msg!("amount {:?} Fani", lamports);
invoke_signed(
&withdraw,
&[
system_program.clone(),
wallet_account.clone(),
coinflip_account.clone(),
pda_account.clone()
],
signers,
)?;
keys for transaction instruction from typescript is :
keys: [
{ pubkey: coinflipPubKey, isSigner: false, isWritable: true },
{ pubkey: wallet.publicKey, isSigner: true, isWritable: true },
{ pubkey: pda, isSigner: false, isWritable: false },
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
],
where coinflipPubKey is sender ,wallet is user wallet / receiver.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论