linkToReferrer(referrer)

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

const campaign = { id:'your-campaign-id',}
const referrer = getReferrer();//Or manually fetch from URL if not using cookies

if (referrer) {
  await userClient
    .referral({ campaign })
    .linkToReferrer(referrer);
}

Params

ParamRequiredTypeDescription

campaign.id

required

string

the id of the program/campaign requirement belongs to

referrer

required

string

the referrer to link the user to

Examples

import { ChainvineClient, getReferrerId } from '@chainvine/sdk';

const userWalletAddress = '0x293kdo0ij0';
const campaignId = 'siojdp2no';
const referrer = getReferrer();//Or manually fetch from URL if not using cookies

const client = new ChainvineClient(); //Make sure to whitelist your domain

const userClient = await client.syncUser(userWalletAddress);
const referralUrlResponse = await userClient
  .referral({ campaign })
  .linkToReferrer(referrer);

Last updated