Skip to main content

Refer User Without Deposit

Create a UserMetadata account with a referrer without requiring an initial deposit. This allows you to link a referrer to a user before they perform any lending operations.
The referrer must be set when the UserMetadata account is created and cannot be changed afterward.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.
2

Initialize RPC and Load Market

Set up configuration constants and initialize RPC connections.
Update the REFERRER address with the wallet address of the referrer who will earn commission from the user’s borrowing activity.
3

Check Existing UserMetadata

Verify that UserMetadata does not already exist for the user.
Once UserMetadata is created with a referrer, the referrer cannot be changed. Always check if UserMetadata exists before attempting to create it.
4

Build User Metadata Setup Instructions

Generate instructions to create the UserMetadata account with the referrer.
getUserLutAddressAndSetupIxs creates the necessary instructions to set up UserMetadata with a referrer without requiring a deposit operation.
5

Build and Sign Transaction

Build the transaction using Kit’s functional pipe pattern.
6

Send and Confirm Transaction

Send the transaction and confirm it using WebSocket.
UserMetadata creation complete. The referrer is now permanently linked to the user and will earn commission from the user’s future borrowing activity.
Use this method when:
  • You want to link a referrer to a user before they make their first deposit
  • You’re creating UserMetadata as a separate step from deposit operations
  • You have a simpler flow that doesn’t require immediate deposit
Use Deposit with Referral when:
  • You want to combine UserMetadata creation and deposit in a single transaction
  • The user is ready to deposit immediately
  • You want to minimize the number of transactions