3

So I'm trying to define a function that carries out transfers of two different SPL tokens for a user. To do so, I need to pass the user's associated token accounts of both tokens into a function - however, in doing so, I face the following error:

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

The function currently has no other logic, I've isolated the bug to simply passing these two ATAs in conjunction. Passing either one of them individually does not lead to this error. Any ideas on what may be going wrong?

1
  • 1
    could you share the code that you've tried?
    – john
    Commented Jul 5, 2023 at 23:34

2 Answers 2

4

In Anchor, there is nothing stopping you from passing two TokenAccounts:

pub struct SomeContext<'info> {
    #[account(mut)]
    pub some_ata: Account<'info, TokenAccount>,

    #[account(mut)]
    pub another_ata: Account<'info, TokenAccount>,
}

pub fn handler(ctx: Context<SomeContext>) -> Result<()> {
    msg!(
        "bal A: {:?} bal B: {:?}",
        ctx.accounts.some_ata.amount,
        ctx.accounts.another_ata.amount
    );
    Ok(())
}
3

Solved - it appears to have been a stack size limit error, moving some accounts to heap via use of Box worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.