For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to Create Tokens With Metadata On Solana Using Token-2022

Create Solana SPL tokens with metadata using Token-2022 program — developer guide

Now that you have learnt about token extension, in this guide, you will be learning how to create a simple token with metadata extension

Prerequistics

Before you begin, ensure you have the following:

  1. Node installed on your PC, preferably v20+

  2. A package manager such as npm or yarn

  3. Solana Wallet, e.g., Phantom, Solfare, or Metamask

  4. Solana Access token from GetBlock

  5. Basic knowledge of JavaScript and Typescript

  6. Basic understanding of Solana (wallets, transactions, lamports)

Set up your environment

1

Create a new project directory:

2

Install required dependencies:

3

Create a .env file and add the following:

Configuration File

Create config.js file and add the following:

Create a Token with Metadata Extension

1

Create a new file index.js . This will serve as your working file

2

Import all the dependencies:

3

Generate an account for the mint address

4

Define the token metadata:

5

Calculate the metadata space and rent needed for the mint account:

This ensures our token mint account has sufficient space for the extensions you use or else the metadata initialization would fail with an insufficient lamports error.

6

Define the structure of the transaction:

This creates the mint address, initializes the mint, metadata, points to the mint itself as the metadata account, and sends the transaction.

Complete code
7

Run the code using this command:

8

Result:

Verify on the Solscan:

Solscan verification

Conclusion

In this guide, you have learnt how to create a token with metadata extension. This guide also walks you through generating a Mint account for your token.

This guide uses Solana Devnet. If you want to make use of Mainnet, go to your account dashboard and get a Solana mainnet access token.

Additional Resources

Last updated

Was this helpful?