Step by step guide for creating a token on Solana Network

Parth Kaloliya
9 min readJan 8, 2022

--

Solana Network

Hello Everyone!!

First of all, wishing you a very Happy New Year!! Due to my busy schedule, I was not able to write the stories on medium.

The main agenda of this story is to create a token on Solana Mainnet, yes you read it right Mainnet!! 😎

So, without wasting any second let’s get started.

Before moving on to our main topic, I would like to discuss some important points and some pre-requisites that we need on our machine before proceeding.

Pre-requisites:

  • OS: Ubuntu (Latest version is preferable)
sudo apt-get update 
sudo apt-get upgrade -y

Execute the above two commands.
- apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies.
- apt-get upgrade to install available upgrades of all packages currently installed on the system from the sources configured via sources.

We are good till here, Let’s start the main operation Now. 😌

Just a small note, While following this story, we will see different outputs so it is fine because I have copied commands and respective outputs from my terminal so definitely it is going to be different.

sh -c "$(curl -sSfL https://release.solana.com/v1.9.3/install)"

This is Solana's install tool. I have used version 1.9.3 that’s why I have copied my link here :) but we can change the version we desire.
After successful execution of this command we will see the output like this:

downloading v1.9.3 installer
Configuration: /home/vulcan/.config/solana/install/config.yml
Active release directory: /home/vulcan/.local/share/solana/install/active_release
* Release version: v1.9.3
* Release URL: https://github.com/solana-labs/solana/releases/download/v1.9.3/solana-release-x86_64-unknown-linux-gnu.tar.bz2
Update successful

Please check your PATH environment. If we are using Ubuntu then the above command will automatically set the Solana path into our existing PATH. We just need to close the terminal and reopen the terminal.

If we do not see any PATH is set then let’s execute the following command

export PATH="/home/vulcan/.local/share/solana/install/active_release/bin:$PATH"

Log out from the terminal and log back in. Execute the following command to check the Solana version

solana --version

Cool!! Now we are going to create our cryptocurrency wallet that will hold Solana. Let’s do this.

solana-keygen new

The above command will first ask for a passphrase, it will just be for a security purpose, if we do not want to set just hit enter and it will give generate one wallet for us, and in return, it will tell where our private key is stored and share the public key and passphrase with us.

Wrote new keypair to /home/vulcan/.config/solana/id.json
==============================================================================
pubkey: YOUR_PUBLIC_KEY
==============================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
MNEMONIC_PHRASE
==============================================================================

Yeah! I have modified the output, I don't want to reveal my seed phrase. 😓
Please save the public key and mnemonic phrase in a very safe place.

Awesome!! The wallet has been created, let’s fill that wallet with some money.

Execute the following command to check the balance of our wallet.

solana balance

We just have created the wallet so definitely, we have 0 SOL tokens, so the output would be like

0 SOL

Now we have to fill our wallet with some SOL tokens, for doing that we can take help of any exchange, I have already performed this step and I am not going to include that portion in this story as it will make this story very long to read, but nowadays we all know how to take tokens from the exchange.

Let me give you a brief here. I have used Binance for that, I have USDT in my wallet so I just swapped USDT/SOL and then withdraw that SOL to my newly created account.

Once we are done with this exchange part, execute the same command again for checking the balance and it will show the updated balance.

Now we have our wallet with some SOLs in our wallet.

We have to do some real quick steps to prepare our environment for the Solana token operation.

We need to install rust language, you can google more about rust but for now, rust is a language that Solana uses to deploy tokens. Execute the following command.

curl https://sh.rustup.rs -sSf | sh

This command will ask us for an option that we wanted to go with, I have chosen option no 1, so we can go with that.

After successful execution, just log out from the existing terminal and log back in.

Now, we need to install some tools.

Execute following commands.

sudo apt install libudev-dev
sudo apt install libssl-dev pkg-config
sudo apt install build-essential -y

Now it's time to install Solana Token Program, this will be a CLI tool that we can use to install a token on the Solana Blockchain.

cargo install spl-token-cli

This command might take some time so in the meantime, you can send me a connection request on LinkedIn 😉.

We are finally ready 😍, If you manage to follow all the above parts successfully so, now we just have to create the token and it's done.

spl-token create-token

We just created a token, we can see the output like:

Creating token TOKEN_ADDRESS
Signature: SOME_SIGNATURE

Please save the TOKEN_ADDRESS in a safe place. we will need it in further steps.

You can execute the solana balance command for checking your balance as we are doing all the operations on mainnet so it will definitely charge you some SOL token for creating our token, but trust me it's too less.

Now we need to create one account that can hold the token which you have just created in the above step.

spl-token create-account TOKEN_ADDRESS

In this command, you need to pass the TOKEN_ADDRESS This command will also charge some of the SOL tokens but the amount would be tiny. You can see the output like:

Creating account ACCOUNT_ADDRESS
Signature: SOME_SIGNATURE

Please save the ACCOUNT_ADDRESS in a safe place. we will need it in further steps.

We have created the token and the account that holds those tokens, now we have to fill that account with the tokens that mean we will mint some tokens in the next step.

spl-token mint TOKEN_ADDRESS TOKEN_AMOUNT ACCOUNT_ADDRESS

This command will mint the particular tokens that we have passed as a first argument (TOKEN_ADDRESS) with the supply of (TOKEN_AMOUNT) and will be held by (ACCOUNT_ADDRESS). You can pass N number of tokens in TOKEN_AMOUNT (I have set that argument to 1000000 tokens). You can expect the output like:

Minting 1000000 tokens
Token: TOKEN_ADDRESS
Recipient: ACCOUNT_ADDRESS
Signature: SOME_SIGNATURE

You can check your account with the tokens held by them by executing the following command.

spl-token accounts 

The output will look like this:

Token                                         Balance
------------------------------------------------------------
TOKEN_ADDRESS 1000000

Time to do some transfers 😎. For this, you will need a new Solana wallet and for that, you can install a Phantom chrome extension.

You can create a new wallet after following all the initial setup of Phantom (your one would be the new one so definitely it will ask for a password and all other things).

Let's do transfer some tokens from the account which we have created in CLI to our phantom wallet.

spl-token transfer --fund-recipient --allow-unfunded-recipient TOKEN_ADDRESS AMOUNT RECEIVER_ADDRESS

--fund-recipient will tell Solana CLI that you want to fund the creation of an account for the wallet you are sending to. That means the account which you have created in the phantom or any Solana account that you will create in the future, will not by default have an account for your token.
--allow-unfunded-recipient simply means that the wallet does not have an account for our token. Even though they don't have this flag would allow us to send our custom token.

You will see output like this:

Transfer AMOUNT tokens
Sender: SENDER_ADDRESS
Recipient: RECEIVER_ADDRESS
Recipient associated token account: F59618aQB8r6asXeMcB9jWuY6NEx1VduT9yFo1GTi1ks
Funding recipient: F59618aQB8r6asXeMcB9jWuY6NEx1VduT9yFo1GTi1ks (0.00203928 SOL)
Signature: SOME_SIGNATURE

You can check your phantom wallet and you can see the tokens you have transferred would be displayed there as an Unknown Token.

I know you feeling bad while seeing that Unknown Token type of thing. But I will also explain that as well before that celebrate for a while 🍾

Before moving to the next part, I would like you to see Solana explorer and search your token address, account address and you can see all the transactions there.

This part will cover how you can give your token a nice name and a nice picture.

Let’s start with the logo first. Download any logo in PNG format that you wanted to see as a token logo. Take care of the size as well, mine was less than 10KB so make sure your logo should be small as well. After downloading the image and if you are done with the size then save that file with the name logo.png.

Now, create a new repository on GitHub. (You can keep the repository name you want).

Upload your logo.png file on the repository which you created in the previous step.

After uploading, click on the logo.png file, it will open in GitHub itself and you can see the download button. Click on that download button and it will open your logo file but with a different URL. URL will start with raw.githubusercontent.com Copy this URL and save it in a safe place.

It's time to do some action 😉 Here, I am assuming that you are already familiar with the basic GitHub commands. So I’ll start the bullet point list and you just have to follow those carefully.

  • Go to Solana token list Github repository.
  • Click on the fork and it will be forked into your GitHub account. Now we have our own version of Solana token repository.
  • Open the VS code (We really don’t need to clone the forked repo and then open it in VS Code. Just press the . in the GitHub screen and it will open the VS Code on your chrome browser.
  • We just need to make only 2 changes. Just follow carefully and we are done.
  • Open the /assests/mainnet directory and create a new folder, keep the folder name as your TOKEN_ADDRESS
  • Open your folder and upload your logo.png file.
  • Open the /src/tokens directory, there we will see the file solana.tokenlist.json file. This file contains all the information related to all the tokens which are present in Solana Mainnet. Basically, it is a registry.
  • Open that file and search Solulab token and copy that entire object. I am attaching that object here as well, so if you do not want to waste your time, it’s fine.
{
chainId: 101,
address: “5PR8Fre4gU52dgv5W4nrJkSAW4xonDWD5d84HJF7nDhU”,
symbol: “SLTK”,
name: “Solulab Token”,
decimals: 0,
logoURI: “https://raw.githubusercontent.com/Parth2412/solana-token/main/logo.png"
}
  • Make sure we need to replace everything with your details, please be very careful here. We need to change the address, symbol, name, and logoURI.
  • Go to the end of the file, We can see version object, Above that version object you can see one closing array bracket ] . You just need to copy your token object and paste it above ] this bracket.
  • We really need to take care of the above three points as we are trying to modify the existing registry file and add our token details so please be very careful.
  • We can see that we have made 2 changes now it’s time to commit those changes so commit those changes with a nice commit message like:
    adding YOUR-TOKEN-NAME token to the solana. Click on the + icon to commit those changes.
  • Now, let’s navigate back to the Solana token list Github repository.
  • Click on the Pull Requests and then New pull request.
  • We can see one option like: compare across forks. Click on that option and we can see the base repository and head repository, we do not need to change the base repository as it is set to solana-labs/token-list we just need to change the head repository. Change that to our version of the repository, you can find your GitHub username in the dropdown.
  • Click on the create pull request. Check everything once again then scroll down and you can see create pull request the button again. Click on that and boom we are done!! 🍾
  • Now we just have to wait for bots to merge our request, once they are able to merge it successfully then our PR would be converted into close PR. Generally, bots will start doing bulk merging at the time period of every 30 mins or every 60 mins, so it’s fine if you think why it is taking too much time. You can check your PR status after 30 mins or 60 mins.
  • If we see our PR status is converted to close PR then let’s go to Solana explorer and search about our token, we can see our token logo, token name, and token symbol as well.
  • If we wait for 24 hours, then we will be able to see our token with logo and symbol in the phantom wallet as well, we can search with the token symbol in the phantom wallet as well.

Sit back for a while and celebrate the great job you just did 👏. Tell your friends, colleagues, to share their addresses and do the transfers check those transactions on the Solana explorer as well.

I’ll come back with some great stories so that you guys can read and can perform practically.

--

--