Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Hooks
useTokenBalances - A React hook that fetches token balances for an account on a specified network. Returns token balances with optional fiat prices and native balance inclusion. useMultichainTokenBalances - A React hook that fetches token balances across multiple chains and networks for linked wallet addresses.Caching information
Token balances are cached for15 seconds by default unless force refreshing
Rate Limiting when using the forceRefresh feature of useTokenBalances
To prevent abuse of force refreshing the balances, we have implemented configurable rate limiting on this feature.
The default limits are as follows
- You cannot request a refresh within
1 minuteof the previous refresh - You can only refresh 3 times within a
5 minuteperiod - You can only force refresh 40 times a day
If you would like higher limits, please reach out to our sales team.