Anchor includes a SystemAccount
type that you can use if the expected to
account will always be a system program owned account (ex. a user's wallet address).
#[derive(Accounts)]
pub struct Transfer<'info> {
pub from: Signer<'info>,
#[account(mut)]
pub to: SystemAccount<'info>
}
Using the UncheckedAccount
type would allow the recipient of the transfer to be any account (such as program account, or an account owned by other program).
You would need to specify that the from account is mutable with #[account(mut)]
. Maybe add a test to see if the balances after the transfer actually changes.