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
  • Response
  • Examples
  1. Developers
  2. SDK
  3. Classes and Functions
  4. ChainvineUser

joinCampaign([campaignParams,])

Send a request to join a user to a referral program/campaign.

const campaignId = '02jd020jkd-302jdi2d-02ij0dj';

await userClient.joinCampaign(
   {
      campaign: {
         id: campaignId
      },
      referrer: 'ABC1245' //optional
   }
)

Params

Param
Required
Type
Description

campaign.id

required

String

referrer

optional

String

the referrer's referral code - if passed in, a referral linking will be attempted. No referral will be made if the user was already referred.

Response

void

Examples

Joining a referred user in a gated referral program so a user can become a referrer

In both browser and Server-side examples, we're able to provide an optional referrerId to link the referrer to the joining user if they were referred.

In this example we use the getReferrerId utility to fetch a referrerId from the browser session. If a referrer Id was saved before .joinCampaign is called, it

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

const referrer = getReferrer();
const userWalletAddress = '0x293kdo0ij0';
const campaignId = 'aSlug23';
const wallet = 'Hiodn2oD2dkmo2';

const client = new ChainvineClient(); //Make sure to whitelist your domain
const userClient = await client.syncUser(userWalletAddress);

await userClient.joinCampaign(
   {
      campaign: {
         id: campaignId
      },
      referrer, //Optional
   }
)
import { ChainvineClient } from '@chainvine/sdk';

const referrer = 'aReferralCode';
const userWalletAddress = '0x293kdo0ij0';
const campaignId = 'aSlug23';
const wallet = 'Hiodn2oD2dkmo2';

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

await userClient.joinCampaign(
   {
      campaign: {
         id: campaignId
      },
      referrer, //Optional
   }
)

PreviousInitializing the clientNextgetRequirement([payload,])

Last updated 1 year ago

the the user should be added to. Note: this campaign/program must belong to your account.

⚙️
🧰
id of the program/campaign