Skip to main content
Use this recipe when your app lives on Base but your users hold assets spread across networks. Before they act, they need to see what they hold everywhere. SODAX reads a user’s own wallet with the same call on every network it supports, so a Base app can show a cross-network portfolio and route any holding onto Base.

What you will build

A portfolio view that reads balances on every network a user has connected, then moves a chosen holding into a Base asset.

Prerequisites

  • @sodax/sdk, plus @sodax/dapp-kit and a SodaxProvider for the React hook.
  • The networks and addresses the user has connected.

How it works

1

Read one network at a time

Each read covers one network, so a broken network never hides the others. A failed network comes back as null, never as an empty wallet.
2

Keep the chain key and token list together

Every read uses token.address on the network you pass, so a token list from another network reads wrong. Each network’s swap-supported list is also the set of holdings a user can route onto Base. Look tokens up by address, not symbol.
3

Display amounts

Balances are bigint in the token’s smallest unit. Scale them by token.decimals. See Read wallet balances.
4

Route a holding onto Base

Hand the chosen holding to Accept any token, settle on Base: the source is the network and token the user picked, the destination is Base.

Code

Read every connected network with @sodax/sdk:
Or one network at a time with the useBalances hook in @sodax/dapp-kit:

Next steps