Skip to content

Commit

Permalink
Adding Tokens Overview (wayfinding) (#570)
Browse files Browse the repository at this point in the history
* Adding Tokens Overview (wayfinding)

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* formatting

* more updates

* update copy

* couple nits

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Jake Urban <10968980+JakeUrban@users.noreply.github.com>

* update wording

* update note

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* G & C addresses

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* Update docs/smart-contracts/tokens/wayfinding.mdx

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>

* wording

* formatting

---------

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
Co-authored-by: Jake Urban <10968980+JakeUrban@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 12, 2024
1 parent d479efa commit dd87e3d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/smart-contracts/tokens/stellar-asset-contract.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 20
sidebar_position: 10
title: Stellar Asset Contract
description: Use Stellar assets on Soroban.
---
Expand Down
2 changes: 1 addition & 1 deletion docs/smart-contracts/tokens/token-interface.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 20
title: Token Interface
description: The common interface implemented by tokens that are compatible with Soroban's built-in tokens.
---
Expand Down
80 changes: 80 additions & 0 deletions docs/smart-contracts/tokens/wayfinding.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
sidebar_position: 5
title: Tokens Overview
description: Choose between the Stellar Asset Contract and Custom Tokens
---

Tokens exist in two forms on Stellar:

1. Assets issued by Stellar accounts (G... addresses) and their built-in [Stellar Asset Contract (SAC)](./stellar-asset-contract.mdx) implementation, and
2. [Custom tokens](./token-interface.mdx) issued by a deployed WASM contract (C... addresses).

Several factors can help you determine whether to issue an asset on Stellar or create a custom token with a smart contract for your project.

However:

### TL;DR

If possible, we recommend issuing a Stellar asset and using the SAC to interact with that asset in smart contracts or to send to contract addresses. More on why below.

## Issuing assets on Stellar

Stellar has first-class support for asset tokenization — issuing an asset can be done using a [built-in transaction](https://developers.stellar.org/docs) without the development of a smart contract.

Stellar’s transactions are fast and cost-effective, making the network great for remittances and micropayments. It also has built-in features for compliance, asset management, and auditing. If you are looking to perform transfers of value, issuing assets on Stellar has all the needed capabilities.

Stellar assets:

- Are compatible with Stellar ecosystem products (such as Stellar wallets) and other ecosystem products (such as exchanges).
- Benefit from [anchors](../../learn/encyclopedia/anchors.mdx), the bridges between the Stellar network and traditional financial systems. Explore the global [Stellar anchor directory](https://anchors.stellar.org/) for further details.
- Give the issuer granular control over asset management with features that allow the issuer to [name the asset](../../issuing-assets/control-asset-access.mdx#naming-an-asset), [determine access control](../../issuing-assets/control-asset-access.mdx#controlling-access-to-an-asset-with-flags), [limit asset supply](../../issuing-assets/control-asset-access.mdx#limiting-the-supply-of-an-asset), [publish asset information](../../issuing-assets/publishing-asset-info.mdx), and [ensure compliance](../../issuing-assets/anatomy-of-an-asset.mdx#compliance).

:::note

Note that while these items are also possible with custom smart contract tokens, it is more work to build the token contract rather than using the already-implemented features of Stellar asset tokens.

:::

Assets issued on the Stellar network are accessible to smart contracts with the use of that asset’s Stellar Asset Contract (SAC).

### Stellar Asset Contract

The Stellar Asset Contract (SAC) is compiled into the protocol layer and allows smart contracts to interact with assets issued on Stellar. An instance of the SAC can be deployed for every Stellar asset by anyone who wants to interact with the asset from a contract. The SAC has access to all account balances (for XLM) and trustline balances (for all other assets) balances as well as smart contract token balances.

Read more about the SAC [here](./stellar-asset-contract.mdx).

Learn how to deploy a Stellar Asset Contract for an asset in [this How-To Guide](../../smart-contracts/guides/cli/deploy-stellar-asset-contract.mdx).

**Benefits of the SAC:**

- Compatibility: the SAC benefits from Stellar assets' existing interoperability.
- Cost and resource efficiency: the SAC is built into the protocol instead of being a contract that runs in a virtual machine. Each function within the SAC will be more resource-efficient than its custom-coded counterpart.
- Less work: you don’t have to write an entirely new contract. A Stellar asset’s SAC already exists on the network and just needs to be deployed to be used.
- Customization: Admin addresses can be contracts. Asset issuers can set a different smart contract as an admin for their asset’s SAC. Making the admin another smart contract allows the addition of custom and decentralized logic for the assets admin capabilities, such as authorizing balances and trust lines, minting tokens, etc.

**Downside of the SAC:**

- Other than the customization noted above, it is not possible to modify the behavior of Stellar assets or their SAC. If you’re looking to use assets in a way not supported by Stellar assets, you can create your own custom smart contract token using the token interface and all applications that interact with tokens using the token interface will be able to interact with the custom token.

## Custom tokens

If you have a unique use case where the capabilities Stellar Assets are not sufficient, you can create a custom token that implements the [token interface](./token-interface.mdx). The token interface specifies the functions and events a contract must implement to be compatible with applications that use tokens.

The SAC also implements the token interface and applications that interoperate with the token interface can seamlessly interact with Stellar assets and custom tokens.

:::note

Smart contracts cannot use Stellar assets unless that Stellar asset has a deployed SAC. Anyone can deploy the SAC for a Stellar asset to its reserved address.

:::

**These example scenarios are not possible with the SAC and demonstrate what you could use the token interface for:**

- As the creator of a new token, you decide to implement a feature within your custom token smart contract that enables you to receive a 1% fee from every transaction involving your token. Whenever someone transfers your token to another user, 1% of the transferred amount is automatically deducted and sent to a designated wallet address that you control.
- You want to develop a factory contract that automates the creation of instances of a specific token. This contract serves as a centralized and standardized way to deploy new token contracts on demand without manual intervention each time a new instance is needed.

## Helpful links

- [Issue an asset tutorial](../../issuing-assets/how-to-issue-an-asset.mdx)
- [Stellar Asset Contract](./stellar-asset-contract.mdx)
- [Token Interface](./token-interface.mdx)

0 comments on commit dd87e3d

Please sign in to comment.