Manage tokens and balances
Tokens repository
import { tokens, chains, Network } from '@hot-labs/kit'
// The repository chains contains data on all popular blockchains.
const baseChain = chains.get(Network.Base)
// The tokens repository contains a list of primary tokens,
// which are supported for exchange and display in portfolios.
const ethOnBase = tokens.get("native", Network.Base)
// Converts an int to a float using the token's decimals.
ethOnBase.float(10_000_000n)
// Converts a number to an integer using decimals.
ethOnBase.int(10)
// Actual 0.01 ETH in dollars
console.log(`USD: ${ethOnBase.float(10n ** BigInt(ethOnBase.decimals - 2)) * ethOnBase.usd}`)
// IMPORTANT:
// ID of token is combination of chain id and address
// Any native token has address === 'native'
token.id === `${token.chain}:${token.address}`Refresh tokens and rates
Last updated