-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[docs] Coin registry #23750
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
Merged
Merged
[docs] Coin registry #23750
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
22da22f
AI doc
ronny-mysten f4bbb6f
Content updates and component fix
ronny-mysten 1ace2ee
Updates to content and plugin
ronny-mysten b723969
Delete ai doc
ronny-mysten b5fd016
feedback edits
ronny-mysten fea22d0
Merge branch 'main' into coin-reg
ronny-mysten 2c4046b
typo
ronny-mysten 84f7944
feedback
ronny-mysten 89615ca
Feedback
ronny-mysten 2e88494
Merge branch 'main' into coin-reg
ronny-mysten 7f28b61
Fixes false lint
ronny-mysten 18fd88d
nit
ronny-mysten 2677012
Apply suggestions from code review
ronny-mysten f8e1a60
style guide
ronny-mysten d69f115
fix link
ronny-mysten 1a50bd1
Apply suggestions from code review
ronny-mysten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
--- | ||
title: Coins | ||
description: Learn about creating, managing, and using coins on Sui, including regulated tokens, in-game currencies, and loyalty tokens. | ||
keywords: [ coin, coins, sui coin, regulated coin, in-game token, loyalty token, token design, tokenomics ] | ||
title: Currencies and Tokens | ||
description: Learn about creating and managing currencies and tokens on Sui using the Coin Registry system and `token` module, including regulated tokens, in-game currencies, and loyalty tokens. | ||
keywords: [ coin, coins, sui coin, regulated coin, in-game token, loyalty token, token design, tokenomics, coin registry, currency registry ] | ||
pagination_prev: null | ||
--- | ||
|
||
Learn how to design and implement coins on Sui. | ||
Learn how to design and implement currencies and tokens on Sui. | ||
|
||
<Cards> | ||
<Card title="Create Coins and Tokens" href="/guides/developer/coin"> | ||
<Card title="Create Currencies and Tokens" href="/guides/developer/currency"> | ||
Learn how to create currencies using the Coin Registry. | ||
</Card> | ||
<Card title="Regulated Coin and Deny List" href="/guides/developer/coin/regulated"> | ||
<Card title="Regulated Currency and Deny List" href="/guides/developer/coin/regulated"> | ||
Create regulated currencies with deny list capabilities. | ||
</Card> | ||
<Card title="In-Game Currency" href="/guides/developer/coin/in-game-token"> | ||
Use Closed-Loop Tokens for in-game currencies and restricted-use tokens. | ||
</Card> | ||
<Card title="Loyalty Tokens" href="/guides/developer/coin/loyalty"> | ||
Implement loyalty programs using the Closed-Loop Token standard. | ||
</Card> | ||
</Cards> |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,84 @@ | ||||||
--- | ||||||
title: Create Currencies and Tokens | ||||||
description: Learn how to create currencies and mint coins and tokens on the Sui network using the Coin Registry system. | ||||||
keywords: [ mint tokens, create tokens, use tokens, publish token, custom tokens, sui CLI, denylist, regulated coins, coin registry, currency registry ] | ||||||
pagination_prev: null | ||||||
--- | ||||||
|
||||||
The Coin Registry system provides a centralized approach to currency management through the `sui::coin_registry` module. The registry is a shared object located at address `0xc` that stores metadata, supply information, and regulatory status for all registered coin types. | ||||||
|
||||||
The `sui::token` module handles token creation on the network. Refer to the [Closed-Loop Token](/standards/closed-loop-token.mdx) and [Currency](/standards/currency.mdx) Standards documentation for more information on these features. | ||||||
|
||||||
### Currency creation process | ||||||
|
||||||
The registry system supports two currency creation methods: | ||||||
|
||||||
1. **Standard creation:** Call `new_currency<T>()` when creating the coin outside of the `init` function of your package. | ||||||
1. **OTW creation:** Use `new_currency_with_otw<T>()` with a One-Time Witness for uniqueness proof. | ||||||
|
||||||
Both methods return a `CurrencyInitializer<T>` that allows configuration before finalization: | ||||||
|
||||||
<details> | ||||||
<summary> | ||||||
Regular currency creation | ||||||
</summary> | ||||||
<ImportContent source="examples/move/coin/sources/non_otw_currency.move" mode="code" /> | ||||||
</details> | ||||||
|
||||||
<details> | ||||||
<summary> | ||||||
OTW currency creation | ||||||
</summary> | ||||||
<ImportContent source="examples/move/coin/sources/my_coin_new.move" mode="code" /> | ||||||
</details> | ||||||
|
||||||
The initialization process allows for: | ||||||
|
||||||
- **Supply model selection:** Choose fixed, burn-only, or flexible supply. | ||||||
- **Regulatory configuration:** Add deny list capabilities if needed. | ||||||
|
||||||
:::caution Important | ||||||
|
||||||
After initialization of a currency using the OTW method, you must call `finalize_registration` to create the shared `Currency` object that the Coin Registry can track. | ||||||
|
||||||
::: | ||||||
|
||||||
## `DenyList` | ||||||
|
||||||
The Sui framework provides a `DenyList` singleton, shared object that the bearer of a `DenyCapV2` can access to specify a list of addresses that are unable to use a Sui core type. The initial use case for `DenyList`, however, focuses on limiting access to coins of a specified type. This is useful, for example, when creating a regulated coin on Sui that requires the ability to block certain addresses from using it as inputs to transactions. Regulated coins on Sui satisfy any regulations that require the ability to prevent known bad actors from having access to those coins. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
:::info | ||||||
|
||||||
The `DenyList` object is a system object that has the address `0x403`. You cannot create it yourself. | ||||||
|
||||||
::: | ||||||
|
||||||
## Create regulated currency | ||||||
|
||||||
Use the `make_regulated()` function during the initialization phase before calling `finalize()`. This adds deny list capabilities to the `Currency<T>` and tracks the regulatory status within the registry system. | ||||||
|
||||||
<details> | ||||||
<summary> | ||||||
Regulated currency creation | ||||||
</summary> | ||||||
<ImportContent source="examples/move/coin/sources/regcoin_new.move" mode="code" /> | ||||||
</details> | ||||||
|
||||||
## Create tokens | ||||||
|
||||||
Tokens reuse the `TreasuryCap` defined in the `sui::coin` module and therefore have the same initialization process. The `coin::create_currency` function guarantees the uniqueness of the `TreasuryCap` and forces the creation of a `CoinMetadata` object. | ||||||
|
||||||
Coin-like functions perform the minting and burning of tokens. Both require the `TreasuryCap`: | ||||||
|
||||||
- `token::mint`: Mint a token | ||||||
- `token::burn`: Burn a token | ||||||
|
||||||
See [Closed-Loop Token](../../standards/closed-loop-token.mdx) standard for complete details of working with tokens. | ||||||
|
||||||
## Related links | ||||||
|
||||||
<RelatedLink to="/guides/developer/coin/regulated.mdx" /> | ||||||
<RelatedLink to="/guides/developer/coin/loyalty.mdx" /> | ||||||
<RelatedLink to="/guides/developer/coin/in-game-token.mdx" /> | ||||||
<RelatedLink to="/concepts/sui-move-concepts/derived-objects.mdx" /> | ||||||
<RelatedLink href="https://move-book.com/programmability/one-time-witness.html" label="One Time Witness" desc="The Move Book documentation of the one time witness pattern. " /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.