1

I am trying to transfer some spl tokens from one account to another. The account's authority is a PDA of the program:

if source_account.amount > 0 {
        invoke_signed(
            &spl_token::instruction::transfer(
                &token_program_info.key,
                &source_account_info.key,
                &dest_account_info.key,
                &transfer_authority_info.key,
                &[],
                source_account.amount,
            )?,
            &[
                token_program_info.clone(),
                token_pot_info.clone(),
                dest_account_info.clone(),
                transfer_authority_info.clone(),
            ],
            &[authority_seeds],
        )?;
    }

My program succeeds without this, but when I add this code back in I receive an error: Err value: TransactionError(InstructionError(0, ProgramFailedToComplete))'

for context, the transfer authority is definitely correct as when i edit it I get a different error: PrivelegeEscaltion.

The accounts are also initialised, I printed out the amount both of them store currently and it works. They are same mint...

LUK3ARK
  • 11
  • 1
  • Consider asking this question in the solana stack exchange: https://solana.stackexchange.com/ – C.OG Aug 01 '22 at 01:57

1 Answers1

0

It doesn't look like the accounts line up. If you're trying to transfer from token_pot_info, you should do:

        invoke_signed(
            &spl_token::instruction::transfer(
                &token_program_info.key,
                &token_pot_info.key,
                &dest_account_info.key,
                &transfer_authority_info.key,
                &[],
                source_account.amount,
            )?,
            &[
                token_pot_info.clone(),
                dest_account_info.clone(),
                transfer_authority_info.clone(),
                token_program_info.clone(),
            ],
            &[authority_seeds],
        )?;

I also moved the token program info to the bottom. That may also be causing an issue.

Jon C
  • 7,019
  • 10
  • 17