Stellar Assets Explained
When Bitcoin was presented in 2008 it showed that it was possible to have a decentralized and trustless currency. In the following decade we witnessed the rise of many different cryptocurrencies, each one with a different goal and philosophy.
While cryptocurrencies can differ greatly from each other, they can be divided into four groups:
- Cryptocurrencies/Payment Tokens: these tokens have no inherent value and are used as a medium of exchange on the network. Payment tokens are usually used to pay for network fees. Stellar Lumens are an example of cryptocurrency.
- Stablecoins: these are tokens that are backed 1:1 by another asset, usually a fiat currency held in a deposit account. Users trust the stablecoin issuer to exchange back the token for fiat currency. Coinbase USDC is an example of stablecoin, you can always redeem 1 USDC for 1$.
- Utility Tokens: these tokens are used to pay for a service. The Basic Attention Token (BAT) is a utility token used to obtain advertising-related services and it’s exchanged between users, publishers and advertisers.
- Security Tokens: these tokens represent ownership of an asset, for example a company or a property. This type of tokens are less common because securities are regulated in most countries and early stage companies (the most likely candidates for Initial Coin Offerings) don’t have the resources to comply with all the regulations.
Originally new tokens were created by forking an existing project and changing the protocol to meet the requirements. Ethereum revolutionized this process by letting users program smart contracts that behaved like currencies, later it was formalized in the ERC20 standard.
The Stellar Network supports non-native assets directly, letting users issue and exchange their different assets. In this blog post we begin by giving an high-level overview of Stellar Assets, compare them with ERC20 tokens, and finally delve into the technical details.
Native and Credit Assets
There are two types of assets on the Stellar network: the native asset and credit assets. The native asset, known as Stellar Lumens (or XLM), is the asset that’s used to pay transaction fees and as base reserve for the account. The supply of Lumens increases by 1% per year from inflation.
Credit assets have no inherent value, they can’t be used to pay for transaction fees, instead their value is given by the trust users have on the asset issuer. Assets are used mainly to issue stablecoins by anchors, but there are projects that use them for security and utility tokens. The supply of credit assets is up to the issuer account. A fixed supply can be created by distributing the initial supply amount and then locking the issuer account.
Since credit assets are based on the user trust of an issuer, users have to explicitly add a trustline to an issuer before they can use an asset. Usually this is done in a few clicks from the wallet software.
Credit assets have additional features compared to Lumens, making them suitable for more complex use-cases. As we discussed previously, securities are heavily regulated and for this reason security tokens should only be held by authorized users. Stellar includes a mechanism for issuers of security tokens to authorize who can hold their assets, making it possible to comply with Securities and KYC/AML regulations. Issuers can also freeze the assets held by another account.
Difference with Ethereum ERC20 Tokens
Ethereum is the most popular platform for ICOs. ICO on Ethereum involve creating an Ethereum smart contract (not to be confused with a Stellar Smart contract) that follows the ERC20 standard for tokens. This standard defines a common API for smart contract that enable users and issuers to:
- Retrieve basic information about the token (Name, symbol and total circulating supply)
- Get an account balance
- Transfer the token between accounts
- Set an allowance (allow an account to withdraw a predefined amount)
The ERC20 standard allowed the Ethereum ecosystem to grow by enabling wallets and exchanges to support a wide range of tokens.
Stellar assets are different because they are backed directly in the Stellar protocol. This is important because it means that assets are supported by all wallets, right from the beginning. Users can enable support for the most common assets on the network with only a few clicks. Non-native assets transactions are equal to Lumens transactions in everything and are handled in the same way by the network validators, thus they are as secure as native transactions. Finally, because they are part of the protocol, all assets are improved by updates that add new functionality or that improve security (without the headache caused by upgrading smart contracts).
At the core of Stellar assets there are trustlines. Trustlines are stored on the ledger, you can find them on Stellar Expert or, if you have access to stellar-core, you can explore the trustlines table.
A trustline contains the following information:
- AccountId: the account this trustline refers to
- Asset: the asset code and issuer of the trustline
- Limit: the limit for which the account trusts the issuing account
- Balance: the account current balance, in units of the asset
- Flags: contains the trustline flags, for example Authorize
- Buying Liabilities: this equals to the total amount the account is offering to buy. Buying liabilities plus balance must be less than the account limit, if you try to create a new offer that would put you above the limit you will receive a trustline full error
- Selling Liabilities: this equals to the total amount the account is offering to sell. Selling liabilities must be less than the account balance, otherwise you won’t be able to create a new sell offer
Anyone can issue assets on Stellar, all you have to do is pick an asset code and get users to trust you! After users have added the asset code and issuer account to their trustline, they can start receiving payments from the issuer.
As we mentioned earlier, sometimes an issuer may want to restrict who can hold its asset. To do this, it must:
- Submit a transaction to set the issuer account AUTHORIZATION REQUIRED flag
- Wait for users to add a trustline, users won’t be able to receive the asset yet since they are not authorized
- Authorize each individual user account by setting the trustline authorized flag to true
Bonus: Allowance in Stellar
As we have seen in the previous section, ERC20 tokens let users to set an allowance and let another account withdraw a predefined amount. In Stellar, this behaviour is let to the users and not the asset issuer. It is easy to create an allowance thanks to Stellar support for multi-signature accounts. If Alice wants to let Bob withdraw up to 100 XLM, all they have to do is to create a new account with 100 XLM in it and add Bob to the account signers. When Alice wants to increase the allowance, they will simply transfer more funds into the shared account. Likewise, Bob will transfer funds from the shared account to their account.
Originally published at https://www.lockerx.co.uk.