If you’d like to interact with an asset issued on the Stellar network in smart contracts, you can create or deploy the Stellar Asset Contract for that asset.
Prerequisites
You must ensure you have the required amount of XLM to create your issuing and distribution accounts and cover the minimum balance and transaction fees. If you’re issuing an asset on the testnet, you can fund your account by getting test XLM from friendbot. If you’re issuing an asset in production, you will need to acquire XLM from another wallet or exchange. If you’d like to avoid your users having to deal with transaction fees, consider using fee-bump transactions. Read more in our Fee-Bump Transaction Guide. Learn about the testnet and mainnet in our Networks section. Learn more about fees in our Fees, Resource Limits, and Metering section.Foundational tools
Issuer account keypair
First, you must generate a unique keypair. The public key will act as your issuing identity on the network, while you use the secret key to sign transactions.Your account address will not change once you issue your asset, even if you modify its signers. Many issuers employ vanity public keys related to their asset. For instance, you might configure a custom signer in base32 like
GASTRO...USD.Many users secure their issuing account with cold storage techniques, such as a hardware wallet or multisignature setup. This adds an extra layer of protection by keeping your secret key offline or requiring multiple approvals for transactions.
Distribution account keypair
Your asset can be issued and transferred between accounts through a payment, contract, or claimable balance. Although it is not required to create a distribution account, it is best practice, so we will do so in this example. Read more in our Issuing and Distribution Accounts section.Three Operations
Generate a new keypair
Import an existing keypair
Employ multiple signatures
Local asset object
The asset object is a combination of your code and your issuing public key. After your issuance, anyone can search the network for your unique asset.While anyone can create an asset, there may be real-world compliance implications relevant to your use case.
You’ll want to make sure you publish information about your asset to establish trust with your users and prevent errors. Learn how to do so with our Publish Information About Your Asset section.
Network transactions
These examples read accounts from and submit transactions to Stellar RPC. RPC takes a transaction and answers immediately with the statusPENDING, so you then poll for the final result. See sendTransaction and getTransaction.
Build transaction to establish distributor trustline
Accounts must establish a trustline with the issuing account to hold that issuer’s asset. This is true for all assets except for the network’s native token, Lumens.If you’d like to avoid your users having to deal with trustlines or XLM, consider using sponsored reserves. Read more in our Sponsored Reserves guide.
Issuer payment to distributor
Payments are the most popular operation to actually issue (or mint) your asset, compared to other issuances. A payment creates the amount of an asset specified, up to the maximum 64-bit integer. Relevantly, you do not need to scale up the issuing amount of your asset by the XDR minimum increment.You can also create a market directly from the issuing account and issue tokens via trading.
Optional transactions
Configure maximum supply
This section details how to lock your account with the purpose of limiting the supply of your issued asset. However, locking your account means you’ll never be able to do anything with it ever again—whether that’s adjusting signers, changing the home domain, claiming any held XLM, or any other operation. Your account will be completely frozen.