5

The documentations show how to initialize a new mint with a transfer fee, using createInitializeTransferFeeConfigInstruction().

My question is how to modify the transfer fee configuration later? Preferably in JS/TS.

1
  • Is this still not possible to update?
    – HALO
    Commented Apr 9 at 1:57

3 Answers 3

5

There's a missing instruction creator for the SetTransferFee instruction in the JS library, which is an oversight.

It's certainly possible, but only through the CLI currently with spl-token set-transfer-fee, e.g.:

$ spl-token set-transfer-fee <MINT_ID> <FEE_IN_BASIS_POINTS> <MAX_FEE>
5
0

Once it is set, there is no way to update the transfer fee for the mint.

2
  • So, once you create a mint with a transfer fee, you can't update the fee later?
    – iMrDJAi
    Commented Oct 6, 2023 at 21:00
  • for now you can't.
    – Ellie
    Commented Oct 7, 2023 at 1:32
0

Here's how I'm doing it with Rust:

Creating the extension with transfer_fee_basis_points = 0:

fn initialize_transfer_fee(ctx: &mut Context<LaunchToken>) -> Result<()> {
    invoke(
        &initialize_transfer_fee_config(
            &ctx.accounts.token2022_program.key(),
            &ctx.accounts.mint.key(),
            Some(&ctx.accounts.mint.key()),
            Some(&ctx.accounts.mint.key()),
            0,
            TOTAL_SUPPLY,
        )
        .unwrap(),
        &[ctx.accounts.mint.to_account_info()],
    )?;
    Ok(())
}

Updating it later on:

fn update_transfer_fee(ctx: &mut Context<UpdateToken>, mint_biz_id: String) -> Result<()> {
    invoke_signed(
        &set_transfer_fee(
            &ctx.accounts.token2022_program.key(),
            &ctx.accounts.mint.key(),
            &ctx.accounts.mint.key(),
            &[&ctx.accounts.mint.key()],
            ctx.accounts.pool_data.transfer_fee_basis_points,
            TOTAL_SUPPLY,
        )
        .unwrap(),
        &[ctx.accounts.mint.to_account_info()],
        signer_seeds
    )?;
    Ok(())
}

Hope it helps

Not the answer you're looking for? Browse other questions tagged or ask your own question.