1

I'm trying to fund a Native Mint token Account from a PDA and then Sync it like so.

    **(funder.try_borrow_mut_lamports()?) -= excess_sol;
    **(wrapped_sol_escrow.try_borrow_mut_lamports()?) += excess_sol;

    anchor_spl::token::sync_native(CpiContext::new(ctx.accounts.token_program.to_account_info(), 
      anchor_spl::token::SyncNative{ account: wrapped_sol_escrow.to_account_info() }))?;

But this gives "Sum of account balances before and after instruction do not match"

1 Answer 1

3

I asked a similar question recently.

You need to transfer the balance at the very end of your transaction, or at least after any Cross Program Invocation.

See this github issue that explains why.

2
  • Yep I saw your question but in this example it woudn't work as I need to sync in the native mint balance to be usable.
    – Trevor
    Commented Jan 6 at 11:10
  • Then I guess you’d have to do it in two transactions instead of one until the bug is fixed? (Assuming it is fixed one day considering that it’s already pretty old…) Commented Jan 6 at 14:37

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.