Deposit with Referral
A UserMetadata account stores the referrer information. The referrer must be included when the account is created. After it is set, the referrer cannot be changed.1
Import Dependencies
Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.2
Setup Market and Check Existing Referrer
Load the keypair, initialize the market, and check whether a referrer is already associated with the account.3
Build Deposit Instructions with Referrer
Generate deposit instructions that include the referrer information.4
Send Initial Transaction
Fetch the latest blockhash and build the transaction message.5
Handle Retry Logic
Detect and handle setup-related errors that may occur.The deposit with referral is complete. The referrer is now permanently linked to the account and will earn commission from the user’s future borrowing activity.