4 : Issue and Mint Asset in Stellar.
Last updated
Last updated
Check this guide in
Edit this guide in it's repo:
Contribute to this guide in the of the repo
In this chapter we will show you how to issue (create) a Stellar Asset (classic) and mint the the first supply of it.
To issue and mint an asset you need to build and submit two transactions. The first one will to create a trustline for the asset between receiver and issuer address, this is a requirement. The second one will send a payment of the asset from issuer to receiver that effectivaly **will create and mint the asset by sending it+*.
Remember to follow the code in the . Also, you can clone the code by doing
Previous to the creation of the asset, the destination address is required to submit a transaction to the network that creates a trustline with the asset. In Stellar, this is a requirement to establish a trustline before receiving an asset that has not been received before.
Read more about trustlines in the
The transaction that will creates the trustline need to contains an operation Change Trust
where the fields asset
(asset code and issuer address) is required and the field trust limit
is optional.
You can check the full code of this playground, on how to build build and submit this trust operation
Here we show you a fragment of this code, using the javascript StellarSdk
package:
Once the destination address trust the asset, the issuer can create it. Issuing the asset consist in building and submit a transaction that contains a payment operation. The payment operation requires to set up the asset code
,the issuer adress
and the amount
. This payment will create the token and mint the amount that the issuer sends to destination address.
Here we show you a fragment of this code, using the javascript StellarSdk
package:
Here a fragment of this code:
In the case the issuer addres is not locked, new amount of the asset can be minted. To mint the asset is as easy as create a new transanction with a payment operation. This operation will mint the asset incrementing the total supply of the asset.
You can run it by:
Also you can run it with a different asset code than the one in settings.json by passing it the ASSET_CODE
argument.
As we have showed above you can pass the asset code as an argument when invoking the script.
You can check the full code of this playground, on how to build build and submit the transaction with a payment operation
If you want to use our code, we prepared the script that can be called by the soroban-preview-10
docker container:
This script will send two transactions to the stellar futurenet or standalone chains, depend on your selection when launching .
This script will take the asset, issuer adress, receiver address, amount, network passphrase and limit amount allowed to be received by receiver address from the file.
In the we will use this docker containers in order to get info about the asset created in the current chapter
This Playground has been developed by in collaboration with from