Quickstart
Token Factory Tutorial

Token Factory Tutorial

The tokenfactory module enables any account to create new tokens with a unique identifier based on the creator's address. Each account can generate multiple tokens by specifying distinct denoms. The token creator is granted "admin" privileges, allowing them to mint, burn, and transfer their token.

These tokens are named factory/{CREATOR_ADDRESS}/{DENOM} and come with a range of native functionalities.

Requirements

To create a token on the testnet, ensure you have the following setup:

  • The seid CLI
  • A wallet with SEI tokens on testnet

You can obtain testnet tokens from one of the faucets listed here.

Creating a Denom

seid tx tokenfactory create-denom $DENOM --from=$ACCOUNT --chain-id=atlantic-2 --node=https://rpc.atlantic-2.seinetwork.io/ --broadcast-mode=block --fees=20000usei

This command creates a new coin with the format factory/{ACCOUNT}/{DENOM}. Replace $DENOM with your desired denom name and $ACCOUNT with your account name. The account specified here will be the token admin.

💡

Simplify your tutorial experience by setting the $DENOM and $ACCOUNT variables in your terminal. This allows you to easily refer to these variables throughout the tutorial.

For instance, to set a denom called solid and use the account name of your choice, use the following commands:

DENOM=solid
ACCOUNT=your_account_name

Replace your_account_name with the actual name of your account. Once set, you can refer to these values throughout the session using $DENOM and $ACCOUNT.

Understanding Command Line Arguments

When executing commands in this tutorial, you'll encounter several arguments. Here's a brief overview of what each means:

  • --chain-id=atlantic-2: This specifies the network where the command will be executed. In this case, atlantic-2 is the identifier for the Sei testnet.
  • --node=https://rpc.atlantic-2.seinetwork.io/: This points to the RPC URL of the node you are interacting with.
  • --broadcast-mode=block: This determines how your transaction is broadcasted to the network. The block mode means the transaction will wait to be included in a block before returning a response. This is a safer option as it confirms your transaction is processed.
  • --fees=20000usei: This is used to specify the transaction fee.

Understanding these arguments will help you execute the commands more confidently and customize them as needed for different scenarios.

For detailed descriptions of these arguments, use seid help in the CLI.

Minting Tokens

seid tx tokenfactory mint $AMOUNT --from=$ACCOUNT --chain-id=atlantic-2 --node=https://rpc.atlantic-2.seinetwork.io/ --broadcast-mode=block --fees=20000usei

This command will create (mint) a specific $AMOUNT of your new token. Replace $AMOUNT with the number of tokens you want to mint, followed by the token denom generated from the previous command.

💡

For instance, if you would like to mint 1M tokens, you should input 1000000factory/{ACCOUNT}/{DENOM} as amount. Or you could set a new variable for the amount:

AMOUNT=1000000factory/${ACCOUNT}/${DENOM}

To verify that the tokens have been minted, query the balance of your account:

seid query bank balances $ACCOUNT --chain-id=atlantic-2 --node=https://rpc.atlantic-2.seinetwork.io/

Burning Tokens

seid tx tokenfactory burn $AMOUNT --from=$ACCOUNT --chain-id=atlantic-2 --node=https://rpc.atlantic-2.seinetwork.io/ --broadcast-mode=block --fees=20000usei

This command allows you to burn a specific amount of your tokens, reducing the total supply. To use it, replace $AMOUNT with the number of tokens you wish to destroy.

💡

For instance, to burn 100 tokens, you should input 100factory/{ACCOUNT}/{DENOM}. Ensure that you substitute {ACCOUNT} and {DENOM} with your actual account address and token denomination, respectively. Or update the variable:

AMOUNT=100factory/${ACCOUNT}/${DENOM}

Only the token admin has permission to mint and burn tokens. If necessary, you can reassign these privileges by using the change-admin command to designate a new admin.

Next Steps

🎉 Congrats on completing the Token Factory tutorial! You've learned how to create, mint, and burn tokens on Sei using the tokenfactory module.

💡

Smart contracts can also create TokenFactory denoms and act as token admins, allowing for more complex and automated token management strategies.

For more advanced features and detailed insights, please refer to the Token Factory module documentation (opens in a new tab).