How to Create an SPL Token on Solana Using the Command Line

·

The Solana Program Library (SPL) token standard is a foundational element of the Solana blockchain, enabling developers and users to create, manage, and transfer custom tokens efficiently. Using Solana's command-line tools, you can issue your own SPL tokens, mint initial supplies, and perform operations like airdrops. This guide provides a step-by-step walkthrough for creating and managing SPL tokens via the terminal.


Prerequisites

Before you begin, ensure you have the following set up:


Step 1: Create a New SPL Token

To create a new token, use the spl-token create-token command. This operation generates a new token mint account on the blockchain.

Example command and output:

spl-token create-token

Output:

Creating token E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Address: E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy
Decimals: 9
Signature: 4ZzwaPK34qpLgamyKtPtLc3WtYp5HRpudiJwFzPszq6ErKPP6jeCsPxf9JWYcchg5S2QjAeUbNMX4F1azsyxnAdj

Step 2: Create a Token Account

After creating the token, you need an associated token account (ATA) to hold balances of that token. Use the spl-token create-account command with your token address.

Example:

spl-token create-account E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy

Output:

Creating account Cemt9DSnRUZCJo7HtYeS75GrnfM6fne1HinqnUkiFdVz
Signature: 3QwfqKobnam53iL9HqpQE8Nj4jpdzBng9KzoDS8dPbi9iBfHUWV9XEWfVCJTCja7PJN7edFwGjJDnipr7aaA7GRZ

The ATA is now ready to receive token balances.


Step 3: Mint Tokens to Your Account

Use the spl-token mint command to issue an initial supply of tokens to your ATA.

Example:

spl-token mint E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy 10000 Cemt9DSnRUZCJo7HtYeS75GrnfM6fne1HinqnUkiFdVz

Output:

Minting 10000 tokens
 Token: E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy
 Recipient: Cemt9DSnRUZCJo7HtYeS75GrnfM6fne1HinqnUkiFdVz
Signature: 4cesqzY5sh6Dy5thkyPxKKjdo2tTyE8eb3D895KnFmPEKY9LGKqgDCPx99xLA21MQPNTYNDihhD2LYtVFW9WS4p4

You can verify the balance with:

spl-token balance E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy

Step 4: Transfer SPL Tokens

To send tokens to another wallet, use the spl-token transfer command. The --fund-recipient flag ensures the recipient’s ATA is created if it doesn’t exist.

Example:

spl-token transfer --fund-recipient E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy 100 6nmqFHKGZP8AXpdh3ynwV4GQS1cc64wG8e8dZUgX4RoM

Output:

Transfer 100 tokens
 Sender: Cemt9DSnRUZCJo7HtYeS75GrnfM6fne1HinqnUkiFdVz
 Recipient: 6nmqFHKGZP8AXpdh3ynwV4GQS1cc64wG8e8dZUgX4RoM
 Recipient associated token account: EQPA9QhhDe9Mg41Vkar1fzyHjKcSNKiX6vHDd82LargQ
 Funding recipient: EQPA9QhhDe9Mg41Vkar1fzyHjKcSNKiX6vHDd82LargQ
Signature: 5moXxanL71T7WvSkSpPePn2rSdFrkcqSK6EsnabCvKw4NwMdGTiRVA5dKmbhymKpA8JRXgkYvRdGVFzTiEDUYqC8

Advanced Operations

Setting Token Authority

You can assign minting or freezing authority to other addresses during or after token creation using commands like:

spl-token authorize E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy mint <NEW_AUTHORITY>

Disabling Minting

To make your token supply fixed, permanently disable minting:

spl-token disable-mint E69iMAYn5k9HcWiPRZtthMDmyv1owgiWSbZCtTn9VMzy

Airdropping Tokens

For larger airdrops, automate transfers using scripts that iterate over recipient addresses. Always test on devnet first.


Best Practices for SPL Token Management

For more advanced tokenomics or custom logic, you might explore on-chain programs or smart contracts.


Frequently Asked Questions

What is an SPL token?

SPL tokens are digital assets on the Solana blockchain that follow a standardized token program. They represent fungible or non-fungible items and are interoperable with Solana wallets and applications.

Why do I need an associated token account?

An associated token account (ATA) is a dedicated account that holds balances of a specific SPL token for a user. It simplifies token management and ensures compatibility with wallets.

Can I change the decimal places of a token after creation?

No, the decimal precision is set permanently during token creation. Plan your tokenomics carefully before deploying.

How do I view my SPL tokens in a wallet?

Most Solana wallets (e.g., Phantom, Solflare) automatically detect and display SPL tokens held in your associated token accounts.

What is the cost to create an SPL token?

Creating a token requires SOL for transaction fees and account rent. Costs vary based on network congestion but are generally low on testnets.

How can I automate token airdrops?

Use scripts with the SPL Token CLI or integrate with Solana web3 libraries like @solana/web3.js for programmatic airdrops.