I'm new here and I would like to transfer USDC from a defined wallet to another defined wallet. The From account could be a Signer account. I'm really confused and I don't know what I should do. With my knowledge I guess I should transfer wallet address to ATA.
I'm running these Anchor functions on NextJS & TSX. I have no problem transferring Solana to a destination but I don't understand how to do it for USDC.
Here's my example code for transferring Solana.
system_program::transfer(
CpiContext::new(
ctx.accounts.system_program.to_account_info(),
system_program::Transfer {
from: ctx.accounts.authority.to_account_info(),
to: contract_account.to_account_info(),
},
),
Ok(())
I would like to do the same for USDC. I made this function basically to get money from a signer to an Account PDA after a contract has been completed.
**ctx
.accounts
.moneyto
.to_account_info()
.try_borrow_mut_lamports()? += ctx.accounts.contract_account.price;
Thank you so much!