#[repr(u8)]
pub enum TransferFeeInstruction { InitializeTransferFeeConfig { transfer_fee_config_authority: COption<Pubkey>, withdraw_withheld_authority: COption<Pubkey>, transfer_fee_basis_points: u16, maximum_fee: u64, }, TransferCheckedWithFee { amount: u64, decimals: u8, fee: u64, }, WithdrawWithheldTokensFromMint, WithdrawWithheldTokensFromAccounts { num_token_accounts: u8, }, HarvestWithheldTokensToMint, SetTransferFee { transfer_fee_basis_points: u16, maximum_fee: u64, }, }
Expand description

Transfer Fee extension instructions

Variants§

§

InitializeTransferFeeConfig

Initialize the transfer fee on a new mint.

Fails if the mint has already been initialized, so must be called before InitializeMint.

The mint must have exactly enough space allocated for the base mint (82 bytes), plus 83 bytes of padding, 1 byte reserved for the account type, then space required for this extension, plus any others.

Accounts expected by this instruction:

  1. [writable] The mint to initialize.

Fields

§transfer_fee_config_authority: COption<Pubkey>

Pubkey that may update the fees

§withdraw_withheld_authority: COption<Pubkey>

Withdraw instructions must be signed by this key

§transfer_fee_basis_points: u16

Amount of transfer collected as fees, expressed as basis points of the transfer amount

§maximum_fee: u64

Maximum fee assessed on transfers

§

TransferCheckedWithFee

Transfer, providing expected mint information and fees

This instruction succeeds if the mint has no configured transfer fee and the provided fee is 0. This allows applications to use TransferCheckedWithFee with any mint.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The source account. May include the TransferFeeAmount extension.
  2. [] The token mint. May include the TransferFeeConfig extension.
  3. [writable] The destination account. May include the TransferFeeAmount extension.
  4. [signer] The source account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [] The source account’s multisignature owner/delegate.
  5. ..4+M [signer] M signer accounts.

Fields

§amount: u64

The amount of tokens to transfer.

§decimals: u8

Expected number of base 10 digits to the right of the decimal place.

§fee: u64

Expected fee assessed on this transfer, calculated off-chain based on the transfer_fee_basis_points and maximum_fee of the mint. May be 0 for a mint without a configured transfer fee.

§

WithdrawWithheldTokensFromMint

Transfer all withheld tokens in the mint to an account. Signed by the mint’s withdraw withheld tokens authority.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The token mint. Must include the TransferFeeConfig extension.
  2. [writable] The fee receiver account. Must include the TransferFeeAmount extension associated with the provided mint.
  3. [signer] The mint’s withdraw_withheld_authority.
  • Multisignature owner/delegate
  1. [writable] The token mint.
  2. [writable] The destination account.
  3. [] The mint’s multisig withdraw_withheld_authority.
  4. ..3+M [signer] M signer accounts.
§

WithdrawWithheldTokensFromAccounts

Transfer all withheld tokens to an account. Signed by the mint’s withdraw withheld tokens authority.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [] The token mint. Must include the TransferFeeConfig extension.
  2. [writable] The fee receiver account. Must include the TransferFeeAmount extension and be associated with the provided mint.
  3. [signer] The mint’s withdraw_withheld_authority.
  4. ..3+N [writable] The source accounts to withdraw from.
  • Multisignature owner/delegate
  1. [] The token mint.
  2. [writable] The destination account.
  3. [] The mint’s multisig withdraw_withheld_authority.
  4. ..3+M [signer] M signer accounts. 3+M+1. ..3+M+N [writable] The source accounts to withdraw from.

Fields

§num_token_accounts: u8

Number of token accounts harvested

§

HarvestWithheldTokensToMint

Permissionless instruction to transfer all withheld tokens to the mint.

Succeeds for frozen accounts.

Accounts provided should include the TransferFeeAmount extension. If not, the account is skipped.

Accounts expected by this instruction:

  1. [writable] The mint.
  2. ..1+N [writable] The source accounts to harvest from.
§

SetTransferFee

Set transfer fee. Only supported for mints that include the TransferFeeConfig extension.

Accounts expected by this instruction:

  • Single authority
  1. [writable] The mint.
  2. [signer] The mint’s fee account owner.
  • Multisignature authority
  1. [writable] The mint.
  2. [] The mint’s multisignature fee account owner.
  3. ..2+M [signer] M signer accounts.

Fields

§transfer_fee_basis_points: u16

Amount of transfer collected as fees, expressed as basis points of the transfer amount

§maximum_fee: u64

Maximum fee assessed on transfers

Implementations§

source§

impl TransferFeeInstruction

source

pub fn unpack(input: &[u8]) -> Result<Self, ProgramError>

Unpacks a byte buffer into a TransferFeeInstruction

source

pub fn pack(&self, buffer: &mut Vec<u8>)

Packs a TransferFeeInstruction into a byte buffer.

Trait Implementations§

source§

impl Clone for TransferFeeInstruction

source§

fn clone(&self) -> TransferFeeInstruction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TransferFeeInstruction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for TransferFeeInstruction

source§

fn eq(&self, other: &TransferFeeInstruction) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for TransferFeeInstruction

source§

impl StructuralPartialEq for TransferFeeInstruction

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V