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

up vote 15 down vote accepted

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
    Please add a brief summary of the current process. – Saya Jan 19 at 1:42

I created the following to help understand this.

Activity Diagram of Issuing a Custom Asset on Stellar

  • Hm, i have question. On #8 what do you mean Create and Fund, can u elaborate more.. thanks – Arman Ortega Jul 6 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. – Arman Ortega Jul 6 at 15:29

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

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
  • Using this commandline how does the distributor move the asset HAK to another account ? – Arman Ortega Jul 10 at 8:37
  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

protected by Orbit Lens May 25 at 17:09

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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