Injective | TS & dApps Docs
DocumentationInjective TS
  • Overview
  • Getting Started
    • Technical Concepts
    • Application Concepts
      • Calculations
        • Min Price Tick Size
        • Min Quantity Tick Size
      • Networks
      • CosmJs Support
    • Assets
      • Creating Tokens
      • Denom Client (deprecated)
      • Injective Lists
    • Running examples
  • Wallets
    • Getting Started
    • Accounts
    • Wallet Connections
    • Wallet Strategy
    • Offchain (Arbitrary) Data
  • Querying
    • Getting Started
    • Chain
      • Auction
      • Auth
      • Bank
      • Distribution
      • Exchange
      • Governance
      • IBC
      • Mint
      • Insurance Funds
      • Oracle
      • Peggy
      • Permissions
      • Staking
      • Tendermint
      • Wasm
      • WasmX
      • Token Factory
    • Indexer
      • Account
      • Auction
      • Derivatives
      • Explorer
      • Insurance Funds
      • Markets
      • Leaderboard
      • Mito
      • Oracle
      • Portfolio
      • Spot
      • Web3Gw Transactions
      • Streaming
        • Account
        • Auction
        • Derivatives
        • Oracle
        • Portfolio
        • Spot
        • Explorer
    • Ethereum (GraphQL)
  • Transactions
    • Getting Started
    • Cosmos
      • Ledger through Keplr Wallet
    • Ethereum
      • Ethereum Ledger
    • MsgBroadcaster
    • Private Key
    • Web3 Gateway
  • Core Modules (& examples)
    • Getting Started
    • Auction
    • AuthZ
    • Bank
    • Distribution
    • Exchange
    • Feegrant
    • Governance
    • IBC
    • Insurance
    • Peggy
    • Permissions
    • Staking
    • Tokenfactory
    • Wasm
  • Smart Contracts
    • Cosmwasm
      • Injective Name Service
      • Neptune Service
      • CW20 to Bank & Market Order in One Transaction
  • Bridges
    • Getting Started
    • Ethereum
    • IBC
    • Wormhole
  • Building Dapps
    • Getting Started
    • Configuring Nuxt
    • Configuring React
    • dApps Examples
      • Smart Contract
      • DEX
      • Bridge
      • Simple HTML example with Webpack
Powered by GitBook
On this page
  1. Getting Started
  2. Assets

Denom Client (deprecated)

PreviousCreating TokensNextInjective Lists

Last updated 11 months ago

This is deprecated, refer to the guide instead.

The easiest way to get the token metadata information for a particular denom is to utilize the TokenFactory class and use its methods:

import { TokenFactory } from '@injectivelabs/token-metadata'
import { Network } from '@injectivelabs/networks'

const network = Network.Mainnet
const tokenFactory = TokenFactory.make(network) // you can omit the network argument if you want to have the TokenFactory for mainnet

// After instantiating, we can start using it in our dApp
const denom = 'peggy0x...'
const token = tokenFactory.toToken(denom)

console.log(token)

There are few edge cases that we have to consider while using the `TokenFactory`:

  • If you are trying to query token metadata for a denom that doesn't exist in the the TokenFactory will return undefined. If so, you should follow our to add the token metadata information in the package.

  • IMPORTANT TokenFactory does not have the logic to query a denom trace for an IBC denom. Instead, we have a list of pre-defined IBC hashes which we use to get metadata from. We'll explore how to have this possibility as well below.

DenomClientAsync (deprecated)

As part of the @injectivelabs/sdk-ui-ts package we have an abstraction class which uses the TokenFactory class under the hood, has a caching mechanism for IBC hashes, fetches token metadata from the chain, ERC20 contract details, CW20 contract details, etc. With it, you can ensure that you get all of the Token information for the denoms used within your application.

The usage is pretty simple, here is an example:

import { DenomClientAsync } from '@injectivelabs/sdk-ui-ts'
import { Network } from '@injectivelabs/networks'

const network = Network.Mainnet
const denomClient = new DenomClientAsync(network) // you can omit the network argument if you want to have the TokenFactory for mainnet

// After instantiating, we can start using it in our dApp
const denom = 'peggy0x...'

/**
 * We have to use await here in case the IBC denom hash is not
 * in the list of hardcoded IBC hashes so we fetch all of the
 * denom traces from the chain and cache them in the local instance of the
 * DenomClient class so we can access them easily
 */
const token = await denomClient.getDenomToken(denom)

console.log(token)
injective-list
list of tokens
CONTRIBUTION guide
DenomClientAsync