useWalletAssets
Get token balances for the current wallet.
Usage
import { useWalletAssets } from '@openfort/react';
import { formatUnits } from 'viem';
function WalletAssets() {
const { data: assets, isLoading, error } = useWalletAssets();
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<ul>
{assets?.map((asset) => (
<li key={asset.address}>
{formatUnits(asset.balance, asset.metadata?.decimals ?? 18)} {asset.metadata?.symbol}
</li>
))}
</ul>
);
}Parameters
type WalletAssetsHookOptions = {
assets?: OpenfortWalletConfig['assets'] // Additional assets to track
staleTime?: number // Cache duration in ms (default: 30000)
}