Skip to main content

In-Game Currencies

Using the Sui Closed-Loop Token standard, you can create in-game currencies. These might be in the form of in-game assets such as gems and diamonds that you can grant to players for their actions or make available for purchase. You mint the currency on Sui, but players can only use the currency within the economy of the game itself. You typically mint them in predefined amounts to maintain scarcity and the game economy.

This example implements a governance-controlled currency in Move. Transferring the currency requires an approval, which is implemented using custom rule logic. The currency in this example is called King Credits, and it can only be transferred with approval from the Crown Council.

Initialize the currency​

To create the King Credits currency, initialize the currency using the coin::create_currency module and configure the currency policy with token::add_rule_for_action:

info

init functions run only during the package publish event.

Set custom transfer rules​

In another Move package, implement the add_rule_config function to initialize the rule configuration with initial council members and set a limit on the maximum number of members, including a check to ensure the count does not exceed that maximum.

The add_council_member and remove_council_member functions add and remove members from the council. The prove function checks whether the request sender is a council member and adds an approval for the rule if they are:

View the full example on GitHub.