I am writing a program in which the accepted payment MUST be from a token account. Anchor context snippet here:
pub struct Payment<'info> {
#[account(mut)]
pub buyer_token_account: Account<'info, TokenAccount>
...
...
}
In order for the user to pay via SOL, i am currently doing 3 separate transactions:
- Create WSOL account
- Fund WSOL account with SOL
- Call Payment with WSOL account
Although, this results in the user having to accept more than one transaction.
So I wanted to know if there are ways to do this at once, such that the user only sees SOL being deducted in the Phantom Wallet summary. I.e. - 1 SOL, and not -1 SOL, + 1 WSOL.
I assume that I could create a transaction consisting of all 3 instructions. Would this work? If yes, are there other ways to do this as well?