Skip to main content

How Referral Codes Work

Kamino’s referral system allows referrers to earn commission from the borrowing activity of referred users. Each referrer creates a unique referral code that can be shared publicly without revealing a wallet address, providing a user-friendly way to distribute referral codes.
In the SDK, the shortUrl field represents the referral code.
1

Import Dependencies

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

Initialize RPC

Load the keypair and initialize RPC connections.
3

Create Referrer State with Short URL

Generate a unique short URL and create the referrer state initialization instruction.
The short URL must be unique, contain a maximum of 32 characters, and use only ASCII alphanumeric characters plus underscore and hyphen.
4

Send Referrer Setup Transaction

Build and send the transaction to initialize the referrer state on-chain.
5

Verify Short URL Resolution

Confirm that the short URL correctly resolves to the referrer wallet address.
Referrer setup complete. The short URL is active and can be shared with users to establish referral relationships.