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

ParamRequiredTypeDescription

campaign.id

required

String

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

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
   }
)

Last updated