Creating a Solana token involves a few key steps: generating a keypair, creating the token metadata, and deploying it on the Solana blockchain. Below is a simplified guide to creating a SPL token (Solana's equivalent of ERC-20) using the Solana CLI and spl-token commands.

Step 1: Install Required Tools
1.Install Solana CLI (Command Line Interface):
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
Verify installation:
solana --version
2.Install SPL Token CLI:
cargo install spl-token-cli
3.Set Network (Default is mainnet-beta, use devnet for testing):
solana config set --url devnet
4.Create/Verify Wallet:
If you don’t have one:
solana-keygen new --outfile ~/.config/solana/devnet-wallet.json
Check balance (get test SOL from a faucet if needed):
solana airdrop 1
Step 2: Create the Token
1.Create the Token:
spl-token create-token --decimals 9
Replace
9with your desired decimal places (e.g.,6for USDC-like tokens).This outputs a Token ID (e.g.,
3x2W5...). Save this!
2.Create a Token Account (to hold minted supply):
spl-token create-account <TOKEN_ID>
3.Mint Tokens:
spl-token mint <TOKEN_ID> 1000000000
This mints
1,000,000,000units (with 9 decimals = 1 token).
4.Disable Future Minting (make supply fixed):
spl-token authorize <TOKEN_ID> mint --disable
Step 3: Add Metadata (Optional)
To make your token visible in wallets like Phantom, add metadata using Metaplex:
1.Install Metaplex CLI:
npm install -g @metaplex-foundation/metaplex-cli
2.Create a JSON metadata file (token-metadata.json):
{
"name": "Your Token Name",
"symbol": "TICKER",
"description": "A test token on Solana",
"image": "https://your-token-image-url.png",
"decimals": 9,
"website": "https://your-website.com"
}3.Upload metadata:
metaplex upload -k ~/.config/solana/devnet-wallet.json token-metadata.json
Step 4: Verify Token
1.Check token supply:
spl-token supply <TOKEN_ID>
2.View token in a wallet (e.g., Phantom):
Add the Token ID as a custom token.
Notes
Mainnet vs. Devnet: Replace
devnetwithmainnet-betain commands for a real token (requires SOL for fees).Token Standards: For advanced features (NFTs, royalties), explore Metaplex Token Standards.
Smart Contracts: SPL tokens are basic. For custom logic, write Solana programs in Rust/Anchor.
Example Transaction Flow
# Create token (9 decimals) spl-token create-token --decimals 9 # Output: Token ID: 3x2W5... # Create account spl-token create-account 3x2W5... # Mint 1000 tokens (assuming 9 decimals) spl-token mint 3x2W5... 1000000000 # Disable minting spl-token authorize 3x2W5... mint --disable
Done! Your Solana token is now live.
