Fuul
  • INTRO
    • ⚑What is Fuul?
    • πŸ’ͺWhy use Fuul?
    • πŸ€”Use Cases
    • βš™οΈIntegration
    • πŸ”—Main Links
  • HOW IT WORKS
    • πŸ’ΈTypes of Rewards
    • βœ…Conversion Events
      • 1️⃣CLAMM LPs (e.g. Uniswap V3)
      • 2️⃣Constant LPs (e.g., Uniswap V2)
      • 3️⃣Lending & Borrowing
      • 4️⃣Staking
      • 5️⃣Token Holders
      • 6️⃣Custom Onchain Events
      • 7️⃣Custom Offchain Events
  • πŸ€‘Incentive Payouts
    • πŸ—ΏFixed Rewards
    • 🌊Variable Rewards
    • πŸ’°Pool Distribution
  • πŸ§‘β€πŸ€β€πŸ§‘Referrals
  • ♾️Attribution Methods
  • πŸ’²Budgets
  • ⚑Fuul Incentives Manager
  • πŸŽ–οΈLeaderboards
  • πŸ’»Incentives Hub
    • πŸ‘¨β€πŸ’»White-Label Implementation
    • πŸ‘No-Code
  • FOR DEVS
    • ⭐Getting started with Fuul Web SDK
    • βš™οΈSending Custom Events through the API
    • πŸ“„Tracking referrals in your app
    • πŸ‘¨β€πŸ’»API Key Management
    • πŸ› οΈBuilding your incentives hub in your app (white-label)
      • ℹ️Getting all incentives information
      • πŸ”—Creating affiliate links or codes
      • πŸ’―Getting Leaderboard Data
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ™‹Getting Individual Rewards
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ€™Claiming Onchain Rewards
    • πŸ”§Building widgets
    • πŸ“’Managing Audiences and Segments
      • πŸ‘€Getting User Audiences using Fuul SDK
      • πŸ‘₯Updating Audience Segments using Fuul API
    • ✈️Migration from older SDK versions
    • πŸ†˜Troubleshooting
  • PROTOCOL
    • ⛓️Smart Contracts
    • 🧡Subgraphs
  • Guides
    • ✏️Getting Started
      • Creating Your First Incentive Program
      • How to Add a Budget in Fuul
  • 🏁Creating Triggers & Conversions
    • Understanding Triggers Types
    • Creating an Event with CSV file
  • 🎨Program Incentive Page
    • Building no code landing pages
  • πŸ“ŠAnalytics
    • Understanding Sybil Detection
Powered by GitBook
On this page
  • Creating affiliates tracking links using Fuul SDK
  • Managing affiliate codes using Fuul SDK
  • Creating affiliate codes
  • Updating affiliate codes
  • Getting the affiliate code registered to an address
  • Checking if an affiliate code is free to use
  1. FOR DEVS
  2. Building your incentives hub in your app (white-label)

Creating affiliate links or codes

PreviousGetting all incentives informationNextGetting Leaderboard Data

Last updated 2 months ago

Creating affiliates tracking links using Fuul SDK

To create tracking links use the generateTrackingLink method. This generates a tracking link for the affiliate to share your program link.

import { Fuul } from ('@fuul/sdk');

const trackingLinkUrl = await Fuul.generateTrackingLink(
    baseURL, affiliateAddress)

// Returns
"http://yourwebsite.com?af=<affiliateAddressOrCode>"

baseURL: the URL of your website (where the pageview and connect wallet events are implemented)

affiliateAddress: the address of the affiliate. Usually, it is the one that is connected to the site.

You can find an example of two landing pages (one for creators and another one for end users) with the Fuul SDK integrated using next JS and RainbowKit in

Managing affiliate codes using Fuul SDK

By default, affiliate links have the af=affiliateAddress parameter to identify the affiliate that referred the click.

Fuul allows affiliates to create their own codes to hide their addresses and make prettier links.

Check out the following example to get a better idea.

// Without an affiliate code
"http://yourwebsite.com?af=0x1f9090aae28b8a3dceadf281b0f12828e676c326"

// With an affiliate code
"http://yourwebsite.com?af=my-affiliate-code"

Creating affiliate codes

Affiliates can create their codes on the Fuul Hosted solution, but projects can also choose to add the functionality to their website.

To create codes using the SDK, use the createAffiliateCode method.

import { Fuul } from ('@fuul/sdk');

await Fuul.createAffiliateCode({
  address: '0x12345',
  code: 'my-affiliate-code',
  signature: '0x12345',
  accountChainId: '1' // Only for smart contract wallets
})

address: the address of the affiliate. Usually, it is the one that is connected to the site.

code: the affiliate code to be created.

signature: the resulting signature of the address signing the following formatted message:

accountChainId: the chain id of the smart contract wallet. Do not include it when the wallet is an EOA.

I confirm that I am creating the ${{affiliateCode}} code on Fuul

E.g. I confirm that I am creating the my-affiliate-code code on Fuul

Return values

The method either succeeds and the code is registered or it throws one of the following errors:

ValidationError: The affiliate code has an invalid character. Codes can only be alphanumeric separated by dashes (-). E.g. my-affiliate-code

InvalidSignatureError: The signature is not valid for the address and message

AddressInUseError: The address has already created an affiliate code

CodeInUseError: The code has already been taken by another user

There is a character limit with a maximum of 30 characters.

Updating affiliate codes

To update an affiliate code, use the updateAffiliateCode method.

import { Fuul } from ('@fuul/sdk');

await Fuul.updateAffiliateCode({
  address: '0x12345',
  code: 'my-new-cool-code',
  signature: '0x123455',
  accountChainId: '1' // Only for smart contract wallets
})

address: the address of the affiliate. Usually, it is the one that is connected to the site

code: the new affiliate code

signature: the resulting signature of the address signing the following formatted message:

I confirm that I am updating my code to ${{affiliateCode}} on Fuul

E.g. I confirm that I am updating my code to my-affiliate-code on Fuul

accountChainId: the chain id of the smart contract wallet. Do not include it when the wallet is an EOA.

Return values

The method either succeeds and the code is registered or it throws one of the following errors:

ValidationError: The affiliate code has an invalid character. Codes can only be alphanumeric separated by dashes (-). E.g. my-affiliate-code

InvalidSignatureError: The signature is not valid for the address and message

CodeInUseError: The code has already been taken by another user

Getting the affiliate code registered to an address

To get the affiliate code for a specific address using the SDK, use thegetAffiliateCode method.

import { Fuul } from ('@fuul/sdk');

const affiliateCode = await Fuul.getAffiliateCode(
    '0x2d60a6F7Ce0ff573DD2A016DAb917C47Ffe1bA09')
    
// my-code

The return value will be either the code or null in case there is no code created for the input address.

Checking if an affiliate code is free to use

To check whether an affiliate code is free to use or taken using the SDK, use the isAffiliateCodeFree method.

import { Fuul } from ('@fuul/sdk');

const codeIsFree = await Fuul.isAffiliateCodeFree('my-code')

// True or false

The return value will be True if the code is free to use or False if it is already taken.

πŸ› οΈ
πŸ”—
this repo