Token Integration with Anchor
Learn how to interact with Solana's Token Programs from an Anchor Program.
What are Token Programs?
On Solana, there are two main token programs (developed by Anza, previously Solana Labs):
- Token Program (Original)
- Basic token functionality (mint, transfer, etc.)
- Immutable and widely used
- Token Extension Program (Token 2022)
- Includes all original Token Program features
- Adds additional functionality through "extensions"
- Recommended for new tokens
Invoking Token Programs in an Anchor Program
The anchor-spl
crate
simplifies the process of interacting with Solana's Token Programs in an Anchor
program. This crate includes instructions and account types for both the
original Token Program and the newer Token Extension Program (Token 2022).
Simply add the anchor-spl
crate as a dependency to your program. For a
walkthrough of how to create an Anchor program locally, see the
quickstart page.
Core Modules
The most commonly used modules provided by the anchor-spl
crate include:
Module | Description |
---|---|
token | Token Program (legacy) instructions and account types |
token_2022 | Token 2022 base instructions (instructions matching the Token Program functionality) |
token_2022_extensions | Token 2022 extensions instructions |
token_interface | Implementation of account types that work with both Token Program and Token 2022 Program |
associated_token | Associated token account instruction |
The following pages provide examples of how to use the anchor-spl
crate in an
Anchor program.