# `useEthereumWalletAssets`

:::info
**Ethereum only.** Import from `@openfort/react/ethereum`.
:::

Returns wallet assets (tokens, NFTs) for the connected Ethereum address using ERC-7811 via Openfort's authenticated RPC proxy.

:::warning
Fetches [default assets](/docs/configuration/default-assets) plus any assets defined in [wallet configuration](/docs/products/embedded-wallet/react/wallet/assets#erc-20-tokens) or passed as options.
:::

## Usage

```tsx
import { useEthereumWalletAssets } from '@openfort/react/ethereum';
import { formatUnits } from 'viem';

function WalletAssets() {
  const { data: assets, isLoading, error } = useEthereumWalletAssets();

  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>
  );
}
```

## Return type

The return type is a discriminated union based on the `multiChain` option:

```ts
type UseEthereumWalletAssetsResult =
  | (WalletAssetsReturnBase & { multiChain: true; data: readonly MultiChainAsset[] | null })
  | (WalletAssetsReturnBase & { multiChain: false; data: readonly Asset[] | null })

type WalletAssetsReturnBase = {
  isLoading: boolean
  isError: boolean
  isSuccess: boolean
  isIdle: boolean  // True when wallet not connected or chain not available
  error: OpenfortError | undefined
  refetch(): Promise<unknown>
}

// Asset is a discriminated union by `type`
type Asset = {
  type: 'native'
  address?: 'native'
  balance: bigint
  metadata?: {
    decimals?: number
    symbol: string
    name?: never
    fiat: { value: number; currency: string }
  }
  raw?: NativeAsset
} | {
  type: 'erc20'
  address: Hex  // e.g. `0x${string}`
  balance: bigint
  metadata: {
    decimals?: number
    symbol: string
    name: string
    fiat?: { value: number; currency: string }
  }
  raw?: Erc20Asset
}

type MultiChainAsset = Asset & {
  chainId: number
}
```

## Parameters

```ts
type UseEthereumWalletAssetsOptions = {
  assets?: Record<number, Hex[]>  // Additional assets to track per chain
  multiChain?: boolean            // When true, fetches across all configured chains
  staleTime?: number              // Cache duration in ms (default: 30000)
}

// assets format: { [chainId: number]: Hex[] }
// Example USDC on mainnet: { 1: ['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'] }
```
