Swap and Bridge
Preview and execute token swaps and cross-network bridges with WDK CLI
WDK CLI can quote installed swap and bridge protocols, select a route, and execute it from an unlocked wallet. Use wdk token list to find the registered network and token names accepted by these commands.
Before you begin, set up and unlock a wallet and check the source and destination token names with wdk token list. Built-in entries need no registration. If an entry is missing, add a custom token. Fund the source account with the tokens and native gas asset needed for execution.
If you register a custom or overriding native token, read Manage Tokens first: wdk token add cannot retain nativeId, so routing works only when the selected protocol discovers the asset by symbol or does not require a native route identifier. Custom native tokens are not guaranteed to swap or bridge.
wdk swap and wdk bridge execute immediately unless you add --dry-run. Preview first, inspect the route, amounts, fees, recipient, and skipped protocols, then decide whether to execute.
Preview A Swap
Provide exactly one of --amount-in and --amount-out.
wdk swap \
--network SOURCE_NETWORK \
--from-token SOURCE_TOKEN \
--to-token DESTINATION_TOKEN \
--amount-in 100 \
--dry-runAn exact-input request selects the successful quote with the highest output. An exact-output request selects the quote with the lowest input:
wdk swap \
--network SOURCE_NETWORK \
--from-token SOURCE_TOKEN \
--to-token DESTINATION_TOKEN \
--amount-out 100 \
--dry-runReplace the uppercase placeholders with values from wdk network list and wdk token list. Add --to-network DESTINATION_NETWORK for a cross-network swap.
The ranking compares token amounts only. Separate gas and bridge fees can use different denominations or already be included in a provider quote, so they do not affect route selection. Review both the on-top and included fee lines. A successful result can also list protocols under skipped when those protocols failed to quote.
Execute A Swap
Run the same command without --dry-run only after reviewing the preview:
wdk swap \
--network SOURCE_NETWORK \
--from-token SOURCE_TOKEN \
--to-token DESTINATION_TOKEN \
--amount-in 100Execution requests new quotes and can select a different route or return different amounts than the earlier preview. WDK CLI does not ask for another confirmation.
Preview And Execute A Bridge
wdk bridge moves the same registered token between different networks. It supports exact input only.
wdk bridge \
--network SOURCE_NETWORK \
--token TOKEN \
--to-network DESTINATION_NETWORK \
--amount 100 \
--dry-runThe source and destination networks must differ. After reviewing the preview, remove --dry-run to execute. Execution requotes before choosing and running a route.
Choose The Recipient And Protocol
If --recipient is omitted, WDK CLI derives the destination-network address from the same wallet and account index. An explicit recipient must be valid for the destination network.
Use --protocol NAME to restrict quoting to one protocol already registered in the installed CLI catalog. wdk module add installs a wallet-module package for custom networks; it does not add a swap or bridge protocol to this routing catalog.