Creating, Minting, and Interacting with a Token Factory Token
The Token Factory module provides a simple framework for creating and managing custom native tokens. It allows users to create, mint, distribute and interact with their own tokens seamlessly. Each token is uniquely tied to its creator’s address and follows the standardized format factory/{creator address}/{subdenom}.
The module is particularly useful for developers and projects looking to issue chain-native assets without the complexity of deploying custom smart contracts. Regardless of the token’s intended use the Token Factory streamlines the entire lifecycle, ensuring a secure and scalable approach to token management on XION.
Prerequisites
Before proceeding, make sure you have the following:
XION Daemon (
xiond
) Installed: Ensure thatxiond
is installed on your system. If not, follow the Setting up your Local Development Environment guide to set it up.An Active Account: Set up an account using
xiond
by following the Generate an account guide. You will use this account to execute transactions.A Funded Account: You need an account with sufficient native XION tokens to cover transaction fees. You can obtain testnet tokens through the XION testnet faucet.
Creating a Token
To create a new token using the Token Factory module, you would execute the following command:
Parameters:
<your-denom>
– The unique token name (e.g.,customtoken
).<wallet-name>
– Your configured wallet name inxiond
.<chain-id>
– The chain ID of the XION network.<node>
– The ID or address of the blockchain node you are connecting to.--gas auto
– Automatically estimates the gas required for the transaction.<gas-adjustment>
– Adjusts the estimated gas amount by 30% to account for possible variations in actual consumption.<gas-prices>
– The fee rate for gas in uxion (the smallest unit of XION).
Example:
The following is an example of the initial output:
After typing y and pressing Enter, you may see the following output:
Upon successful execution, a unique token will be created with a denomination formatted as:
Querying Token Data
After creating a token, you may want to verify its metadata and check its initial state on the blockchain. This can be done using the denom-metadata query within the bank module, which retrieves essential details about the token, including its base denomination, display name, and symbol.
To query the token data, run the following command:
Example:
Example Output:
Understanding the Output:
base
– The full unique identifier of the token.denom_units
– The denomination structure for different decimal representations.display
– The default way the token is displayed in applications.name
– The registered name of the token.symbol
– The token’s ticker symbol (if set during metadata configuration).
Updating Token Metadata
Before minting new tokens, it is important to configure the token’s metadata to ensure frontends and dapps can properly query and display token information and to set the required decimal precision to be used by the token.
Updatable Fields:
ticker-symbol
– The short symbol representing the token (e.g.,XION
).description
– A brief description of the token.exponent
– The decimal precision used for display purposes.
To update the token metadata, run the following command:
Example:
This command updates the metadata for the mytoken
token, setting:
Ticker Symbol →
MYT
Description →
"My custom token"
Exponent →
6
(indicating 6 decimal places for display)
The following is an example of the initial output:
After typing y and pressing Enter, you may see the following output:
You can then query the metadata to see the updates:
Possible Output:
Minting Tokens
After successfully creating your token, you will notice that no tokens have actually been minted. To establish or increase the token supply, you must explicitly mint new tokens. The minting process allows you to generate additional tokens under your control, which can then be used within your dapps, or distributed to other accounts.
To mint tokens, execute the following command:
Parameters:
<amount>
– The quantity of tokens to mint.<denom>
– The full denomination (includingfactory/<creator-address>/<denom>
).<wallet-name>
– Your configured wallet name.<chain-id>
– The chain ID of the XION network.<node>
– The ID or address of the blockchain node you are connecting to.--gas auto
– Automatically estimates the gas required for the transaction.<gas-adjustment>
– Adjusts the estimated gas amount by 30% to account for possible variations in actual consumption.<gas-prices>
– The fee rate for gas in uxion (the smallest unit of XION).
Example:
The following is an example of the initial output:
After typing y and pressing Enter, you may see the following output:
If your exponent was set to 6, then 1000000000000
would mint 1 million mytoken
tokens since the exponent determines how many decimal places the token uses.
Querying Token Balance
Once you have minted or received tokens, you may want to check your wallet’s balance to see the amount of native XION, custom tokens, and IBC-transferred assets you hold. The bank balance query allows you to retrieve a complete breakdown of all tokens associated with your address.
To check the token balances for an account execute:
Example:
The following is an example of the output, with factory/xion1ka5gdcv4m7kfzxkllapqdflenwe0fv8ftm357r/emp
as the custom token:
Sending Tokens to Another Address
Once you have minted tokens, you may want to transfer them to another wallet, whether for payments, rewards, or distribution to users. The bank send transaction allows you to send your custom tokens (or any other assets in your wallet) to another address on the XION blockchain.
To send tokens, use the following command:
Parameter Breakdown:
<your-address>
– The sender’s wallet address.<recipient-address>
– The recipient’s wallet address.<amount>
– The number of tokens to send.<denom>
– The full token denomination, including thefactory/{creator-address}/{denom}
prefix.<node>
– The RPC node used to broadcast the transaction.<wallet-name>
– The name of your configured wallet inxiond
.<chain-id>
– The XION network’s chain ID.--gas auto
– Enables automatic gas estimation.<gas-adjustment>
– Adjusts the estimated gas usage (e.g.,1.5
for 50% buffer).<gas-prices>
– Sets the gas fee rate inuxion
.
Example: Sending 500 mytoken
Tokens
mytoken
TokensWhat Happens?
This transfers 500
mytoken
tokens from the sender (xion1ka5...
) to the recipient (xion193h...
).The transaction is broadcasted to the network via the specified RPC node.
If successful, the recipient’s balance is updated, and the sender’s balance is reduced accordingly.
You have successfully created, updated, minted and transferred a token using the XION Token Factory module. With this foundation, you can now integrate your token into your smart contracts and dApp frontends seamlessly.
Last updated
Was this helpful?