Creating an SPL Token on Solana
Creating an SPL token on Solana is a streamlined process enabled by the SPL Token Program, which allows developers to define new digital assets with complete control over supply, decimals, minting authority, and distribution. This guide walks through the creation of an SPL token using the spl-token
CLI tool, helping you understand each step under the hood.
š SPL Token Program ID:
TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Prerequisites
Before proceeding, ensure the following:
ā
Installed Tools
Solana CLI: For interacting with the Solana blockchain.
SPL Token CLI: A utility for managing SPL tokens.
cargo install spl-token-cli
ā
Environment Setup
Your wallet is initialized:
solana-keygen new --outfile ~/.config/solana/devnet.json
Solana CLI is set to devnet or mainnet:
solana config set --url https://api.devnet.solana.com
Your wallet is funded with SOL (to pay transaction fees):
solana airdrop 2
Step-by-Step Token Creation
1. Create the Token Mint
This initializes a new token and returns its unique mint address.
spl-token create-token
Youāll receive an output like:
Creating token...
Token: <TOKEN_MINT_ADDRESS>
Behind the scenes:
A Mint Account is created to track total supply and configuration.
Your wallet is set as Mint Authority (can mint tokens).
By default, your wallet is also the Freeze Authority (can freeze token accounts).
š Save the token address. It is the permanent identifier for your SPL token.
2. Create an Associated Token Account
A token account is required to hold balances of a specific SPL token.
spl-token create-account <TOKEN_MINT_ADDRESS>
This command creates a token account associated with your wallet for the given mint.
š” Solana wallets can have one associated token account per mint. This is not the same as your main wallet address.
3. Mint Tokens to an Account
To generate supply, mint tokens from your wallet to a token account:
spl-token mint <TOKEN_MINT_ADDRESS> <AMOUNT>
Example:
spl-token mint <TOKEN_MINT_ADDRESS> 1000000
This sends 1,000,000 tokens to your walletās associated token account.
Minting requires authority. If you revoke minting rights (recommended after distribution), this command will fail.
4. Check Your Token Balance
spl-token balance <TOKEN_MINT_ADDRESS>
Or view all token accounts:
spl-token accounts
This confirms your SPL token balance is available in your token account.
5. Transfer Tokens to Another Wallet
To send tokens to another Solana wallet:
spl-token transfer <TOKEN_MINT_ADDRESS> <AMOUNT> <RECIPIENT_ADDRESS>
If the recipient doesnāt have a token account, the CLI will automatically create one if possible.
Optional Operations
š Revoke Mint Authority (Cap Supply)
If you want a fixed supply:
spl-token authorize <TOKEN_MINT_ADDRESS> mint --disable
āļø Freeze Accounts (Security Option)
spl-token freeze <TOKEN_ACCOUNT_ADDRESS>
You must have freeze authority to perform this action.
Summary Table
Create Token
spl-token create-token
Generates mint address
Create Token Account
spl-token create-account <MINT>
Needed to hold tokens
Mint Tokens
spl-token mint <MINT> <AMOUNT>
Requires mint authority
Check Balance
spl-token balance <MINT>
Verifies token balance
Transfer Tokens
spl-token transfer <MINT> <AMOUNT> <RECIPIENT_ADDRESS>
Sends tokens to recipient
Revoke Mint Authority
spl-token authorize <MINT> mint --disable
Optional, for capping supply
Freeze Token Account
spl-token freeze <TOKEN_ACCOUNT_ADDRESS>
Optional, requires freeze authority
Final Thoughts
Creating an SPL token is a foundational step in launching products on Solanaāwhether DeFi tokens, NFTs, or DAOs. With just a few commands, developers can create fast, scalable assets with real utility.
Want to go further? Integrate your token into smart contracts using Anchor, add metadata via Metaplex, or distribute tokens via claim sites or Merkle trees.
Next: Revisit Whar are SPL tokens? for conceptual grounding.
Last updated