Cover image for #52 | Creating Fungible, IBC-Compatible Tokens on Nibiru

#52 | Creating Fungible, IBC-Compatible Tokens on Nibiru

· 3 min read

Nibiru's Token Factory streamlines the creation of fungible tokens, which are essential for decentralized finance (DeFi), asset tokenization, and governance systems. It offers a robust, user-friendly, IBC compatible, and secure alternative to traditional token creation methods.

Fungibility: Coins versus NFTs

Fungible tokens are equivalent and interchangeable digital assets. These includes familiar tokens like NIBI, ETH, fiat currencies like KRW and USD, and quantifiable voting rights. Non-fungible tokens are distinct and unique and uses to represent items like collectibles, licenses, or deeds of ownership.

Coins as Fungible Tokens on Nibiru

The "Coin " is the main standard for fungible tokens on Nibiru. Coins are quite simple and described by two pieces of information: a denomination and an amount. A coin denomination, or coin denom for short, is a unique identifier for the asset to be understood by the Nibiru blockchain. For example, NIBI tokens have coin denom "unibi".

  • Smart Contract Support: All smart contracts on Nibiru can hold or receive coins. Special contract logic is not needed to enable protocol.
  • Wallet Compatibility: Coins are compatible with a wide range of wallets and decentralized applications within the IBC ecosystem.
  • Multi-Chain Compatibility: Coins are a multi-chain standard. They have bridge and IBC support by default. Coins can only be created by the Bank Module on Nibiru, which is essentially an ownerless contract that can mint or burn tokens and manages all transfers of coins.

Coin Creation with Token Factory

The Token Factory Module (x/tokenfactory) on Nibiru offers a controlled environment for the creation of new coins, enabling any account to create native fungible tokens.

Since a coin denomination is the official identifier for an asset in the blockchain state, denoms cannot be selected freely. Otherwise, people would freely mint digital assets and potential misuse the namespaces of certain coin denominations. To avoid this problem, Token Factory coins use namespaces corresponding to the address of the account that created them.

Coins created through x/tokenfactory are prefixed with tf, similar to how IBC assets are prefixed with ibc. This prefixing prevents namespace collisions.

protobuf// TFDenom: A token factory denominationmessage TFDenom { // Creator: Bech32 address of the creator of the denom. string creator = 1; // Subdenom: Unique suffix of a token factory denom. A subdenom is specific // to a given creator. It is the name given during a token factory "Mint". string subdenom = 2;}

TFDenom is a protobuf struct for a x/tokenfactory denomination. It is represented as "tf/{creator}/{subdenom}" on chain, uniquely identifying a coin denom within the Bank Module.

Building Custom Smart Contract Tokens

To customize the logic for creating denominations, developers can rely on nibiru-tokenfactory contract from the Nibiru Rust repository (cw-nibiru).

This contract can be customized to match developer specifications and then deployed like any other Wasm smart contract on the Nibiru blockchain. The quick-start guide to get developers started can be found in Nibi-Stargate Smart Contract in Nibiru For Dev docs.

Minting Simple Tokens with the Nibiru CLI

Using the Nibiru CLI (nibid), token creation is made simple and permissionless via the x/tokenfactory module. Operations like creating denoms, minting, burning and changing admins are all possible.

Creating a Coin Denomination:

bashnibid tx tf create-denom <subdenom> \ --from <creator-address> \ --gas auto \ --gas-adjustment 1.5 \ --gas-prices 0.025unibi \ -y | jq

Minting:

bashCOIN="<amount>tf/<creator-address>/<subdenom>"
nibid tx tf mint $COIN \    --from <creator-address> \    --mint-to <receipient> \    --gas auto \    --gas-adjustment 1.5 \    --gas-prices 0.025unibi \    -y | jq

For Burning:

bashCOIN="<amount>tf/<creator-address>/<subdenom>"
nibid tx tf burn $COIN \  --from <creator-address> \  --burn-from <address-to-burn-from> \  --gas auto \  --gas-adjustment 1.5 \  --gas-prices 0.025unibi \  -y | jq

For a step-by-step guide, follow our Token Factory guide (Nibiru CLI).

References

About Nibiru

Nibiru is at the forefront of Web3 by integrating applications and platforms into a unified experience. Nibiru is a unique and innovative Layer1 blockchain distinguished by its robust smart contract ecosystem offering superior throughput and unparalleled security. Nibiru is architected to bridge the gap between innovators and builders, serving as the conduit for applications that drive real-world utility.

🌏 Website | ⛓️ Nibiru Community