STP
Advanced Usage

Advanced Usage

Advanced functions are available for managing the contract. These functions are not required for normal operation.

Adjusting Global Supply Cap

ℹ️

Only the contract owner can adjust the supply cap.

The maxmimum number of subscribers can be adjusted using the setGlobalSupplyCap function. The supply cap can be set to any value greater or equal to the current supply. Additionally, the supply cap can be set to 0 to allow unlimited subscribers (default). This is in addition to tier specific supply caps.

import { prepareSetSupplyCap } from '@withfabric/protocol-sdks/stpv2';
 
const setCap = await prepareSetSupplyCap({
  contractAddress: '0x...',
  supplyCap: 1000n,
});
 
const receipt = await setCap();

Transfering Ownership

ℹ️

Only the contract owner can transfer ownership.

Transfers are two step, using transfer + accept. Transfers are started via the setPendingOwner function. This can be used to stage a backup owner, or to transfer ownership to a new owner.

import { prepareTransferOwnership } from '@withfabric/protocol-sdks/stpv2';
 
const transfer = await prepareTransferOwnership({
  contractAddress: '0x...',
  newOwner: '0x...',
});
 
const receipt = await transfer();

Accepting Ownership

ℹ️

Only the PENDING contract owner can accept ownership

Once a transfer is started, the pending owner must call acceptOwnership to complete the transfer.

import { prepareAcceptOwnership } from '@withfabric/protocol-sdks/stpv2';
 
const accept = await prepareAcceptOwnership({
  contractAddress: '0x...',
});
 
const receipt = await accept();

Recovering Misplaced Tokens

In the event that tokens are accidentally sent to the contract, they can be recovered using the recoverCurrency(address tokenAddress, address recipientAddress, uint256 tokenAmount) function. This will also work for native tokens if tokenAddress is set to 0x0.

ℹ️

Only the contract owner can reconcile the ERC20 balance.

ℹ️

This function will revert if tokenAddress matches the contract's denominated currency token.

import { prepareRecoverCurrency } from '@withfabric/protocol-sdks/stpv2';
 
const recover = await prepareRecoverCurrency({
  contractAddress: '0x...',
  tokenAddress: '0x...',
  recipientAddress: '0x...',
  tokenAmount: 1000n,
});
 
const receipt = await recover();