Tide Referral SDK


The Tide Referral SDK (Software Development Kit) is an npm library that enables you to integrate referral tracking and management functionality into your web applications. With the Tide SDK, you can effortlessly implement referral campaigns and track user actions. This documentation will guide you through the features and usage of the library.


To get started, you need to install the library as a dependency in your project. You can use npm or yarn to install the package:
npm install tide-sdk
yarn add tide-sdk



Before using any functionality of the library, you need to initialize it with the provided configuration. The initialize function sets up the SDK with the necessary authentication token. Here's an example:
import TideSDK from 'tide-sdk';
const config = {
AUTH_TOKEN: 'your-auth-token',
Make sure to replace 'your-auth-token' with your actual authentication token.

Create a new referred user

To track and manage referrals, you need to identify users by their address and referral code. The identify function should be called whenever a new user connects their wallet to your site. It associates the user's address and referral code with their account. Here's an example of how to use the identify function:
import TideSDK from 'tide-sdk';
const address = 'user-address';
const referralCode = 'referral-code';
TideSDK.referrals.identify(address, referralCode);
Replace 'user-address' with the actual user's Ethereum address and 'referral-code' with the referral code provided in the tide_ref query parameter.

Completing a Referral

When a user successfully completes a specific action on your site, such as minting an NFT or making a purchase, you should call the completeReferral function. This function marks the referral as completed and tracks the user's action. Here's an example of how to use the completeReferral function:
import TideSDK from 'tide-sdk';
const address = 'user-address';
try {
const referralCompleted = await TideSDK.referrals.completeReferral(address);
} catch(err) {
console.log("referral failed!")
Replace 'user-address' with the actual user's Ethereum address. The completeReferral function returns true if the referral was successfully completed. If an error occurs or the referral completion fails, it returns false and throws an error with the reason for failure.

Error Handling

The Tide SDK provides error codes and messages to help you handle errors gracefully. The following error codes are available:
  • SdkErrors.MISSING_TOKEN: Thrown when the authentication token is missing.
  • SdkErrors.INVALID_ADDRESS: Thrown when the provided address is invalid.
  • SdkErrors.TOKEN_EXPIRED: Thrown when the authentication token has expired.


To help you get started quickly and see our library in action, we have prepared a working example that demonstrates the usage of our SDK. This example provides practical implementation scenarios and serves as a valuable reference for understanding how to integrate our library into your projects.
You can find these working examples at the following link: Example Repository
Note: Please make sure to follow the provided instructions and requirements specific to the example to ensure a smooth and successful implementation.