Back to Sui

Create Currencies and Tokens

docs/content/guides/developer/coin/currency.mdx

latest3.5 KB
Original Source

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 and Currency 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.
  2. OTW creation: Use new_currency_with_otw<T>() with a One-Time Witness for uniqueness proof.

:::caution Proper creation and RPC support requires a second transaction to promote the currency to the registry. :::

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 Proper creation and RPC support requires a second transaction to promote the currency to the registry.

After initialization of a currency using the OTW method, you must call coin_registry::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.

:::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 standard for complete details of working with tokens.