Failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete

Failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete

Manage alerts

Loading saved threads...

denimcodes · External communityPost link
External question — Solana Stack Exchange Author: denimcodes Original post: https://solana.stackexchange.com/questions/6522 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am trying to initialize an escrow account and I keep getting this error. Here's the instruction code use crate::state::*; use anchor_lang::prelude::*; use anchor_spl::{token::{Mint, TokenAccount, Token}, associated_token::AssociatedToken}; pub fn handler(ctx: Context<InitEscrow>) -> Result<()> { let escrow_account = &mut ctx.accounts.escrow_account; escrow_account.bump = *ctx.bumps.get("escrow_account").unwrap(); escrow_account.borrower = ctx.accounts.borrower.key(); escrow_account.loan = ctx.accounts.loan_account.key(); escrow_account.nft_mint = ctx.accounts.nft_mint.key(); escrow_account.escrow_nft_vault = ctx.accounts.escrow_nft_vault.key(); escrow_account.token_mint = ctx.accounts.token_mint.key(); escrow_account.escrow_token_vault = ctx.accounts.escrow_token_vault.key(); Ok(()) } #[derive(Accounts)] pub struct InitEscrow<'info> { #[account(mut)] pub borrower: Signer<'info>, #[account( init, payer = borrower, space = Escrow::LEN, seeds = [b"escrow", borrower.key().as_ref(), loan_account.key().as_ref()], bump )] pub escrow_account: Account<'info, Escrow>, #[account( seeds = [b"loan", borrower.key().as_ref()], bump = loan_account.bump )] pub loan_account: Account<'info, Loan>, pub token_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = token_mint, associated_token::authority = escrow_account )] pub escrow_token_vault: Account<'info, TokenAccount>, pub nft_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = nft_mint, associated_token::authority = escrow_account )] pub escrow_nft_vault: Account<'info, TokenAccount>, pub token_program: Program<'info, Token>, pub associated_token_program: Program<'info, AssociatedToken>, pub system_program: Program<'info, System>, } Here's the test code: await program.methods .initEscrow() .accounts({ borrower: borrowerPk, tokenMint: tokenMintPk, nftMint: nftMintPk, escrowAccount: escrowAccountPk, escrowNftVault: escrowNftVaultPk, escrowTokenVault: escrowTokenVaultPk, }) .signers([borrower]) .rpc({ skipPreflight: true, }); });
Quote
Report
denimcodes · External communityPost link
External answer — Solana Stack Exchange Author: denimcodes Original post: https://solana.stackexchange.com/a/6527 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I used a try catch block on typescript code and found the specific error. It was ProgramStackError. Fixed it by boxing the Escrow account. Here's the updated context code: #[derive(Accounts)] pub struct InitEscrow<'info> { #[account(mut)] pub borrower: Signer<'info>, #[account( init, payer = borrower, space = Escrow::LEN, seeds = [b"escrow", borrower.key().as_ref(), loan_account.key().as_ref()], bump )] pub escrow_account: Box<Account<'info, Escrow>>, #[account( seeds = [b"loan", borrower.key().as_ref()], bump = loan_account.bump )] pub loan_account: Account<'info, Loan>, pub token_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = token_mint, associated_token::authority = escrow_account )] pub escrow_token_vault: Account<'info, TokenAccount>, pub nft_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = nft_mint, associated_token::authority = escrow_account )] pub escrow_nft_vault: Account<'info, TokenAccount>, pub token_program: Program<'info, Token>, pub associated_token_program: Program<'info, AssociatedToken>, pub system_program: Program<'info, System>, }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Solana Stack Exchange Author: denimcodes Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/a/6527 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I used a try catch block on typescript code and found the specific error. It was ProgramStackError. Fixed it by boxing the Escrow account. Here's the updated context code: #[derive(Accounts)] pub struct InitEscrow<'info> { #[account(mut)] pub borrower: Signer<'info>, #[account( init, payer = borrower, space = Escrow::LEN, seeds = [b"escrow", borrower.key().as_ref(), loan_account.key().as_ref()], bump )] pub escrow_account: Box<Account<'info, Escrow>>, #[account( seeds = [b"loan", borrower.key().as_ref()], bump = loan_account.bump )] pub loan_account: Account<'info, Loan>, pub token_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = token_mint, associated_token::authority = escrow_account )] pub escrow_token_vault: Account<'info, TokenAccount>, pub nft_mint: Account<'info, Mint>, #[account( init, payer = borrower, associated_token::mint = nft_mint, associated_token::authority = escrow_account )] pub escrow_nft_vault: Account<'info, TokenAccount>, pub token_program: Program<'info, Token>, pub associated_token_program: Program<'info, AssociatedToken>, pub system_program: Program<'info, System>, }

Cancel quote

Checking account access…