var img = document.createElement('img'); img.src = "https://terradocs.matomo.cloud//piwik.php?idsite=1&rec=1&url=https://docs.terra.money" + location.pathname; img.style = "border:0"; img.alt = "tracker"; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(img,s);
Skip to main content

Token Factory

ℹ️info

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:

Denoms
Copy

_2
factory/account1_address/mytoken
_2
factory/account2_address/mytoken

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./].

CreateDenom
Copy

_4
message MsgCreateDenom {
_4
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
_4
string subdenom = 2 [ (gogoproto.moretags) = "yaml:\"subdenom\"" ];
_4
}

  • 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.

Mint
Copy

_7
message MsgMint {
_7
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
_7
cosmos.base.v1beta1.Coin amount = 2 [
_7
(gogoproto.moretags) = "yaml:\"amount\"",
_7
(gogoproto.nullable) = false
_7
];
_7
}

  • 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.

Burn
Copy

_7
message MsgBurn {
_7
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
_7
cosmos.base.v1beta1.Coin amount = 2 [
_7
(gogoproto.moretags) = "yaml:\"amount\"",
_7
(gogoproto.nullable) = false
_7
];
_7
}

  • 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.

ChangeAdmin
Copy

_5
message MsgChangeAdmin {
_5
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
_5
string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
_5
string newAdmin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ];
_5
}

  • 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.

SetDenomMetadata
Copy

_7
message MsgSetDenomMetadata {
_7
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
_7
cosmos.bank.v1beta1.Metadata metadata = 2 [
_7
(gogoproto.moretags) = "yaml:\"metadata\"",
_7
(gogoproto.nullable) = false
_7
];
_7
}

  • 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

DenomCreationFee
Copy

_10
{
_10
"params": {
_10
"denom_creation_fee": [
_10
{
_10
"denom": "uluna",
_10
"amount": "10000000"
_10
}
_10
]
_10
}
_10
}

This fee is currently set to 10 Luna.