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');consttrackingLinkUrl=awaitFuul.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 this repo
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.
The message to sign must follow this exact format:
I confirm that I am creating the ${{affiliateCode}} code
E.g. I confirm that I am creating the my-affiliate-code code
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.
The message to sign must follow this exact format:
I confirm that I am updating my code to ${{affiliateCode}}
E.g. I confirm that I am updating my code to my-affiliate-code
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.
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.
The return value will be True if the code is free to use or False if it is already taken.
import { Fuul } from ('@fuul/sdk');
await Fuul.createAffiliateCode({
userIdentifier: "0x12345", // the address of the user
identifierType: "evm_address", // evm_address | solana_address | xrpl_address
signature: "0x123485090123",
signaturePublicKey: '0x12345' // Only for XRPL type signatures
code: 'my-affiliate-code',
accountChainId: '1' // Only for smart contract wallets
})
import { Fuul } from ('@fuul/sdk');
await Fuul.updateAffiliateCode({
userIdentifier: "0x12345", // the address of the user
identifierType: "evm_address", // evm_address | solana_address | xrpl_address
signature: "0x123485090123",
signaturePublicKey: '0x12345' // Only for XRPL type signatures
code: 'my-new-cool-code',
accountChainId: '1' // Only for smart contract wallets
})