Appearance
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.flow | Meaning |
|---|---|
direct | Session already receives this token on this network. User sends it. |
swap | Same chain, different token. SDK swaps into the session asset. |
bridge | Different chain. SDK bridges into the session token/network. |
unavailable | No route for this token. |
Priority: direct → swap → bridge → unavailable.
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).
Tron is direct TRX and TRC-20 only. Swap and bridge stay unavailable. See Tron.
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. Fetch wallet balances before resolving a plan - source.decimals comes from the cached balance row, and getPlan fails without it.
Options
| Option | Meaning |
|---|---|
walletId | Connected instance |
network | Source token network |
symbol | Source token symbol |
tokenAddress | Source token contract, or null for native |
bridgeDestination? | Optional preferred bridge destination. When omitted, the SDK picks automatically |
Returns
| Field | Meaning |
|---|---|
plan | WalletTransferPlan or null |
isLoading | Loading |
error | Last getPlan error |
refetch | Re-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).
Fee check on the amount step
After useWalletTransferPlan and amount input, call useWalletTransferFeeCheck with the same plan and canonical amount string you pass to submit. Disable Continue while the hook is loading or when data.status !== 'ok'. For exceeds_balance_with_fee, offer a button that sets the amount to data.suggestedAmount — the SDK never adjusts it automatically.
The connect-sdk demo wallets deposit screen shows this panel live (DepositAmountPlaceholder).
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
| Option | Meaning |
|---|---|
enabled? | Skip prefetch when false. Default true |