Skip to content

UI Helper Functions

Dealing with many assets and networks creates complicates typically standard RPC calls like reading users token balances. Decent's Hooks include helper functions for common pain points building across chains.

useUsersBalances

This hook returns all of a connected wallet's token balances across all chains.

Sample Usage

const { tokens = [], isLoading } = useUsersBalances({
  address,
  chainId,
  selectTokens,
  selectChains,
});
ParameterDescriptionTypeRequiredDefault
addressConnected wallet address.ChainIdtrueN/A
chainIdDestination network chain ID to set default selected token.ChainIdtrueN/A
selectTokensSet of token addresses to return specifically - e.g., zeroAddress.AddressfalseAll tokens.
selectChainsTarget set of chains from which to fetch balances.ChainId[]falseAll supported chains.

useUsdConversion

Fetch the USD price for a specified token. Leverages the Decent Scan /getTokenPrice endpoint.

Sample Usage

const { data, isLoading, error } = useUsdConversion({
  tokenAddress,
  chainId
});
ParameterDescriptionTypeRequiredDefault
tokenAddressTarget token address.AddresstrueN/A
chainIdChain ID for token.ChainIdtrueN/A