Earn Withdraw to Privy
1
Import Dependencies
Import the required packages for Privy client, Solana RPC communication, and Kamino SDK operations.2
Configure Privy and Initialize Client
Set up your Privy credentials and initialize the Privy client and RPC connection.3
4
Check User Shares
Query the user’s vault shares to determine how much can be withdrawn.The total shares represent the user’s position in the vault. Both staked and unstaked shares are included in the withdrawal.
5
Build Withdrawal Instructions
Generate withdrawal instructions for all user shares using a noop signer.A noop signer is used to build instructions without requiring the actual private key. Privy will handle signing later.
6
Build Transaction Message
Fetch the latest blockhash and construct the withdrawal transaction message.7
Sign Transaction with Privy
Compile the transaction, serialize it, and sign using Privy’s wallet API.Privy handles the signing securely using the embedded wallet. The private key never leaves Privy’s infrastructure.
8
9
Check USDC Balance
Query the wallet’s USDC balance using Privy’s balance API.Your withdrawal is complete! The user’s vault shares have been redeemed for USDC, and the balance is now available in their Privy wallet.