Skip to main content
Determine whether account share approval is needed for a withdrawal operation and prepare the appropriate authorization. This is the recommended entry point for the withdrawal flow. It automatically:
  • Checks existing account share allowance
  • Detects smart contract wallets (Safe, EIP-4337, EIP-7702)
  • Returns the appropriate authorization result

Import

Usage


Parameters

ParameterTypeRequiredDescription
vaultNamestringYesAccount name from AmplifyVault.name (e.g. from getVaultsByConfig())
wantAssetAddressYesToken address to receive upon withdrawal
withdrawAmountstringYesAccount shares to withdraw (decimal string)
userAddressAddressYesOwner of account shares
chainIdnumberYesBlockchain network ID
forceMethod"approval" | "allowance_check"NoOverride auto routing behavior

Return Type

Returns a discriminated union WithdrawAuthorizationResult:

WithdrawAuthMethod.APPROVAL

Returned when approval is needed (insufficient allowance, smart wallet detected in auto mode, or forceMethod: "approval").

WithdrawAuthMethod.ALREADY_APPROVED

Returned when existing allowance is sufficient.

Type Guards

Use type guards for type-safe handling:
Or use a switch statement:

Smart Wallet Behavior

In auto mode, smart contract wallets (Safe, EIP-4337, EIP-7702) are routed to APPROVAL with approve tx data so they can batch approve + withdraw atomically.
The SDK detects smart wallets by checking for deployed bytecode at the address using 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

Use forceMethod for deterministic behavior:

Examples


Comparison with Deposit Authorization

prepareWithdrawalAuthorization() mirrors the deposit flow’s prepareDepositAuthorization():
FeatureDeposit AuthWithdrawal Auth
MethodsPERMIT, APPROVAL, ALREADY_APPROVEDAPPROVAL, ALREADY_APPROVED
Permit SupportYes (EIP-2612)No
Smart Wallet Auto-DetectYesYes
Force MethodforceMethod: "permit" | "approval"forceMethod: "approval" | "allowance_check"
Withdrawals don’t support EIP-2612 permits since the approval is on account shares (BoringVault ERC20), not the deposit token.

Error Handling

ErrorDescriptionResolution
Vault not foundInvalid account nameVerify account name via getVaultsByConfig()
Failed to check withdrawal approvalOn-chain multicall failedCheck RPC connectivity and retry