🎯Referral Program with Token Rewards

Build a complete referral program where affiliates earn token rewards for each user they bring to your platform. By the end, you'll have tracking links, wallet attribution, a leaderboard, and a claiming flow.

Prerequisites

  • A Fuul account with a project created

  • Conversion events and payout rules configured in the dashboard

  • A funded budget (see How to Add a Budget)

  • Two API keys: send:tracking_event (frontend) and optionally send:trigger_event (backend)

Step 1: Install and initialize the SDK

npm install @fuul/sdk
import { Fuul } from '@fuul/sdk';

Fuul.init({ apiKey: 'your-send-tracking-event-key' });

Step 2: Track referral visits

Call sendPageview on every page load. The SDK captures the referrer's affiliate code from the URL (?af=code) automatically.

import { useEffect } from 'react';
import { Fuul } from '@fuul/sdk';

function App() {
  useEffect(() => {
    Fuul.sendPageview();
  }, []);

  return <YourApp />;
}

Step 3: Identify users on wallet connect

When a user connects their wallet, call identifyUser to link their wallet to the tracking session:

circle-info

At this point, attribution is complete. When this user converts (e.g., trades, deposits), Fuul automatically attributes the conversion to the referrer and calculates rewards.

Give affiliates a way to generate their referral links:

Affiliates can also create custom branded codes:

See Affiliate Links & Codes for the full API.

Step 5: Display the leaderboard

Show top affiliates ranked by token earnings:

See Leaderboard Data for points and volume leaderboards.

Step 6: Show individual rewards

Display a specific user's earnings:

See Individual Rewards for history and per-conversion breakdowns.

Step 7: Add claiming

Let users claim their token rewards onchain. The full implementation involves fetching signed claim checks and submitting a contract transaction:

  1. Show claimable balances β†’ Claim Flow Integration

  2. Fetch claim checks β†’ Get Claim Checks

  3. Submit the transaction β†’ EVM Claiming or SVM Claiming

Next steps

Feature
Guide

Add referral codes (user-generated, permanent attribution)

Enable multi-level referrals

Target specific user segments

Get notified on payouts

Add fraud prevention

Last updated