- Published on
The Basics Of Creating Fungible Tokens
- Authors
- Name
- Lostin
- @__lostin__
Welcome back. In this tutorial we'll be looking at the basics of creating Solana tokens. To do so we'll be using the Solana token command line interface and I'll also show you a manual way to create tokens without code. Creating a token is easy once you know how but can be a bit confusing at first due to the Solana accounts system.
Today we'll be looking at creating a standard vanilla fungible token on Solana. Fungible essentially means the tokens are perfectly interchangable with one another. You may have heard of something called Token 2022, which introduced a bunch of new token features and capabilities such as transfer taxes. We'll be keeping things simple today and won't be looking at any of those features yet.
The SPL-Token CLI
First we need to install the SPL-Token CLI, this Rust crate is separate from the Solana CLI which you may have installed before. Run the following command on the terminal.
cargo install spl-token-cli
The installation does take a while. While you are waiting you can check out the SPL token CLI official docs. When the installation is finished you should be able to check everything is okay by running the following command.
spl-token --version
I will assume you have the standard Solana crate installed with a local key generated and that you've funded your account solana airdrop 2
with some balance as we learned in previous tutorials. Firstly we create our token mint account. The token mint account contains general metadata about our token including the maximum number of tokens, the number of decimals and the token owner which by default will be your local key account.
spl-token create-token
Creating token BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Address: BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY
Decimals: 9
Signature: 21y5sPGyTrt5eGy3jEbQ5JRCDhxb3bWuAUhuEK66MYUtdAXcwm7L3CLg7itqJc6bR6hWGzx6wv1DiA3MPobBoJhB
You can see some of this data by running the following command. Substitute the address of the token mint account for your one.
spl-token display BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY
SPL Token Mint
Address: BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY
Program: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Supply: 0
Decimals: 9
Mint authority: 2mCSuNUHo3wxgTEXG8ywwYusMUB8tfwGyC1qHtn5m9Q5
Freeze authority: (not set)
We've created a token mint account. But right now, no one has any tokens. For us to hold the token ourselves we must first have a token account for that token. We do that with the following command. Substitute your token mint address for the one below.
spl-token create-account BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY
Creating account TM5jWkD62m5s7q3w1dBw4AZGKZuJSDZ2PF5r3FbAtVk
Signature: 4iw9D7TCsQsYoGePYCH77dSoggJVD6GPAtkQiU67eHwhcP8HgdWWVwvQu6WgMUReVbEQFyfAUSNPjoLFWhn211dj
Only now that we have a token mint account and a token account can we actually mint a token to ourselves. Let's mint 1000 tokens with the following command.
spl-token mint BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY 1000
Minting 1000 tokens
Token: BNREmGFU8aJsNw44dDJzVAuNqr4rhwp1uEVzS6Yi62XY
Recipient: TM5jWkD62m5s7q3w1dBw4AZGKZuJSDZ2PF5r3FbAtVk
Signature: 2emNAeBgqBmR8AX2hLvBh1D7JEsstzAki5FvLGgA7gD1Mb5RGHodHjuEQZJM1frvp351zexmJVse5jm8gr8XwtsR
Next let's burn some of our tokens. We can burn them in the same way we minted them.
spl-token burn TM5jWkD62m5s7q3w1dBw4AZGKZuJSDZ2PF5r3FbAtVk 99
Burn 99 tokens
Source: TM5jWkD62m5s7q3w1dBw4AZGKZuJSDZ2PF5r3FbAtVk
Signature: 22yuLWu7Y4uxTPkchZCdSpqW9N5DjVj2MeseLXDt4aAm92h8UBzv5yHPU6Jz4kBWaHkMf95WLwjHHcCVNUVq2kmN
There are many more commands available to perform token related actions from the command line. You can see a list of them by running spl-token --help
. Experiment with a few.
Manually create tokens
While the SPL-token CLI is the more professional and easy to automate way to create tokens. There's also a non-technical option which is to use Fluxbeam tools. Currently as of writing they have a free selection of token tools for non-technical users to create and modify tokens including many of the new options made possible with Token 2022 such as transfer taxes and interest bearing.
Below are the current options for creating a token on Fluxbeam.
Okay, that's it for our basic introduction to tokens. Congrats for making it this far and happy minting!