useProfileBalance hook.
Balance Display Configuration
You can customize how balances are displayed and calculated through theparaModalConfig.balances property in your ParaProvider configuration. This setting will impact both the Para Modal’s balance display and instances where you use the useProfileBalance hook.
Para supports two primary balance display modes, AGGREGATED and CUSTOM_ASSET.
Defining Custom Networks and Assets
To include custom assets when fetching connected wallet balances, you will need to supply implementation metadata for each asset, including:- Each asset must include basic metadata, including
name,symbol, andlogoUrl(optional). - Each asset must include an
implementationsarray for each network you wish to query for balances.- Each implementation object must include:
- Price data:
- For a fixed price:
- Include a
priceobject with the asset’s price in the format{ value: number; currency: 'USD' }.
- Include a
- For a volatile price:
- Include a
priceUrlstring. This endpoint must respond to GET requests with a JSON object with the asset’s current price in the format{ value: number; currency: 'USD' }.
- Include a
- For a fixed price:
- Network information:
- For a custom EVM network:
- Include a
networkobject specifying the network’sname,evmChainId, and anrpcUrlwhere asset balances can be queried. - If the asset is the network’s native token:
- No additional configuration is needed.
- If the asset is an ERC-20 token:
- Include a
contractAddressstring.
- Include a
- Include a
- For a standard EVM or Solana network:
- Include a
networkstring, matching one of the networks enumerated in theTNetworktype. For example,'ETHEREUM'or'SOLANA'. - Include a
contractAddressstring.
- Include a
- For a custom EVM network:
- Price data:
- Each implementation object must include:
Aggregated Mode (Default)
Aggregated Mode automatically aggregates balances across all detected chains and assets and displays them in USD value. If you supply additional assets and price data, these totals will be included in the calculation.The aggregated total will include most commonly used assets across many networks. If you want to only include totals from your customized tokens, set
excludeStandardAssets to true.Custom Asset Mode
In Custom Asset Mode, the Para Modal will only display balances of a chosen asset, with no fiat currency conversion. This is ideal for cases where your app uses a particular token that may not have price information available. Like in Aggregated Mode, you will need to supply implementation metadata for the asset, including any custom network definitions so that its balances can be queried for the session’s connected wallets. However, in this mode, you do not need to include a price object or a price URL.useProfileBalance Hook
TheuseProfileBalance hook allows you to query the current aggregated or custom asset balance of all wallets in the current session.
Balances are normally cached on the server for five minutes. You can supply a refetchTrigger to the hook to manually refetch balances when desired, using a unique number or string.
ProfileBalance object returned by useProfileBalance has the following structure:
- Aggregated
- Custom Asset