Usage
Parameters
The hook accepts the following parameters when callingwithdraw
or withdrawAsync
:
encryptKey
(string): User’s decryption PINwallet
(WalletData): Wallet public/private key pairamount
(string | number): Amount of USDC to withdrawrecipient
(string): Address to receive the withdrawn tokensbearerToken
(string): Authentication token for the API
Return Value
Returns an object containing:withdraw
: Function to trigger withdrawal (mutate)withdrawAsync
: Async function to trigger withdrawal (mutateAsync)withdrawData
: Transaction hash of the withdrawal operationisLoading
: Boolean indicating if the operation is in progressisError
: Boolean indicating if an error occurred
Example Implementation
Implementation Details
The hook performs a single transaction:- Withdraw Transaction
- Contract:
0x017f19582c61479f2fe0b6606300e975c0a8f439102f43eeecc1d0e9b3d84350
- Entrypoint:
withdraw
- Calldata: [amount, recipient, “0x0”]
- Contract:
Security Considerations
- Ensure proper encryption of private keys
- Validate recipient wallet address
- Implement proper PIN validation
- Use secure storage for wallet data
- Monitor transaction status
Error Handling
- Handle insufficient token balance
- Validate wallet addresses
- Check for withdrawal limits
- Monitor gas fees
- Implement retry logic for failed transactions
Make sure you have sufficient VESU-USDC balance before attempting to withdraw.