Withdrawal flow overview
The full round trip looks like this:
The steps above, in text:
1
Get the contract and admin signature
With the built-in Rain API client configured, fetch the user’s collateral contract and the admin signature directly in the app:If Rain hasn’t produced the signature yet, the SDK throws
RAIN_303 carrying the reported status and an optional retryAfter hint: retry after that interval.Alternatively, fetch the signature from your backend with the server-side SDK and pass the salt / signature / expiresAt values into the app; the on-chain step is identical:TypeScript
2
Withdraw
Pass the admin signature to Platform differences:
withdrawCollateral. The SDK builds the transaction, signs it through the resolved wallet (the provider must support typed-data signing), submits it, and returns the transaction hash.On Android, addresses are checksummed and validated up front: malformed input throws
RAIN_102.Before signing, the SDK checks on-chain that the resolved wallet is one of the collateral’s admin signers. A wallet that is definitively not authorized throws
RAIN_407 (naming the wallet and proxy) before any signing round-trip, instead of an opaque on-chain InvalidSignature() revert. If the check cannot run (RPC failure), the withdrawal proceeds.Estimate the withdrawal fee
Estimate the network fee before submitting.Fee estimation builds the full transaction, including an EIP-712
signTypedData call through the provider. That means estimate-then-withdraw signs twice, and estimation can surface a signing prompt (for example biometrics on Turnkey). The collateral-admin check also runs during estimation, so RAIN_407 is possible here too. iOS returns Decimal; Android returns Double.Manual building (bring your own submission)
To build the withdrawal calldata yourself and submit with your own wallet, use the wallet-agnostic builders: they never resolve a provider (though Android’sbuild() still requires at least one registered).
Error handling
Withdrawal methods can throw:
See the full Error Reference for handling patterns.
What’s next
Withdraw Collateral (Guide)
Contract architecture and server-side withdrawal examples.
Authentication
Configure the built-in Rain API client and session tokens.
Error Reference
Handle SDK errors with standardized error codes.