dAppBooster
    Preparing search index...

    Function useTokens

    • Custom hook for fetching and managing tokens data with price and balances.

      Combines token list data with real-time price and balance information from LI.FI SDK. Features include:

      • Token data fetching from token lists
      • Balance fetching for specified accounts across multiple chains
      • Price information retrieval
      • Automatic sorting by token value (balance × price)
      • Periodic refetching for up-to-date balances and prices

      Parameters

      • params: { account?: `0x${string}`; chainId?: number; withBalance?: boolean } = ...

        Parameters for tokens fetching

        • Optionalaccount?: `0x${string}`

          Account address for balance fetching (defaults to connected wallet)

        • OptionalchainId?: number

          Specific chain ID to filter tokens (defaults to all supported chains)

        • OptionalwithBalance?: boolean

          Whether to fetch token balances

      Returns { isLoadingBalances: boolean }

      Token data and loading state

      // Fetch all tokens with balances for connected wallet
      const { tokens, tokensByChainId, isLoadingBalances } = useTokens();

      // Fetch tokens for specific chain without balances
      const { tokens } = useTokens({
      chainId: 1,
      withBalance: false
      });

      // Fetch balances for specific account
      const { tokens } = useTokens({
      account: '0x123...'
      });