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.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.--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 codeABC 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.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.
Admin Setup
At this point the issuer is the admin of the contract. Let’s create another account that’ll be the admin.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.mint function.
Transfer
Generate and fund a second user account that the user account from the previous step can transfer the asset to.transfer function.
Burn
Using the user account, invoke the asset contract’sburn function.
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’sset_authorized function.
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’sclawback function.