SHILLBILL
  • About ShillBill
  • Overview
    • Get started on Solana
    • How to Use ShillBill
    • How to Shill
    • Fee Structure
  • Use Cases
    • Integration Guide
    • Ads Integration
  • Official Links
    • Website
    • Twitter
    • Telegram
Powered by GitBook
On this page
  • Overview
  • Key Parameters
  • How to Find Your userId
  • Code Example
  • Example Output
  1. Use Cases

Integration Guide

This guide helps third-party developers generate referral links for integration into their bots (Telegram, Twitter, Discord, etc.) using the ShillBill system. These links allow users to earn referral fees from token purchases initiated via their custom ShillBill links.

To receive referral rewards, your SB account must have at least 0.01 SOL on the balance.

Overview

The code below generates referral links that combine:

  • A token address (Base58-encoded SPL token from Solana)

  • A user ID (the ShillBill user earning referral fees)

  • A buy type (small, regular, or large), selected via link prefix: bl_, b_, br_

Key Parameters

  • token: The Base58-encoded SPL token address to promote.

  • userId: The ShillBill user ID of the person who will receive referral rewards.

  • Buy Type Prefix The referral link uses a prefix to indicate buy intent:

    • bl_ → small buy

    • b_ → standard buy

    • br_ → large buy

How to Find Your userId

  1. Tap Menu → Refer friends

  2. You’ll get a referral link similar to:

    https://t.me/Shill_Bill_bot?start=ref_68c888febe18a1fc03b5190z
  3. Extract the user ID from the link:

    68c888febe18a1fc03b5190z

Code Example

import base64url from "base64url";
import { base58_to_binary } from "base58-js";
import { ObjectId } from 'bson';

/**
 * Merges two arrays with a prefix byte
 * @param {Uint8Array} arr1 - First array
 * @param {Uint8Array} arr2 - Second array
 * @returns {Buffer} Combined buffer with prefix
 */
function mergeWithPrefixByte(arr1, arr2) {
  const totalLength = 1 + arr1.length + arr2.length;
  const combined = Buffer.alloc(totalLength);

  combined[0] = 1;
  Buffer.from(arr1).copy(combined, 1);
  Buffer.from(arr2).copy(combined, 1 + arr1.length);

  return combined;
}

/**
 * Generates a token reference by combining user ID and token
 * @param {string} token - Base58 encoded token
 * @param {string} userId - User ID
 * @returns {string} Base64URL encoded token reference
 */
function generateTokenRef(token, userId) {
  const tokenData = base58_to_binary(token);
  const userData = new ObjectId(userId).id;

  return base64url(mergeWithPrefixByte(userData, tokenData));
}

/**
 * Generates all three types of referral links
 * @param {string} token - Base58 encoded token
 * @param {string} userId - User ID
 * @returns {Object} Object containing all three referral links
 */
function generateReferralLinks(token, userId) {
  const botLink = 'https://t.me/Shill_Bill_bot';
  const tokenRef = generateTokenRef(token, userId);

  return {
    buySmall: `${botLink}?start=bl_${tokenRef}`,
    buy: `${botLink}?start=b_${tokenRef}`,
    buyLarge: `${botLink}?start=br_${tokenRef}`
  };
}

// Example usage
const token = 'znv3FZt2HFAvzYf5LxzVyryh3mBXWuTRRng25gEZAjh';
const userId = '68c888febe18a1fc03b5190z';

const referralLinks = generateReferralLinks(token, userId);
console.log('Referral Links:', referralLinks);

Example Output

{
  buySmall: 'https://t.me/Shill_Bill_bot?start=bl_<encodedRef>',
  buy:      'https://t.me/Shill_Bill_bot?start=b_<encodedRef>',
  buyLarge: 'https://t.me/Shill_Bill_bot?start=br_<encodedRef>'
}

PreviousFee StructureNextAds Integration

Last updated 1 month ago

Open the .

ShillBill Telegram Bot