Link a user to a given referrer - this creates a relationship between the two on ChainVine, allowing us to attribute rewards to the referrer based on the user's activity
constcampaign= { id:'your-campaign-id',}constreferrer=getReferrer();//Or manually fetch from URL if not using cookiesif (referrer) {await userClient.referral({ campaign }).linkToReferrer(referrer);}
Params
Param
Required
Type
Description
Examples
import { ChainvineClient, getReferrerId } from'@chainvine/sdk';constuserWalletAddress='0x293kdo0ij0';constcampaignId='siojdp2no';constreferrer=getReferrer();//Or manually fetch from URL if not using cookiesconstclient=newChainvineClient(); //Make sure to whitelist your domainconstuserClient=awaitclient.syncUser(userWalletAddress);constreferralUrlResponse=await userClient.referral({ campaign }).linkToReferrer(referrer);
import { ChainvineClient } from'@chainvine/sdk';constuserWalletAddress='0x293kdo0ij0';constcampaignId='siojdp2no';constreferrer='abc123';// Generate your ChainvineClient instanceconstclient=newChainvineClient({ apiKey:'0dj03j000d'// Your API Key});constuserClient=awaitclient.syncUser(userWalletAddress);constreferralUrlResponse=await userClient.referral({ campaign }).linkToReferrer(referrer);
campaign.id
required
string
the id of the program/campaign requirement belongs to