Token Factory
This tokenfactory module allows any account to create a new token with the name factory/{creator address}/{subdenom}. Because tokens are namespaced by creator address, this allows token minting to be permissionless, due to not needing to resolve name collisions.
Note: If you want your denom to be visible on products like Helix, Hub, Explorer, etc, it's important to add token metadata information using the MsgSetDenomMetadata message as explained below.
Note #2: It's recommended to change your admin to the zero address for safety and preventing supply manipulation.
Messages
Let's explore (and provide examples) the Messages that the TokenFactory module exports and we can use to interact with the Injective chain.
MsgCreateDenom
Creates a denom of factory/{creator address}/{subdenom} given the denom creator address and the subdenom. Subdenoms can contain [a-zA-Z0-9./]. Keep in mind that there is a creation fee which you need to cover when creating a new token.
Keep in mind that that the admin of the token can change the supply (mint or burn new tokens). Its recommended that the admin is unset using the MsgChangeAdmin, as explained below.
import { Network } from "@injectivelabs/networks";
import { MsgCreateDenom } from "@injectivelabs/sdk-ts";
const injectiveAddress = "inj1...";
const privateKey = "0x...";
const subdenom = "inj-test";
const msg = MsgCreateDenom.fromJSON({
subdenom,
symbol: "InjTest",
name: "Inj Testing",
sender: injectiveAddress,
});
const txHash = await new MsgBroadcasterWithPk({
privateKey,
network: Network.Testnet,
}).broadcast({
msgs: msg,
});
console.log(txHash);MsgMint
Minting of a specific denom is only allowed for the current admin. Note, the current admin is defaulted to the creator of the denom.
MsgBurn
The admin can burn the supply of the token factory. Everyone else can use this message to burn their funds only.
MsgSetDenomMetadata
Setting of metadata for a specific denom is only allowed for the admin of the denom. It allows the overwriting of the denom metadata in the bank module.
MsgChangeAdmin
The admin of the denom can mint new supply or burn existing one. It's recommended to change the admin to the zero address as to not allow changing the token's supply.
Full Example
Here is a full example on how to create a new token, mint new tokens and set token metadata on Injective.
Last updated
