1

Is it possible to take the token account creation fee from the wallet to which the token will be sent? Would they need to sign the transaction in order to achieve this?

2 Answers 2

2

It would only be possible to take the token account creation fee from the target of the account if the target also signed the transaction.

2

As mentioned in another answer, it is possible. If the traget is the payer, it has to be a signer as well.

Here's an example on how it could look like with Anchor:

#[derive(Accounts)]
pub struct CreateTokenAcct<'info> {
    #[account(mut)]
    pub user: Signer<'info>,
    #[account(mut)]
    pub target: Signer<'info>,
    pub mint: Account<'info, Mint>,
    #[account(init, payer = target, associated_token::mint = mint, associated_token::authority = target)]
    pub destination: Account<'info, TokenAccount>,
    pub system_program: Program <'info, System>,
    pub token_program: Program<'info, Token>,
    pub associated_token_program: Program<'info, AssociatedToken>,
    pub rent: Sysvar<'info, Rent>,

}
2
  • 2
    It's not necessary to use init_if_needed here and it's generally considered bad practice to use
    – Henry E
    Commented Jul 25, 2022 at 18:23
  • 1
    Good point. I edit the answer to not use init_if_needed. Commented Jul 25, 2022 at 18:41

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.