This guide provides instructions for creating an SPL token on the Solana blockchain, including the necessary token metadata. For implementing the Metaplex metadata standard, please consult the official Metaplex documentation.
1. Install Solana Tools
To get started, First install the Solana CLI. Follow this guide to set up Solana tools on your system windows/linux.
2. Create a Folder and Keypairs
Open your terminal on windows/linux and create a new directory for your token:
mkdir crypto-token
cd crypto-token
Now, generate a keypair that will serve as the token owner: ( Keep it safe )
solana-keygen grind --starts-with key:1
This command generates a keypair where the public address begins with “key.” The more characters you add, the longer it will take to generate. Replace the example below with your own keypair:
keyH23FC3gG4miLPCTTDWuD9PDX6E6V9kBk681ZnvQm.json
Configure Solana to use this keypair:
solana config set --keypair keyH23FC3gG4miLPCTTDWuD9PDX6E6V9kBk681ZnvQm.json
Make sure to keep this keypair secure, as it controls your token mint and its associated metadata. To check the current Solana configuration, run:
solana config get
3. Create a Token Mint Address
Next, we create an address for the token mint:
solana-keygen grind --starts-with crypto:1
This command will generate a keypair starting with “crypto” Replace this example keypair with your own: the longer word you use it will take as longer time.
cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun.json
Set Solana to work on the Devnet (for testing purposes): You can use main-net also
solana config set -ud
4. Fund the Account
On Solana Devnet, you can get free SOL by using the following command:
solana airdrop 5
If you’re working on Mainnet, you’ll need to fund the account with real SOL by purchasing it from exchanges or decentralized platforms. To find your public key:
solana address
5. Create the Token Mint
In Solana, tokens are represented by unsigned 64-bit integers (u64). To create the token mint with the metadata extension enabled, run:
spl-token create-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb --enable-metadata cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun.json
You can also set custom decimals for your token by adding --decimals
7 to the command if needed (the default is 9).
6. Create and Upload Metadata
Now, create the off-chain metadata for your token. The metadata file should be a JSON file structured as follows:
{
"name": "Crypto Token",
"symbol": "CRYPTO",
"image": "https://your-storage-provider-url/token-icon.png"
}
You can upload this file to decentralized storage platforms such as Arweave, IPFS, or centralized options like GitHub. For this example, we recommend using Web3 Storage, which offers 5GB of free storage.
7. Add Metadata to the Token
Once you’ve uploaded your metadata, initialize the metadata for your token with the following command:
spl-token initialize-metadata cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun 'Crypto Token' 'CRYPTO' 'https://your-storage-provider-url/metadata.json'
8. Mint Tokens
Now that your token is set up, you can mint tokens. First, create a token account to hold the minted tokens:
spl-token create-account cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun
Mint the desired amount of tokens:
spl-token mint cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun 100
9. Transfer Tokens
You can transfer tokens to another wallet with:
spl-token transfer cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun 10 <recipient-address> --fund-recipient
The --fund-recipient
flag allows you to cover the recipient’s account rent.
10. Update Metadata
As long as the update authority isn’t set to null, you can update the metadata. For example, to update the URI of the token:
spl-token update-metadata cryptoG6oxHmPcXVdNaUoECzWXn8Jz8fA5Q99QauJ4Gun uri https://your-storage-provider-url/metadata.json
.
You’ve successfully created a token on the Solana blockchain, added metadata, minted tokens, and transferred them to another wallet. You can now view your token on Solana block explorers such as Solana Explorer, SolScan, or SolanaFM.