import { Callout } from "nextra/components"; import { HelpCallout } from "../../components";
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.
To create a token on the devnet, ensure you have the following setup:
- The
seid
CLI - A wallet with SEI tokens on devnet
seid tx tokenfactory create-denom $DENOM --from=$ACCOUNT --chain-id=arctic-1 --node=https://rpc.arctic-1.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.
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
.
When executing commands in this tutorial, you'll encounter several arguments. Here's a brief overview of what each means:
--chain-id=arctic-1
: This specifies the network where the command will be executed. In this case,arctic-1
is the identifier for the Sei devnet.--node=https://rpc.arctic-1.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. Theblock
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.When creating a token, it is important to specify details regarding the denom amounts and aliases so your token can be correctly parsed on wallets and explorers.
Create a token metadata json
file. The file below is an example metadata file for the Sei token.
{
"name": "sei",
"description": "The native token of Sei.",
"denom_units": [
{
"denom": "usei,
"exponent": 0,
"aliases": [
"microsei"
],
},
{
"denom": "msei",
"exponent": 3,
"aliases": [
"millisei"
]
},
{
"denom": "sei",
"exponent": 6,
}
],
"base": "usei",
"display": "sei",
}
The base
field denotes the smallest denom that this token can be represented in.
Note that if you intend to create a pointer contract, the denom_units
with the largest exponent will be used as the display denom. (sei
in this case).
seid tx tokenfactory set-denom-metadata $METADATA_FILE --fees 20000usei -b block -y --from $ADDR
Replace $METADATA_FILE
with the path to your metadata file created in step 1. and $ADDR
with the address of the token admin.
seid tx tokenfactory mint $AMOUNT --from=$ACCOUNT --chain-id=arctic-1 --node=https://rpc.arctic-1.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.
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=arctic-1 --node=https://rpc.arctic-1.seinetwork.io/
seid tx tokenfactory burn $AMOUNT --from=$ACCOUNT --chain-id=arctic-1 --node=https://rpc.arctic-1.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.
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.
To enable seamless use of this token in EVM environments, we can create a pointer contract. This process results in an ERC20 token that can be imported and used in EVM wallets and applications.
seid tx evm deploy-erc20 $DENOM $NAME $SYMBOL $DECIMAL --from=$ACCOUNT --evm-rpc=https://evm-rpc.arctic-1.seinetwork.io/
Parameters
DENOM
: The denomination of the token for which you want to create an ERC20 pointer. This should match the TokenFactory token you created.NAME
: The name you wish to assign to your ERC20 pointer token. It should match the name of the TokenFactory token.SYMBOL
: The symbol for your ERC20 pointer token. It should correspond with the symbol of the TokenFactory token.DECIMAL
: The number of decimals for your ERC20 pointer token. This should align with the decimals of the TokenFactory token (typically 6).
Flags
--from
: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.--evm-rpc
: The endpoint URL for the EVM RPC interface of the Sei blockchain. This URL is used by theseid
command to interact with the Sei EVM.
Executing this command creates an ERC20 token and outputs the contract address. This token is linked to the TokenFactory token, meaning any activities involving this ERC20 token will also reflect on the state of the TokenFactory token and vice versa.
Note that if you wish to specify denoms on your ERC20 tokens, you will need to set the token metadata for the base tokenfactory token. The denom with the largest exponent will be used.
Learn more about EVM interoperability and pointer contracts [here](../interoperability/overview.mdx).🎉 Congrats on completing the Token Factory tutorial! You've learned how to create, mint, and burn tokens on Sei using the tokenfactory
module.
For more advanced features and detailed insights, please refer to the Token Factory module documentation.