Skip to main content
The stellar-cli can be used to issue and administer assets on the Stellar network. The following guide assumes that the stellar-cli has been configured to use testnet, or a local test network. To use testnet, run the following command.

Asset Issuance

To create a Stellar Asset using the stellar-cli several steps take place:
  • An issuer account must exist.
  • An asset code selected.
  • Optionally, an admin is configured.

Issuer Creation

To create an issuer, generate a key and fund it. Funding uses friendbot, the testnet faucet, and is only available on testnet.
View the public key with:
Configure the issuer key to be used for signing transactions:

Issuer Config

Issuer accounts have several configuration flags that can be toggled and affect all assets issued by the issuer. In this guide the issuer account will be setup with the revocable and clawback-enabled features will be enabled. These features allow the asset admin to revoke authorisation to use an asset, which has the effect of freezing their balance, and to clawback, which has the effect of forcibly burning the asset.
For other options, see the manual for the stellar tx new set-options command. To view the tx before sending, use the --build-only option and pipe the transaction through the tx edit command:

Choosing the Asset Code

Choose an asset code 1 to 12 characters long. The asset code along with the issuer account address will uniquely identify the asset. An issuer can issue multiple assets, distinguished by their asset code. For the rest of this guide the asset code ABC will be used.

Asset Contract Setup

A built-in contract exists on network for every asset. It’s address is reserved and can be calculated using the following command.
The contract is not deployed automatically. Anyone can deploy the contract, it is not an action requiring authorisation.

Contract Deployment

Deploy the built-in asset contract. The --asset option specifies the name of the asset, which is in the format <asset-code>:<asset-issuer>. The --alias option stores locally an alias that can be used in subsequent commands to reference the contract address.
Run the following command to get some read only data from the contract to confirm it’s deployed.

Admin Setup

At this point the issuer is the admin of the contract. Let’s create another account that’ll be the admin.
Using the issuer account, invoke the asset contract’s set_admin function.

Actions

Once the asset contract is deployed and setup, the following actions can take place.

Mint (Admin Only)

Generate and fund a user account that the minted asset will be transferred to.
Using the user account, trust the asset so that the user account can hold the asset.
To mint the asset to the user, use the admin account, invoke the asset contract’s mint function.
Check the balance after the mint.

Transfer

Generate and fund a second user account that the user account from the previous step can transfer the asset to.
Using the user2 account, trust the asset so that the new user account can hold the asset.
Using the user account, invoke the asset contract’s transfer function.
Check the balances after the transfer.

Burn

Using the user account, invoke the asset contract’s burn function.
Check the balance after the burn.

Revoke Authorization / Freeze (Admin Only)

An admin can revoke a user’s authorisation to use the asset. The user will continue to hold the balance but will be unable to transfer it or create new payments. Any existing liabilities, such as those created by offers created on Stellar, will continue to exist and could still be executed. Using the admin, invoke the asset contract’s set_authorized function.
Using the user account, invoke the asset contract’s transfer function. The invocation will fail because they are no longer authorized to transfer.
cookbooktest.fail

Clawback (Admin Only)

An admin can clawback a user’s balance. The amount clawed back will be burned. Using the admin, invoke the asset contract’s clawback function.
Check the balance after the clawback.