Skip to main content
edited title
Link
Burger Bob
  • 1.5k
  • 4
  • 19

How to efficiently transfer "pure"NATIVE SOL to a program accepting NATIVEWRAPPED SOL?

Source Link
Burger Bob
  • 1.5k
  • 4
  • 19

How to efficiently transfer "pure" SOL to a program accepting NATIVE SOL?

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:

  1. Create WSOL account
  2. Fund WSOL account with SOL
  3. 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?