The TokenFactory (TF) module on Nibiru Chain allows any account to create new tokens with a specific format. This format includes the creator's address and a subdenomination, enabling token creation without requiring prior permissions and avoiding naming conflicts.
Using this module, a single account can create multiple tokens by providing unique subdenominations for each one. The creator of a denomination automatically gains "admin" privileges over the token.
With NibiJS, users can perform the following operations on TokenFactory tokens:
Create denominations
Mint tokens
Burn tokens
Change token administrators
All interactions utilize the NibiruTxClient class, which facilitates communication with the blockchain.
To interact with TokenFactory, you first need to connect your wallet to a NibiruTxClient. This client provides access to the signAndBroadcast method to sign transactions.
Update the administrator of a specific denomination.
Copy
import{ EncodeObject }from"@cosmjs/proto-signing";import{ MsgChangeAdmin, MsgChangeAdminResponse }from"@nibiruchain/nibijs/dist/src/protojs/nibiru/tokenfactory/v1/tx";constchangeAdmin=()=>{const signerAddress = address;// from cosmosconst fee ="auto";// You can specify the fee if neededconst denom ="tf/nibi1creator-address/subdenom";// Replace with the actual denominationconstmsgs: EncodeObject[]=[{typeUrl:"/nibiru.tokenfactory.v1.MsgBurn",value: MsgChangeAdmin.fromPartial({sender: address,
denom,newAdmin:"",// new address}),},]const tx =await txClient.signAndBroadcast(
address,
msgs,
fee
);const rtx = MsgChangeAdminResponse.decode(tx.msgResponses[0].value)
console.log(rtx)}