Creating a Token-2022 on Solana

Quickly mint a Token-2022 compliant SPL token on Solana Devnet or Mainnet using the command-line interface (CLI).

This guide explains how to quickly mint a Token-2022 compliant SPL token on Solana Devnet using the command-line interface (CLI). It also shows how to enable and use token extensions such as metadata and transfer fees.


Prerequisites

  1. Install Solana CLI

    sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
  2. Install SPL Token CLI (must support Token-2022)

    cargo install spl-token-cli
  3. Set Up Solana CLI for Devnet

    solana config set --url https://api.devnet.solana.com
    solana config set --keypair /path/to/your/dev-wallet.json
  4. Airdrop Some SOL for Fees

    solana airdrop 2

Step-by-Step Token-2022 Minting

1. Create a Token-2022 Mint

spl-token create-token \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb

Save the returned token mint address.

2. Create a Token Account for Your Wallet

3. Mint Tokens to Your Account

4. Confirm Token Balance


Adding Token Extensions

Token-2022 supports advanced features called extensions. Below are examples of two useful ones.

Extension 1: Transfer Fee

This allows collecting fees on every token transfer.

Create Mint with Transfer Fee Extension

Initialize Transfer Fee

This sets a 0.25% fee (25 basis points) with a max of 10 tokens per transfer.


Extension 2: Metadata

This enables rich token metadata like name, symbol, and image.

Initialize Metadata

Make sure the JSON metadata file at that URL is hosted and follows the standard format.


Resources


Notes

  • You must use the --program-id Tokenz... flag for all Token-2022 interactions.

  • Some extensions require initializing during the token mint creation.

  • Not all wallets or exchanges currently support Token-2022 tokens.


Happy minting!

Last updated