Trustware.getBalances()to load what the wallet can sendTrustware.buildRoute()to get a signable routeTrustware.useWallet()to attach the embedded walletTrustware.sendRouteTransaction()to sign and broadcastTrustware.submitReceipt()to confirm the transaction and enable status tracking
This guide covers users withdrawing funds held in an embedded wallet your app provisioned. It is unrelated to paymaster fund management in the Client Dashboard.
When to use this pattern
Choose this pattern when:- your app provisions embedded wallets and users hold balances in them
- users need to move those funds to an external wallet or another chain
- you want to build the withdrawal UI in your own design system
Prerequisites
- An adapted embedded wallet. Follow use Trustware with embedded wallets to wrap the wallet’s EIP-1193 provider with
useEIP1193. - An initialized SDK. Either mount
TrustwareProviderwith your config, or callTrustware.init(config)before the calls below.
1. Load embedded wallet balances
getBalances returns the token balances for an address on one chain. Filter to funded rows to drive your source-token picker:
getBalances results per chain and address. Pass forceRefresh: true to force a fresh on-chain scan, for example right after a deposit lands; omit it to reuse the cache when the user is only switching between chains.
Each row is a BalanceRow:
2. Build the withdrawal route
Build a route with the embedded wallet asfromAddress and the user’s chosen destination as toAddress:
fromAmount is in the token’s smallest unit. Convert human-readable input with the token’s decimals before calling the SDK, for example with viem’s parseUnits. See headless core for the full BuildRouteBody and BuildRouteResult shapes.
3. Attach the embedded wallet and send
Attach the adapted wallet, then sign and broadcast the route.sendRouteTransaction switches the wallet to the route’s chain if needed and returns the transaction hash:
4. Submit the receipt and track status
Submit the transaction hash so Trustware can track settlement, then poll until the route resolves:pollStatus resolves when the route reaches success or failed. Use Trustware.getStatus(route.intentId) instead if you want to poll on your own schedule.
