Skip to content

Transfer plan

A transfer plan (WalletTransferPlan) is how a connected wallet + token becomes the session deposit. You pass the source (walletId, network, symbol, tokenAddress). The SDK picks the route — you do not. For bridge, the destination is picked automatically (first supported destination) unless you pass bridgeDestination.

plan.flowMeaning
directSession already receives this token on this network. User sends it.
swapSame chain, different token. SDK swaps into the session asset.
bridgeDifferent chain. SDK bridges into the session token/network.
unavailableNo route for this token.

Priority: directswapbridgeunavailable.

plan.source is what the user spends. plan.destination is what the session receives. These hooks do not require WalletsProvider, but you still need a connected walletId. Full field list: Transfer plan (Core).

useWalletTransferPlan

tsx
import { useWalletTransferPlan } from '@swapped/connect-sdk/react'

function Plan({
  walletId,
  token,
}: {
  walletId: string
  token: { network: Network; symbol: TokenSymbol; tokenAddress: string | null }
}) {
  const { plan, isLoading, error, refetch } = useWalletTransferPlan({
    walletId,
    network: token.network,
    symbol: token.symbol,
    tokenAddress: token.tokenAddress,
  })

  return (
    <div>
      {isLoading ? <p>Resolving…</p> : null}
      {plan ? <p>{plan.flow}</p> : null}
      {plan?.destination ? (
        <p>
          → {plan.destination.symbol} on {plan.destination.network}
        </p>
      ) : null}
      {error ? <p>{error.message}</p> : null}
    </div>
  )
}

Pass null while you have no token selected — the hook stays idle.

Options

OptionMeaning
walletIdConnected instance
networkSource token network
symbolSource token symbol
tokenAddressSource token contract, or null for native
bridgeDestination?Optional preferred bridge destination. When omitted, the SDK picks automatically

Returns

FieldMeaning
planWalletTransferPlan or null
isLoadingLoading
errorLast getPlan error
refetchRe-run getPlan

Use plan.flow, plan.source, and plan.destination in UI. issues[0].message is a user-facing string when the route is constrained. Other diagnostics: Transfer plan (Core).

usePrepareWalletTransfer

Optional warm-up when entering a wallets / deposit screen.

tsx
import { usePrepareWalletTransfer, useSession } from '@swapped/connect-sdk/react'

function WalletsPage() {
  const { session } = useSession()
  usePrepareWalletTransfer({ enabled: Boolean(session) })
  return null
}

Options

OptionMeaning
enabled?Skip prefetch when false. Default true