> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Extensions

> Learn about the Token Extensions Program (Token 2022) and how to use its extensions to add optional features to token mints and accounts.

## In short

Optional features of the Token-2022 program, such as metadata, pausing, default-frozen accounts, and transfer hooks, switched on per mint. Most must be chosen **when the mint is created**.

<div className="sol-usedin not-prose" data-concept="extensions">
<span className="sol-usedin-label">You've used this in:</span> [Tokenized asset <span className="sol-usedin-step">Step 2</span>](/developers/docs/assets/issue-asset/browser)
</div>

## What are Token Extensions?

The Token Extensions Program (Token 2022) provides more features through extra
instructions referred to as extensions. Extensions are optional features you can
add to a token mint or token account. You can find the implementation of these
extension instructions in the Token Extensions Program
[source code](https://github.com/solana-program/token-2022/tree/main/program/src/extension).

Each extension adds specific state that's generally initialized during mint or
token account creation. When initializing either account, you can enable
specific extensions simultaneously for different functionality. Most extensions
can't be added after an account is initialized. This is an important
consideration when designing your token, as you'll need to plan ahead for which
features you want your token to support. The pages in this section describe
each extension and how to integrate it.

<Info>
  Some extensions can't be combined on the same mint, and some require another.
  Mint initialization fails with `InvalidExtensionCombination` (`0x33`) when:

  - `ScaledUiAmount` and `InterestBearingConfig` are both present (each changes
    how the UI amount is calculated).
  - `TransferFeeConfig` and `ConfidentialTransferMint` are present without
    `ConfidentialTransferFeeConfig`, or `ConfidentialTransferFeeConfig` is
    present without both of them.
  - `ConfidentialMintBurn` is present without `ConfidentialTransferMint`.
  - `NonTransferable` and `ConfidentialTransferMint` are present without
    `ConfidentialMintBurn`.

  The rules are in
  [`check_for_invalid_mint_extension_combinations`](https://github.com/solana-program/token-2022/blob/program%40v11.1.0/interface/src/extension/mod.rs#L1326-L1374).
</Info>

The Token Extensions Program defines an
[`ExtensionType`](https://github.com/solana-program/token-2022/blob/program%40v11.1.0/interface/src/extension/mod.rs#L1066-L1154)
enum that lists all available extensions you can add to a token mint or token
account. Each variant represents a different extension with unique
functionality.

The `ExtensionType` enum is defined as follows (Token-2022 `program@v11.1.0`):

```rust title="Token Extensions"
/// Extensions that can be applied to mints or accounts.  Mint extensions must
/// only be applied to mint accounts, and account extensions must only be
/// applied to token holding accounts.
#[repr(u16)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(test, derive(strum_macros::EnumIter))]
#[derive(Clone, Copy, Debug, PartialEq, TryFromPrimitive, IntoPrimitive)]
pub enum ExtensionType {
    /// Used as padding if the account size would otherwise be 355, same as a
    /// multisig
    Uninitialized,
    /// Includes transfer fee rate info and accompanying authorities to withdraw
    /// and set the fee
    TransferFeeConfig,
    /// Includes withheld transfer fees
    TransferFeeAmount,
    /// Includes an optional mint close authority
    MintCloseAuthority,
    /// Auditor configuration for confidential transfers
    ConfidentialTransferMint,
    /// State for confidential transfers
    ConfidentialTransferAccount,
    /// Specifies the default Account::state for new Accounts
    DefaultAccountState,
    /// Indicates that the Account owner authority cannot be changed
    ImmutableOwner,
    /// Require inbound transfers to have memo
    MemoTransfer,
    /// Indicates that the tokens from this mint can't be transferred
    NonTransferable,
    /// Tokens accrue interest over time,
    InterestBearingConfig,
    /// Locks privileged token operations from happening via CPI
    CpiGuard,
    /// Includes an optional permanent delegate
    PermanentDelegate,
    /// Indicates that the tokens in this account belong to a non-transferable
    /// mint
    NonTransferableAccount,
    /// Mint requires a CPI to a program implementing the "transfer hook"
    /// interface
    TransferHook,
    /// Indicates that the tokens in this account belong to a mint with a
    /// transfer hook
    TransferHookAccount,
    /// Includes encrypted withheld fees and the encryption public that they are
    /// encrypted under
    ConfidentialTransferFeeConfig,
    /// Includes confidential withheld transfer fees
    ConfidentialTransferFeeAmount,
    /// Mint contains a pointer to another account (or the same account) that
    /// holds metadata
    MetadataPointer,
    /// Mint contains token-metadata
    TokenMetadata,
    /// Mint contains a pointer to another account (or the same account) that
    /// holds group configurations
    GroupPointer,
    /// Mint contains token group configurations
    TokenGroup,
    /// Mint contains a pointer to another account (or the same account) that
    /// holds group member configurations
    GroupMemberPointer,
    /// Mint contains token group member configurations
    TokenGroupMember,
    /// Mint allowing the minting and burning of confidential tokens
    ConfidentialMintBurn,
    /// Tokens whose UI amount is scaled by a given amount
    ScaledUiAmount,
    /// Tokens where minting / burning / transferring can be paused
    Pausable,
    /// Indicates that the account belongs to a pausable mint
    PausableAccount,
    /// Tokens burning requires approval from authority.
    PermissionedBurn,

    /// Test variable-length mint extension
    #[cfg(test)]
    VariableLenMintTest = u16::MAX - 2,
    /// Padding extension used to make an account exactly Multisig::LEN, used
    /// for testing
    #[cfg(test)]
    AccountPaddingTest,
    /// Padding extension used to make a mint exactly Multisig::LEN, used for
    /// testing
    #[cfg(test)]
    MintPaddingTest,
}
```

Each extension adds specialized functionality by including extra state to a mint
or token account. All extension specific state is stored in the
[`tlv_data`](https://github.com/solana-program/token-2022/blob/program%40v11.1.0/interface/src/extension/mod.rs#L549-L557)
field, which follows the base account data type. You must further deserialize
the `tlv_data` (containing extension state) according to the specific extension
types enabled for that account.

```rust title="Token Extensions" highlight={8}
/// Encapsulates immutable base state data (mint or account) with possible
/// extensions, where the base state is Pod for zero-copy serde.
#[derive(Debug, PartialEq)]
pub struct PodStateWithExtensions<'data, S: BaseState + Pod> {
    /// Unpacked base data
    pub base: &'data S,
    /// Slice of data containing all TLV data, deserialized on demand
    tlv_data: &'data [u8],
}
```
