ChainVine API Docs
  • Chainvine
    • Product and Features
    • Technical Overview
  • ⚙️Developers
    • 🔨Use Cases
      • Leverage cookies
      • Link Claimer/Referrer
      • Record Link Click
      • Generate a Referrer Link
      • Record a Transfer Event
      • Complete a Requirement
    • 🖼️Embedded Widget
      • Implementation
      • FAQ
    • 🧰SDK
      • Implementation
      • Configuring the Client
      • Classes and Functions
        • Utility Methods
        • ChainvineClient
          • getReferralUrl(walletAddress)
          • recordClick(referrer)
          • linkReferrer([payload,])
          • referralConversion([payload,])
          • syncUser(walletAddress)
          • getCampaignReferralStats([payload,])
        • ChainvineUser
          • Initializing the client
          • joinCampaign([campaignParams,])
          • getRequirement([payload,])
          • getUserStats([payload,])
          • verifyRequirement([payload,])
          • completeRequirement([payload,])
          • claimEligibleEarnings([payload,])
          • transferEvent([payload,])
          • referral([campaignParams,])
            • linkToReferrer(referrer)
            • url()
          • setRewardTiersOverride([payload,])
        • Errors
        • Authentication
          • Getting your API Key
          • Allow-listing a domain
      • FAQ
    • 🪝Webhooks
    • 📔Open API Specification
  • Rewards
    • Claiming For Users
      • On ChainVine
Powered by GitBook
On this page
  • Params
  • Examples
  1. Developers
  2. SDK
  3. Classes and Functions
  4. ChainvineUser
  5. referral([campaignParams,])

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

Param
Required
Type
Description

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);
import { ChainvineClient } from '@chainvine/sdk';

const userWalletAddress = '0x293kdo0ij0';
const campaignId = 'siojdp2no';
const 
referrer = 'abc123';

// Generate your ChainvineClient instance
const client = new ChainvineClient({
    apiKey: '0dj03j000d'  // Your API Key
});

const userClient = await client.syncUser(userWalletAddress);
const referralUrlResponse = await userClient
  .referral({ campaign })
  .linkToReferrer(referrer);
Previousreferral([campaignParams,])Nexturl()

Last updated 1 year ago

⚙️
🧰