Stellar Service Part 3: All things tokens

Connor Macdougall
Rehive blog

--

[This post is slightly outdated, but the details are still informative to learn more about Rehive’s Stellar Extension. As a shortcut we recommend that you start by trying out our automated configuration flow by creating an account here.]

This is the third part of the Stellar setup series. It is recommended that you read Part 1 and Part 2 first.

A basic intro to cryptocurrency tokens

Tokens have become one of the more powerful ways to take advantage of cryptocurrencies. At their core they are essentially arbitrary currency codes that are given meaning by context. They are useful for creating rewards-specific currencies, a loyalty-based currency, issuing credit for a real world currency or asset, and many other use cases. One of the more popular and well known type of token is the ERC20 Token on the Ethereum blockchain. It is essentially a user agreed-upon smart contract structure that keeps track of user balances for its respective token. In contrast, the Stellar ecosystem has a built-in method for handling tokens: trustlines.

A ‘token’ is the trust that one Stellar account has for a specific currency code issued by another Stellar account. Once the trustline is established the receiving account will accept the token from the trusted issuer account.

One simple example would be representing USD on the Stellar blockchain. Let’s say that Alice has $1000 in reserve. Bob would like to trade that USD for other currency pairs on the Stellar network. He trusts Alice to keep the currency in reserve, therefore he can trust Alice’s issuer account for 1000 USD (USD in, this case, being a Stellar token). Once done, Alice can send Bob 1000 of her own issued USD Stellar tokens.

Creating your first token

Now that we have some token basics out of the way let’s dive into creating your own tokens/assets with the Rehive Stellar Service. Most of the steps are done through the Rehive dashboard. First we will need a new Stellar account, which will be our issuer account. This is simply the account which other accounts will trust for the token you created. Use the same method for creating accounts as Part 1 in the series.

The basic structure for a token setup on Rehive involves an issuer account and the company hotwallet account. The issuer (in this case, the new account we created) will only ever send the token to the hotwallet and the hotwallet will act as the distribution account. The reason for this is to easily manage to the total supply of the token. Now onto the fun part.

On the Rehive dashboard, under the Stellar Service management section, browse to the assets page. Rehive uses asset as a general term for tokens, currencies etc. Creating a new Stellar token is as simple as:

  1. Clicking “Add asset” and entering the currency code for your asset (this should be a 3–12 all uppercase code).
  2. Entering the issuer account of the asset. This would be the public address of the Stellar account we created earlier.
  3. Click “Add”.

Done! You’ve now created a token on the Stellar network. Simple right? A few things happen in the background:

  1. A Rehive currency was created with the same currency code as the asset. This now means the Rehive ledger can track your token transactions.
  2. A Stellar transaction is broadcast from the company hotwallet account which creates a trustline between the hotwallet Stellar account and the issuer account.

Funding is just as simple as creating it. The hotwallet now trusts the issuer for the token but has no balance to transact with. To fund the hotwallet account click the “fund” button next to the new asset. Enter the amount you wish to send to the hotwallet (this can be seen as the initial supply or total supply of your new token) and the private key of the issuer account you created.

A few caveats and notes on what just happened when funding. The service uses the private key to sign and broadcast a transaction from the issuer account to the hotwallet for the desired value of your token. Normally, it is not recommended to enter your private keys anywhere so in general the above funding step should rather be done using a wallet of your choice by sending a transaction for X amount of your token to the public address of the company hotwallet account, the same way you would fund it with XLM.

Conclusion

If you’ve been following through each of the tutorials you should now have a company that is fully capable of transacting in both XLM and your newly created currency! Ready for any kind of fintech use case to be built on top of it.

I hope this guide as well as the series of guides has been useful. If you would like to know a little bit more about the lower level way tokens are created I recommend giving this a read. As always we would love to here about what you’ve decided to built with Stellar on Rehive feel free to drop by our public Slack to let us know or ask any questions.

Looking to get started? Get a quote here for a white label wallet on Stellar.

You can find more information here:

Rehive Website
Rehive Products
Rehive Docs
Rehive Dashboard
Rehive Wallet

--

--