LogoAnchor Docs

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):

  1. Token Program (Original)
    • Basic token functionality (mint, transfer, etc.)
    • Immutable and widely used
  2. 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.

Terminal
cargo add anchor-spl
Cargo.toml
[dependencies]
anchor-lang = "0.30.1"
anchor-spl = "0.30.1"

Core Modules

The most commonly used modules provided by the anchor-spl crate include:

ModuleDescription
tokenToken Program (legacy) instructions and account types
token_2022Token 2022 base instructions (instructions matching the Token Program functionality)
token_2022_extensionsToken 2022 extensions instructions
token_interfaceImplementation of account types that work with both Token Program and Token 2022 Program
associated_tokenAssociated token account instruction

The following pages provide examples of how to use the anchor-spl crate in an Anchor program.

On this page

Edit on GitHub