How to create Tokens using Stellar
Tags: stellar
Published: 2021-05-24 13:35:37


> 
Learning blockchain can be intimidating and the learning curve can be very steep. Stellar makes it easier IMO.

With this article, I hope to help you gain a better understanding of how the stellar blockchain network works. My only hope is to inspire you to learn blockchain and be excited about the technology.

Stellar is a distributed ledger technology that allows anyone to build low-cost and fast financial services. 
[Stellar](https://www.stellar.org) has some of the best documentation and tutorials to help a blockchain developer get started quickly.

The [stellar laboratory](https://laboratory.stellar.org ) is the best place to explore the stellar ecosystem and how the technology works. It allows us to connect to the stellar server.

The Stellar Laboratory is a set of tools that enables people to try out and learn about the Stellar network. The laboratory can build transactions, sign them, and submit them to the network. It can also make requests to any of the Horizon endpoints.

![Screenshot 2021-05-19 at 21.51.29.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621453896565/cFXCQNLGe.png)

This article will have four key steps:
#### Step 1: Create two stellar accounts 
#### Step 2: Create a trustline between the issuer and distributor accounts
#### Step 3: Prevent the issuer from making more tokens
#### Step 4: Distribution of the tokens

Okay folks let's get our hands dirty 🙂🔥

# Step 1: Create two stellar accounts

The first step is setting up two accounts on Stellar one for issuing tokens and the other for distributing tokens.

Firstly, lets navigate  to [stellar laboratory](https://laboratory.stellar.org )  and select the stellar test server `https://horizon-testnet.stellar.org` to allow us to work in a test environment.

![Screenshot 2021-05-20 at 09.58.50.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621497534235/t9MTeX4sP.png)

Next, we will set up the two test accounts one for the issuer account and another for the distributor account. This can be done by clicking the generate key pair. This will output a public and private key for one account. Repeat  the process for the second account. 

![Screenshot 2021-05-19 at 21.56.15.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454184533/G4R6kc9x3.png)

Lastly, we will fund both accounts with 10000 lumens on the test network. You can do this by clicking the `Get test network lumens` button. Lumens are  native tokens in the Stellar network and you can [read more on lumens here](https://coinjournal.net/stellar-lumens).

![Screenshot 2021-05-19 at 21.56.59.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454225879/M3YtELe-6.png)

# Step 2: Create a trustline between the issuer and distributor accounts

The second step is about setting up a trustline between the issuer of tokens and the distributor. A Trustline in Stellar explicitly implies that the distribution account trusts the issuing account with the handling of the assets issued.

Firstly , we change tabs and go on the `Build Transaction` page. The transaction builder lets us build a new Stellar transaction on the Stellar Network.

![Screenshot 2021-05-19 at 21.58.26.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454311831/b2xslcHSK.png)

We add the distributor public id into the `Source Account` field. 

![Screenshot 2021-05-19 at 21.59.52.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454402229/Yc7zfI2I7.png)

And then we click the `Fetch next sequence number for account starting with "XXXXXXXX"` button .

![Screenshot 2021-05-19 at 22.00.31.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454439704/omV5ALMly.png)

Let's go to the `Operation Type` field and select `Change Trust` option from the dropdown. On the Asset field, we named our asset "Gold" , added the issuer public Id, and added a trust limit of 2000. A trust limit of 2000 means we will create 2000 tokens when we submit the transaction.

![Screenshot 2021-05-19 at 22.01.29.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454498021/jvycEbc8V.png)

Next, we complete the transaction by clicking the `Sign in Transaction Singer`  button.

![Screenshot 2021-05-19 at 22.02.04.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454531341/lW3NADFCc.png)

Lastly, we sign the transaction using the issuer's private key id and by clicking the `Submit In Transaction Submitter` button. When the transaction is successful 2000 tokens are generated and added to the Distributor's balance.

# Step 3: Prevent the issuer from making more tokens

The goal of this step is to prevent the issuer from generating more tokens on the Stellar network. So basically this locks the issuer's account.

Firstly, we go back to the transaction builder page. Let's add the issuer's public key in the `Source Account` field and generate a transaction sequence number by clicking  `Fetch next sequence number for account starting with "XXXXXXXX" `  button.

![Screenshot 2021-05-19 at 22.05.22.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454730980/kffKErXFX.png)

We go on the `Operation Type` field and select the `Set Options` option from the dropdown.

![Screenshot 2021-05-20 at 10.37.25.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621499858633/9yREnc6Zn.png)

Let's go to the `Master Weight` field and add a value of `0` .Then we click the `Sign In Transaction Singer` button at the bottom of the page .

![Screenshot 2021-05-19 at 22.06.05.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454771281/KSrykVONY.png)


Lastly, we add the issuer's private key in the `Add Singer` field and finish off by clicking `Submit In Transaction Submitter` button at the bottom of the page.
 
![Screenshot 2021-05-19 at 22.07.21.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621454847654/Vs7lx5Uey.png)

# Step 4: Distribution of the tokens

We have generated our tokens and everything is set up , finally, we need to be able to distribute the tokens. We can trade and convert our assets on the stellar network. Stellar offers a decentralized exchange and you can read more about it on https://developers.stellar.org/docs/glossary/decentralized-exchange/

Using this link  https://horizon-testnet.stellar.org/accounts/<Distributor public id> we can check out if we successfully generated the tokens.

![Screenshot 2021-05-20 at 07.30.15.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1621488633561/Vatykgc6u.png)

You now have a understanding of how the stellar blockchain network works.

Where to go from here?! 😁 I suggest you start building a blockchain solution with the help of [Stellar SDKs](https://developers.stellar.org/docs/software-and-sdks/). 

> Thanks

> Thanks to [Stellar](https://www.stellar.org/?locale=en) and the [stellar developer foundation](https://www.stellar.org/foundation) team!!

> Thank you for reading this -Follow me on [Twitter](https://twitter.com/CyprianAarons)

> Checkout my [website](cyprianaarons.co.zw).