Referral Rewards

Referral Rewards

There are two types of referral rewards in STP:

  1. Referral Codes
  2. Client Fee Referral Split

Referral Codes

Referral codes allow creators to incentivize growth by sharing a portion of revenue with people who refer subscribers.

Creators configure referral codes in the contract by specifying a unique numeric code, percentage, permanment flag, and optional account. When a subscriber mints a subscription with a referral code, the referrer receives a percentage of the minted time as a reward.

Referral codes can be created for a specific account or for all accounts. When a referral code is created for a specific account, only that account will be rewarded when the code is used. When a referral code is created for all accounts, any account can receive the reward.

Referral codes can be mutable or immutable. Once an immutable referral code is created, it can't be modified or destroyed. Mutable referral codes can updated or destroyed at any time.

Using the referral code requires calling mintAdvanced.

Client Fee Referral Split

Clients responsible for faciliating deployment have the option to allocate a portion of the client fee to referrers when no referral code is presented during mint time. For example, the client may have a fee of 300 basis points, and can allocate up to 300 basis points to share with referrers in the event a referral code isn't used.

Setting a Referral Code


Only the contract owner and managers can create referral codes

Referral codes are set by calling setReferralCode(uint256 code, uint16 basisPoints, bool permanent, address account).

Setting the basisPoints to 0 will delete the referral code, but only if permanent is false.

import {
} from '@withfabric/protocol-sdks/stpv2';
const create = await prepareCreateReferralCode({
  contractAddress: '0x...',
  code: 102973019237091232n,
  basisPoints: 250,
  permanent: false, // if true, the code can't be updated or deleted
  account: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', // optional (only this account will receive rewards)
const receipt = await create();

Minting with a Referral Code

Minting with a referral code requires calling the mintAdvanced function.

import {
} from '@withfabric/protocol-sdks/stpv2';
const mint = await prepareMintAdvanced({
  contractAddress: '0x...',
  referralCode: 31337n,
  referrer: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
  tierId: 0,
  recipient: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
  amount: 1_000_000_000_000n,
const receipt = await mint();