PollarPollarDemo

Products

AuthenticationWalletTransactions

Integrations

KYCSoonRampNewSwapNewEarnNew

Wallet Adapters

Stellar Wallets KitPrivyNewCosmos WalletNew

Adapters

Trustless Work

Built with Pollar

LumenWipeNew
SendReceiveBalanceChainsAssetsHistoryDistribution

Chains

The networks this app serves, cross-referenced with the wallets the user actually holds — the list every network picker in the SDK is driven by.

useChains() resolves the app's configured chains against the user's wallets and hands you an ordered list, the primary chain, and its address.

The chain list orders AND filters

The app's chain list from /applications/config does both jobs: a chain missing from it is dropped, not merely sorted last. That matters because wallets come from the session — written at login and kept for as long as it lives — while /config is refetched on every page load. So a chain switched off in the dashboard today disappears on the next reload, even for a user who logged in last week and still carries it in their stored session.

Hook, helpers & component used

useChains() comes from the hook layer; the three helpers below are plain functions you can call anywhere, and ChainSelect is the prebuilt picker.

  • useChains()hook

    params: No arguments. Reads wallets from context and the chain order from /applications/config.

    returns: { chains, primaryChain, primaryAddress, ready } — chains is [] while /config is in flight, so a picker driven by it renders nothing rather than a list it must reorder a moment later.

  • chainsOf(wallets, order?)sync

    params: wallets: WalletInfo[]; order?: readonly WalletChain[] — the app's chain list. Omit it and the wallets' own order is used as the fallback.

    returns: WalletChain[] — de-duplicated, since two wallets on one chain (a custodial plus a linked external one) are still a single network choice.

  • resolveChain(chain)sync

    params: chain: WalletChain | undefined.

    returns: WalletChain — absent counts as STELLAR, not as unknown: sessions and balance rows minted before multichain carry no chain and are Stellar by definition.

  • addressForChain(wallets, chain)sync

    params: wallets: WalletInfo[]; chain: WalletChain | null.

    returns: string — the address to show for that chain, or '' when the user holds no wallet there.

  • <ChainSelect />component

    params: value, options, onChange, plus optional label and disabled.

    returns: The picker, or null when options has a single entry — a one-chain app renders no selector at all.

@pollar/react— hooks & components
import { useState } from 'react';
import { useChains, ChainSelect } from '@pollar/react';

export function NetworkPicker() {
  const { chains, primaryChain, ready } = useChains();
  const [picked, setPicked] = useState(null);

  // chains is [] until /config lands — gate on `ready` so the
  // picker never renders a list it has to reorder a moment later.
  return (
    <ChainSelect
      value={picked ?? primaryChain}
      options={chains}
      onChange={setPicked}
      disabled={!ready}
    />
  );
}
useChains()loading

Connect a wallet to resolve the chain list.