Token Factory
The Token Factory module is an open-source module created by the Osmosis team. This document is a stub and mainly covers Terra-specific notes on how it is used. Visit the original documentation for more information.
The Token Factory module allows any account to create a new token with a specific naming convention: factory/{creator address}/{subdenom}
. This design ensures that token minting is permissionless as it doesn't require resolving name collisions. The creator of a token automatically receives "admin" privileges, which enable them to mint, burn, transfer tokens, and change the admin of the token. The ChangeAdmin functionality enables changing the master admin account or even removing admin privileges entirely. Admins can also share privileges with others using the authz module. Assets created using the Token Factory module are recognized by the Bank module as native assets.
Naming conflicts
A naming conflict refers to the potential issue of having two or more tokens with the same name (or denomination), which can lead to confusion.
To avoid naming conflicts, the Token Factory module implements a unique naming structure for tokens that includes the creator's address in the token's name: factory/{creator address}/{subdenom}
. By namespacing tokens using the creator's address, the module ensures that each token created by an account has a unique identifier, even if different accounts create tokens with the same subdenomination. This approach prevents naming conflicts, allowing for a permissionless token creation process.
For example, if two accounts create tokens with the subdenomination mytoken
, the resulting denominations would be different due to the inclusion of their respective creator addresses:
As a result, even though both tokens share the same subdenomination, they remain distinct and easily identifiable.
Messages
CreateDenom
Creates a denom with the factory/{creator address}/{subdenom}
naming convention. Subdenoms can contain [a-zA-Z0-9./]
.
- Each denom creation requires a fee, set in the module parameters. This creation fee is sent to the community pool.
- The bank keeper sets the
DenomMetaData
. - The
AuthorityMetadata
of the denom is stored and is automatically set as the sender of the message. - The denom is added to the
CreatorPrefixStore
, where a set of denoms per creator is kept.
Mint
Minting can only be executed by the current admin of the denom, which by default is the creator.
- The module checks that the denom being used is a Token Factory denom.
- The sender of the message must be the admin of the denom.
- The specified mint amount is minted via the bank module.
Burn
Burning can only be executed by the admin of the denom, which by default is the creator.
- The module checks that the denom being used is a Token Factory denom.
- The sender of the message must be the admin of the denom.
- The specified burn amount is burned via the bank module.
ChangeAdmin
Changing the admin of a denom can only be executed by the current admin.
- The sender of this message must be the admin.
- Modifies
AuthorityMetadata
state entry to change the admin of the denom
SetDenomMetadata
Setting the metadata of a denom can only be executed by the current admin. This action will overwrite the metadata in the bank module.
- The sender of this message must be the admin.
- Updates the
DenomMetaData
via bank keeper.
Parameters
The following parameter is set for the Token Factory module at genesis and can be updated via governance.
Denom creation fee
The DenomCreationFee
parameter determines the fee required to create a new token denomination in the token factory module.
Current value:
https://phoenix-lcd.terra.dev/osmosis/tokenfactory/v1beta1/params
This fee is currently set to 10 Luna.