useWalletAssets
Get the wallet assets for the current user.
Parameters
type WalletAssetsHookOptions = {
// Optional custom asset configuration, in addition to the default assets defined in the wallet config
assets?: OpenfortWalletConfig['assets']
// Optional stale time for caching wallet assets (default: 30000 ms)
staleTime?: number
}Example
import { useWalletAssets } from '@openfort/react';
import { formatUnits } from 'viem';
function WalletAssets() {
const { data: assets, isLoading, error } = useWalletAssets();
if (isLoading) return <div>Loading assets...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
<h2>Wallet Assets</h2>
<ul>
{assets?.map((asset) => (
<li key={asset.address}>
{asset.address}: {formatUnits(asset.balance, asset.metadata?.decimals ?? 18)} {asset.metadata?.symbol}
</li>
))}
</ul>
</div>
);
}