23

How does one go about creating tokens on the Stellar network?

5 Answers 5

17

It's explained in Issuing Assets article in developer's portal.

The process looks like this:

  1. Create an issuing account (let's call it account A)
  2. From any other account (let's call it B) create a trust line by sending change_trust operation. The asset value should have the code of the asset you want to issue (ex. TOKEN) and issuer should be equal the account A from point 1.
  3. Now any payment from A to B sending a custom asset equal to the asset from a trust line from point 2 will create a new asset in the network.

Optionally you can setup another account as the holding or distributor account and have this account make payments and offers involving the asset.

This way the issuer account can be locked away in cold storage so no more tokens can be created without physical access.

1
  • 1
    Please add a brief summary of the current process.
    – manjuu5
    Jan 19, 2018 at 1:42
4

I created the following to help understand this.

Activity Diagram of Issuing a Custom Asset on Stellar

3
  • Hm, i have question. On #8 what do you mean Create and Fund, can u elaborate more.. thanks Jul 6, 2018 at 14:31
  • In addition to my question sir, when Distributor send payment operation to Wonderer B, Wonderer C. They will both receive a ROCKT asset. But the Distributor account his/her ROCKT will get decremented or remained as is? thanks. Jul 6, 2018 at 15:29
  • @ArmanOrtega sorry missed your comments #8 create and fund was from a side project and not relevant. It was about sending many accounts some portion of the ROCKT. Yes when the Distributor makes a transfer, her account balance will be decremented.
    – swidnikk
    Jan 17, 2019 at 21:54
4

https://stellar.army - see second tab. The code is also opensourced, see the github link on top right.

2

Note that you can do this on the commandline using Lumen. Here's an example to create the HAK token on the testnet.

# Create accounts for issuer and distributor
$ lumen account new issuer
$ lumen account new distributor

$ lumen friendbot issuer
$ lumen friendbot distributor

# Create a trustline from distributor to the HAK token, issued by issuer.
$ lumen trust create distributor HAK:issuer

# Distribute 1000 HAK tokens
$ lumen pay 1000 HAK:issuer --from issuer --to distributor

# Kill the issuer's account so no more HAK tokens can be created.
$ lumen signer masterweight issuer 0

# The distributor is now free to distribute 1000 HAKs
$ lumen balance distributor HAK:issuer
# Output: 1000.0000000
1
  • Using this commandline how does the distributor move the asset HAK to another account ? Jul 10, 2018 at 8:37
0
  1. create accounts from here
  2. fund them from friendbot here
  3. make one account as issuer by issuing asset

var assetName = 'testAsset'; var testAsset = new StellarSdk.Asset(assetName, issuerPublicKey);

  1. changeTrust operation.

//accounts.secret = secretkey of any account other than issuer to get trusted for testAsset var receivingKeys = StellarSdk.Keypair .fromSecret(accounts.secret); server.loadAccount(receivingKeys.publicKey()) .then(function (receiver) { var transaction = new StellarSdk.TransactionBuilder(receiver) // The changeTrust operation creates (or alters) a trustline // The limit parameter below is optional .addOperation(StellarSdk.Operation.changeTrust({ asset: testAsset, limit: '1000' })) .build(); transaction.sign(receivingKeys); server.submitTransaction(transaction);

  1. do step (4) for 2 accounts

  2. fund these accounts with testAsset using issuer account

app.get('/transferTestAsset', async function (req, res) { var amt = '100'; var sourceSecretKey = issuerSecretKey; // seed of acc from which tx process var sourcePublicKey = sourceKeypair.publicKey();//pub key of source acc var receiverPublicKey = account5.publicKey;// public key of reciever acc StellarSdk.Network.useTestNetwork(); const account = await server.loadAccount(sourcePublicKey) var transaction = new StellarSdk.TransactionBuilder(account) .addOperation(StellarSdk.Operation.payment({ destination: receiverPublicKey, asset: testAsset,//native asset lumen amount: amt, })) .addMemo(StellarSdk.Memo.text('coins sent testAsset'))//optional .build(); transaction.sign(sourceKeypair); console.log('tx signed'); const temp = await server.submitTransaction(transaction) });

  1. now do step 6 for accounts other than issuer , accounts which trusted the issuers testAsset can recieve the testAsset

  2. go to here and check the transactions

1
  • please format my answer unable to do it Dec 5, 2018 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.