Referral Codes
Manage user referral codes through the Fuul SDK. These methods let you list, generate, check, and use referral codes as well as get invitation statuses.
List invite codes
To get the invite codes for a user use the listUserInviteCodes method.
const result = await Fuul.listUserReferralCodes({
user_identifier: '0x12345',
user_identifier_type: UserIdentifierType.EvmAddress,
});Invitation Status
This method gets the invitation status of the user, including whether they were invited and with which code.
const status = await Fuul.getInvitationStatus({
user_identifier: '0x12345',
user_identifier_type: UserIdentifierType.EvmAddress
});
if (status.invited) {
console.log('User was referred with code:', status.code);
}Check Referral Code
To check whether a code is free to use the checkReferralCode method.
const result = await Fuul.checkReferralCode({ code: 'abc1234' });
if (result.is_free) {
console.log('Referral code is available!');
}Accept Referral
To accept the referral and consume the code use the useReferralCode method.
await Fuul.useReferralCode({
code: 'abc1234',
user_identifier: '0x12345',
user_identifier_type: UserIdentifierType.EvmAddress,
signature: '0xaad9a0b62f87c15a248cb99ca926785b828b5',
signature_message: 'I am using referral code abc1234'
accountChainId: 1 // For smart contract accounts
});The signed message should have the following structure: I am using invite code ${code}
Last updated