Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Solana development skill covering @solana/kit v5, Anchor programs, LiteSVM testing, and security patterns.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/kit/programs/token-2022.md
1---2title: Token-2022 (Token Extensions)3description: Kit-compatible @solana-program/token-2022 client — key differences from base Token program, account sizing, ATA derivation, and extension reference.4---56# Token-2022 (Token Extensions)78Program address: `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`910```ts11import { TOKEN_2022_PROGRAM_ADDRESS } from '@solana-program/token-2022';12```1314Token-2022 extends the base Token program with configurable extensions. For a full guide to available extensions and their use cases, see the [Token Extensions documentation](https://solana.com/docs/tokens/extensions).1516## When to Use Token-2022 vs Token1718| Use Token-2022 | Use Token |19|----------------|-----------|20| Transfer fees needed | Simple fungible tokens |21| On-chain metadata | Maximum compatibility |22| Confidential transfers | Lowest compute cost |23| Transfer hooks | Existing ecosystem integration |24| Interest-bearing tokens | |25| Non-transferable tokens | |2627## Key Differences from Base Token2829### Variable Account Sizes3031Unlike base Token (fixed 82/165 byte accounts), Token-2022 sizes vary by extension. Calculate before creating or rent allocation fails:3233```ts34import { getMintSize, getTokenSize } from '@solana-program/token-2022';3536// Without extensions37const baseSize = getMintSize(); // 82 bytes3839// With extensions - pass extension configs40const sizeWithExtensions = getMintSize([41{ extension: 'TransferFeeConfig', ... },42{ extension: 'MetadataPointer', ... },43]);44```4546### ATA Derivation4748Same pattern as base Token, but you **must** pass `TOKEN_2022_PROGRAM_ADDRESS` — using the wrong program address derives the wrong ATA.4950```ts51import { findAssociatedTokenPda, TOKEN_2022_PROGRAM_ADDRESS } from '@solana-program/token-2022';5253const [ata] = await findAssociatedTokenPda({54owner: walletAddress,55mint: mintAddress,56tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,57});58```5960### Extension Initialization Order6162Extension instructions must come **before** mint initialization — the runtime processes them in order and mint init finalizes the account.6364### Account Fetching6566Same patterns as base Token — extensions are accessible via `mint.data.extensions`:6768```ts69import { fetchMint, fetchToken } from '@solana-program/token-2022';7071const mint = await fetchMint(rpc, mintAddress);72// Access extensions via mint.data.extensions73```7475## Extensions Reference7677See [Token Extensions documentation](https://solana.com/docs/tokens/extensions) for implementation details on each extension.78