# Creating Fungible Tokens Guide
The nibi-stargate
smart contract exemplifies the creation and management of fungible tokens on the Nibiru Chain. This guide presents steps for engaging with the smart contract, encompassing environment setup, contract deployment, transaction broadcasting, and message type comprehension.
# Clone nibiru-wasm
Start by cloning the nibi-stargate
contract from the nibiru-wasm
repository (opens new window).
To build and verify select contracts, you can use the just
comand runner (opens new window).
The specific nibi-stargate
contract is located under contracts/
.
# Setting Environment Variables
Ensure the nibid
command-line interface is installed before interacting with the nibi-stargate smart contract. Refer to the nibid
installation guide.
The following environment variables are utilized in this guide:
KEYNAME
: The keyring name or wallet address for the account responsible for broadcasting transactions. It defaults to "validator" in local Nibiru instances.tx alias
: This alias facilitates reading transaction responses. It extracts the transaction hash using jq, waits for 3 seconds to ensure transaction processing, queries transaction details using nibid q tx, and appends structured information to out.json.
# Deploying the Smart Contract
To deploy the smart contract, you need a reference to its stored bytecode on the blockchain. If the bytecode is not yet stored, deploy or store it:
This will return the transaction hash (tx-hash) with which we will query against to identify the CODE ID
:
Then, instantiate the contract using the stored CODE ID
and it will return with the transaction hash which we will use to the new contract address.
Note: The InstantiateMsg
for this smart contract is empty ({})
.
Using the transaction hash (tx-hash),
# Broadcasting Transactions
The nibi-stargate
smart contract defines the following ExecuteMsg
enum for broadcasting transactions:
# CreateDenom
# Mint
# Burn
# ChangeAdmin
# Executing Broadcast Messages
Using the known Contract Address and the example broadcast messages above, you can execute them via the below command. (broadcast_msg.json
refers to the json file containing the message)