Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Tokens Overview (wayfinding) #570

Merged
merged 26 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ac5b8ea
Adding Tokens Overview (wayfinding)
briwylde08 May 13, 2024
41f8ba1
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
6e65323
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
649c8c5
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
5158160
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
2834b3f
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
d43691d
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
b992820
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 14, 2024
bad50ac
formatting
briwylde08 May 14, 2024
50b6cd4
more updates
briwylde08 May 14, 2024
60bfd21
update copy
briwylde08 May 14, 2024
f6e7984
couple nits
briwylde08 May 28, 2024
a3ef12a
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 30, 2024
1f90ba7
update wording
briwylde08 May 30, 2024
cc69f71
update note
briwylde08 May 30, 2024
17fe936
Merge branch 'token-wayfinding' of https://github.com/stellar/stellar…
briwylde08 May 30, 2024
e15efec
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 May 30, 2024
e0d1b06
G & C addresses
briwylde08 Jun 5, 2024
ffb0dca
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 Jun 11, 2024
c178bbb
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 Jun 11, 2024
fed26c6
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 Jun 11, 2024
9794710
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 Jun 11, 2024
b640c48
Update docs/smart-contracts/tokens/wayfinding.mdx
briwylde08 Jun 11, 2024
e4fed3e
wording
briwylde08 Jun 11, 2024
88de9c9
Merge branch 'token-wayfinding' of https://github.com/stellar/stellar…
briwylde08 Jun 11, 2024
dd227d2
formatting
briwylde08 Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
briwylde08 marked this conversation as resolved.
Show resolved Hide resolved

:::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.
briwylde08 marked this conversation as resolved.
Show resolved Hide resolved
- 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)
Loading