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,
});
Parameter | Description | Type | Required | Default |
---|---|---|---|---|
address | Connected wallet address. | ChainId | true | N/A |
chainId | Destination network chain ID to set default selected token. | ChainId | true | N/A |
selectTokens | Set of token addresses to return specifically - e.g., zeroAddress . | Address | false | All tokens. |
selectChains | Target set of chains from which to fetch balances. | ChainId[] | false | All 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
});
Parameter | Description | Type | Required | Default |
---|---|---|---|---|
tokenAddress | Target token address. | Address | true | N/A |
chainId | Chain ID for token. | ChainId | true | N/A |