Usage
Parameters
The hook accepts the following parameters when callingstake
or stakeAsync
:
encryptKey
(string): User’s decryption PINwallet
(WalletData): Wallet public/private key pairamount
(string | number): Amount of USDC to stakereceiverWallet
(string): Address to receive the staked tokensbearerToken
(string): Authentication token for the API
Return Value
Returns an object containing:stake
: Function to trigger staking (mutate)stakeAsync
: Async function to trigger staking (mutateAsync)stakeData
: Transaction hash of the stake operationisLoading
: Boolean indicating if the operation is in progressisError
: Boolean indicating if an error occurred
Example Implementation
Implementation Details
The hook performs two transactions in sequence:-
Approval Transaction
- Contract:
0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8
- Entrypoint:
approve
- Calldata: [spender, amount, 0]
- Contract:
-
Deposit Transaction
- Contract:
0x017f19582c61479f2fe0b6606300e975c0a8f439102f43eeecc1d0e9b3d84350
- Entrypoint:
deposit
- Calldata: [amount, 0, receiverWallet]
- Contract:
Security Considerations
- Ensure proper encryption of private keys
- Validate receiver 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 existing approvals
- Monitor gas fees
- Implement retry logic for failed transactions
Make sure you have sufficient USDC balance and have approved the VESU contract before staking.