Skip to main content

Creating a Token

Overview​

Astroport pools accept native tokens (including tokenfactory denoms) and CW20 tokens. Terra and Neutron both run the tokenfactory module, which lets any account create a native token. Terra also supports CW20 tokens.

Once you've created your token, create a pool and seed liquidity.

Tokenfactory (Terra and Neutron)​

The tokenfactory module lets any account create a new token named factory/{creator address}/{subdenom}. Because denoms are namespaced by the creator's address, names can't collide and creation is permissionless. One account can create several denoms with different subdenoms. Subdenoms can contain [a-zA-Z0-9./].

The creator becomes the denom's admin and can:

  • Mint the denom
  • Burn the denom
  • Change the admin, or set it to an empty address so that nobody can mint or burn again
ChainCLIDenom creation fee
Terraterrad10 LUNA at the time of writing
Neutronneutrondnone at the time of writing

Check the current fee with the chain's /osmosis/tokenfactory/v1beta1/params LCD endpoint (denom_creation_fee).

NOTE

The commands below use Neutron. For Terra, replace neutrond with terrad, neutron-1 with phoenix-1, the node with a Terra RPC endpoint and the fee denom with uluna. See Network for endpoints.

Create a Denom​


_4
neutrond tx tokenfactory create-denom mytoken \
_4
--from mykey --chain-id neutron-1 \
_4
--node https://neutron-rpc.polkachu.com \
_4
--gas auto --gas-adjustment 1.4 --gas-prices 0.0053untrn

This creates factory/<your address>/mytoken.

Mint​

Only the denom's admin can mint. The amount is in base units: with 6 decimals, 1000000 is 1 token.


_4
neutrond tx tokenfactory mint 1000000factory/neutron1...creator/mytoken \
_4
--from mykey --chain-id neutron-1 \
_4
--node https://neutron-rpc.polkachu.com \
_4
--gas auto --gas-adjustment 1.4 --gas-prices 0.0053untrn

Minted tokens go to the admin's account. Send them on with a normal bank send.

Burn​

Only the denom's admin can burn.


_4
neutrond tx tokenfactory burn 1000000factory/neutron1...creator/mytoken \
_4
--from mykey --chain-id neutron-1 \
_4
--node https://neutron-rpc.polkachu.com \
_4
--gas auto --gas-adjustment 1.4 --gas-prices 0.0053untrn

Change the Admin​


_4
neutrond tx tokenfactory change-admin factory/neutron1...creator/mytoken neutron1...newadmin \
_4
--from mykey --chain-id neutron-1 \
_4
--node https://neutron-rpc.polkachu.com \
_4
--gas auto --gas-adjustment 1.4 --gas-prices 0.0053untrn

The new admin can mint, burn and change the admin.

Using the Token in a Pool​

In Astroport messages a tokenfactory denom is a native token:


_5
{
_5
"native_token": {
_5
"denom": "factory/neutron1...creator/mytoken"
_5
}
_5
}

Stableswap and PCL pools need the token's decimals from the native coin registry. Register them before creating such a pool (see Creating a Pair).

CW20 Tokens (Terra)​

On Terra you can also deploy a CW20 token by instantiating a cw20-base contract (see the CW20 spec). In Astroport messages a CW20 token is written as:


_5
{
_5
"token": {
_5
"contract_addr": "terra1...token"
_5
}
_5
}

CW20 tokens need an increase_allowance before you provide liquidity, and are swapped with a CW20 send (see Swapping).