LogoLogo
  • Introduction
    • Kujira Empowers Everyone
      • Ecosystem
      • Where Everyone Can Be a Whale
      • Grown-Up DeFi (GUD)
    • Why Kujira
      • User and Developer Experience
      • Values
        • Principles
        • Sustainability
    • Meet Team Kujira
  • Kujira Ecosystem
    • Our Products
    • Wider Ecosystem
    • Kujira Roadmap
    • How to Participate
    • Moving Funds to Kujira
    • Shipping Lane
    • Security
    • Media Coverage
    • Links
  • dApps & Infrastructure
    • Basics
    • Welcome to Kujira (Landing Page)
    • BLUE (Central Hub)
      • Dashboard
      • Wallet
      • Swap
      • IBC / Bridge
      • Mint
      • Stake
      • Govern
      • Developer
      • Product Guides
        • How to Send Tokens
        • How to Convert balances to KUJI
        • How to Swap tokens
        • How to Bridge tokens
        • How to use IBC
        • How to Mint USK
        • How to Stake KUJI
        • How to Redelegate KUJI
        • How to Unstake KUJI
        • How to Check the Status of Governance Proposals and/or Vote
        • How to Nominate a Candidate for the Senate
        • How to View Information on Senate Candidates
    • BOW (Liquidity Engine)
      • Dashboard
      • Pools
        • Featured Pools
        • All Liquidity Pools
          • Pool Overview
          • Provide to a Pool
          • Leveraged Liquidity
          • Stake LP with a Pool
      • Swap
      • Stake USK
        • Overview
        • Stake / Unstake
        • Rewards
      • Product Guides
        • How to View LP positions
        • How to Add Liquidity
        • How to Remove Liquidity
        • How to Provide Incentives
        • How to Check the Reward Schedule of a Pool
    • FIN (DEX)
      • Overview
      • How to Use FIN
        • Search and Filter by View
        • Price Chart and Charting Tools
        • Orderbook status and Recent Trades
        • Personal Order Activity
        • Spot and Margin Trade UI
          • Isolated FIN Margin
      • Listing tokens on FIN
      • Coingecko API
      • Product Guides
        • How to Buy KUJI Using axlUSDC
        • How to Sell ATOM for USK
        • How to List a New Pair
        • How to Toggle View to see Certain Pairs
        • How to Save Favourite Pairs
        • How to Check Unclaimed Orders
        • How to Navigate to BOW Pools
        • How to Look at Your History
    • FINDER (Explorer)
      • Product Guides
        • How to View a Wallet's Balance
        • How to Bookmark Wallets for Tracking
        • How to View and Manage Bookmarked Wallets
    • GHOST (Money Market)
      • Basics
      • Dashboard
      • Borrow
      • Lend
    • ORCA (Liquidations)
      • Basics
        • Lending Markets
          • Analytics
          • USK Lending Markets
            • Isolated FIN Margin
          • xAsset Lending Markets
      • How to Integrate ORCA
      • Product Guides
        • How to Bid on Collateral
        • How to View Active Bids on Collateral
        • How to View the Analytics on a Liquidation Market
    • PILOT (Launchpad)
    • POD (Cross-chain Staking)
      • Product Guides
        • How to Stake any Cosmos Layer 1 Token
        • How to Redelegate any Cosmos L1 Token
        • How to Unstake any Cosmos L1 Token
    • Pond (Developer Toolkit)
    • (Retired) SENATE (Grant Oversight)
      • Senators
      • Constitution
      • Treasury
      • Contacting the Senate
      • Past Senate Proposals
      • Past Senate Meetings
      • Transparency
    • Sonar (Native Wallet)
      • Basics
      • Setup
        • Create a wallet
        • Fund your wallet
        • Customize your settings
      • Using Sonar
        • Mobile
          • Home
          • Swap
          • Launch
            • Trade
            • Mint
            • Borrow
            • Liquidate
            • Launch (PILOT)
            • Buy gift cards with Bidali
            • Fin orders (dashboard)
            • Mint & manage USK positions (dash)
            • Borrow on GHOST (dashboard)
          • Stake
          • Send/Receive
        • Desktop
    • USK (Stablecoin)
      • Basics
      • Technical Specifics
      • Use Cases
      • Transparency
      • How to Mint USK
  • Developers
    • Developer Kickstart Page
    • Smart Contracts
      • Token Factory
      • Price Oracle
      • Scheduler
      • Entropy Beacon
    • Indexers
      • SubQuery
    • Core Module Accounts
    • List of Tokens
    • dApp Front Ends
      • FIN
    • Contacting the Team
  • Tokenomics
    • KUJI Token
      • Staking KUJI
      • Staking Tiers and Symbols on BLUE, FIN, and ORCA
      • KUJI Sustainability
      • Kujira Governance
      • Lending and Borrowing KUJI
      • Buying Kujira NFTs
  • Validators
    • Run a Node
      • Create a validator
      • Oracle Price Feeder
      • Tips
    • Cosmovisor Setup
    • Community Tooling
    • Staking Rewards
    • Genesis Validator Allocation
  • Governance
    • Staking
      • Staking Overview
      • Redelegate
      • Unbond
      • Slashing
      • Staking UI
    • Vote on Proposals
    • Submit a Governance Proposal
    • (Retired) The Kujira Senate
      • Treasury
    • Discord Governance Forum
    • Capybara Labs
    • Smart Stake
  • Our Venture-Builder Program
    • Overview
  • Community
    • Kujira Amplifier
    • Kujira Communities
    • Kuji Kast
    • Kujira News
    • Kujira Support
      • Support Ticket System
      • Cosmobot
    • Kujira Social Media
      • Discord
      • Telegram
      • Twitter
      • WinkHUB
      • Medium
      • Reddit
      • Instagram
      • YouTube
  • Help Center
    • Kujira Classroom
    • FAQ
    • Handy Tools
    • Glossary
    • Common Error Messages
  • Brand Assets
    • Colors
    • Logo Options
      • Kujira Brand
      • Native Token Logos
      • Product Logos
      • Legacy Logos
    • Fonts
Powered by GitBook
On this page
  • CLI
  • CosmWASM Bindings
Edit on GitHub
  1. Developers
  2. Smart Contracts

Token Factory

PreviousSmart ContractsNextPrice Oracle

Last updated 1 year ago

The Token Factory allows you to create your own native denoms, as recognised by the Cosmos SDK Bank Module.

This allows your protocol to issue its own token, without needing to support the CW20 standard. It means that all tokens on the Kujira network are compatible as gas-fee payments, and can be collected as protocol revenue and distributed to KUJI stakers.

CLI

Create a denom

kujirad tx denom create-denom mydenom

Mint it

kujirad tx denom mint 10000factory/kujira12345/mydenom kujira123...

and Burn it

kujirad tx denom burn 10000factory/kujira12345/mydenom 

CosmWASM Bindings

These commands can also be issued via your smart contracts. Please refer to the bindings published in kujira-rs:

Creation

In order for the contract to be able to mint and burn a denom, it will need to be created by the contract itself, often upon instantation:

use kujira::msg::{DenomMsg, KujiraMsg};

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
    deps: DepsMut<KujiraQuery>,
    env: Env,
    _info: MessageInfo,
    msg: InstantiateMsg,
) -> Result<Response<KujiraMsg>, ContractError> {
    let addr = env.contract.address;
    let denom = format!("factory/{addr}/{denom}");
    let config = Config::new(msg.owner, denom);
    
    CONFIG.save(deps.storage, &config)?;
    Ok(Response::default()
        .add_message(DenomMsg::Create {
            subdenom: msg.denom,
        }))
}

Minting & Burning

Now your contract is the owner of the denom, we can mint and burn tokens. Here is an example contract whose purpose is to provide a permissioned list of addresses that can mint and burn, instead of just the admin:

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
    deps: DepsMut<KujiraQuery>,
    _env: Env,
    info: MessageInfo,
    msg: ExecuteMsg,
) -> Result<Response<KujiraMsg>, ContractError> {
    let mut c = CONFIG.load(deps.storage)?;
    match msg {
        ExecuteMsg::Burn {} => {
            let amt = amount(&c.denom, info.funds)?;
            c.validate_permitted(info.sender)?;

            Ok(Response::default()
                .add_attributes(vec![attr("action", "burn"), attr("amount", amt)])
                .add_message(CosmosMsg::Custom(KujiraMsg::Denom(DenomMsg::Burn {
                    denom: c.denom,
                    amount: amt,
                }))))
        }
        ExecuteMsg::Mint { amount, recipient } => {
            c.validate_permitted(info.sender)?;
            Ok(Response::default()
                .add_attributes(vec![attr("action", "mint"), attr("amount", amount)])
                .add_message(CosmosMsg::Custom(KujiraMsg::Denom(DenomMsg::Mint {
                    denom: c.denom,
                    amount,
                    recipient,
                }))))
        }
        ExecuteMsg::Permit { address } => {
            c.validate_owner(info.sender)?;
            c.permit(address.clone());
            CONFIG.save(deps.storage, &c)?;
            Ok(Response::default()
                .add_attributes(vec![attr("action", "permit"), attr("address", address)]))
        }
    }
}
KujiraMsg in kujira::msg - Rust
Page cover image
Logo