- Checks existing vault share allowance
- Detects smart contract wallets (Safe, EIP-4337, EIP-7702)
- Returns the appropriate authorization result
Import
Usage
Parameters
Return Type
Returns a discriminated unionWithdrawAuthorizationResult:
WithdrawAuthMethod.APPROVAL
Returned when approval is needed (insufficient allowance, smart wallet detected in auto mode, orforceMethod: "approval").
WithdrawAuthMethod.ALREADY_APPROVED
Returned when existing allowance is sufficient.Type Guards
Use type guards for type-safe handling:Smart Wallet Behavior
In auto mode, smart contract wallets (Safe, EIP-4337, EIP-7702) are routed toAPPROVAL with approve tx data so they can batch approve + withdraw atomically.
getCode. This covers:
- Safe (Gnosis Safe) multi-sig wallets
- EIP-4337 smart accounts (e.g., Biconomy, ZeroDev, Alchemy)
- EIP-7702 delegated EOAs
- Privy embedded wallets (when using smart wallets)
Force Method Overrides
UseforceMethod for deterministic behavior:
Examples
- Complete Viem Flow
- Smart Wallet Batching
Comparison with Deposit Authorization
prepareWithdrawalAuthorization() mirrors the deposit flow’s prepareDepositAuthorization():
Withdrawals don’t support EIP-2612 permits since the approval is on vault shares (BoringVault ERC20), not the deposit token.
Error Handling
Related
- prepareDepositAuthorization - Deposit authorization (equivalent for deposits)
- prepareWithdrawal - Unified withdrawal wrapper
- prepareWithdrawOrderTxData - Low-level withdrawal tx builder
- prepareApproveWithdrawOrderTxData - Manual approval
- Withdrawals Guide - Complete withdrawal integration guide
- Smart Wallets Guide - Smart wallet integration patterns