Advanced Protocol Usage
Advanced functions are available for managing the contract. These functions are not required for normal operation.
Pausing and Unpausing
Only the contract owner can pause and unpause minting.
The contract can be paused and unpaused using Pausable (opens in a new tab). Pausing the contract only prevents mints and renewals. All other functions remain callable.
import { preparePause, prepareUnpause } from '@withfabric/protocol-sdks/stpv1';
// Pause the contract
const pause = await preparePause({
contractAddress: '0x...',
});
const pauseReceipt = await pause();
// Unpause the contract
const unpause = await prepareUnpause({
contractAddress: '0x...',
});
const unpauseReceipt = await unpause();
Adjusting Supply Cap
Only the contract owner can adjust the supply cap.
The maxmimum number of subscribers can be adjusted using the setSupplyCap
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).
import { prepareSetSupplyCap } from '@withfabric/protocol-sdks/stpv1';
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 Ownable2Step (opens in a new tab). Transfers are started via the transferOwnership
function.
This can be used to stage a backup owner, or to transfer ownership to a new owner.
import { prepareTransferOwnership } from '@withfabric/protocol-sdks/stpv1';
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/stpv1';
const accept = await prepareAcceptOwnership({
contractAddress: '0x...',
});
const receipt = await accept();
ERC-20 Reconciliation
Only the contract owner can reconcile the ERC20 balance.
For ERC20 denominated contracts, it's possible that an account accidentally transfers tokens to the contract by interacting directly with the ERC20 contract.
If that happens, the reconcileERC20Balance
function can be called to reconcile the balance of the contract with the ERC20 contract, making the funds available for withdrawal.
These funds could be used to pay for a subscription using the mintFor
function.
import { prepareReconcileERC20Balance } from '@withfabric/protocol-sdks/stpv1';
const reconcile = await prepareReconcileERC20Balance({
contractAddress: '0x...',
});
const receipt = await reconcile();
ERC-20 Recovery
Not supported for the contract's denominated ERC20 token. Use reconcileERC20Balance
instead.
Only the contract owner can recover ERC20 tokens.
If any ERC20 tokens are transferred to the contract unintentionally, they can be recovered using the recoverERC20
function.
import { prepareRecoverERC20 } from '@withfabric/protocol-sdks/stpv1';
const recover = await prepareRecoverERC20({
contractAddress: '0x...',
erc20Address: '0x...',
recipient: '0x...',
amount: 31337n,
});
const receipt = await recover();
Native Token Reconciliation
Only supported for contracts denominated with native tokens. For ERC-20 denominated contracts use recoverNativeTokens
instead.
Only the contract owner can recover native tokens.
If native tokens are transferred to the contract unintentionally (via selfdestruct, etc), they can be reconciled using the reconcileNativeBalance
function.
import { prepareReconcileNativeBalance } from '@withfabric/protocol-sdks/stpv1';
const recover = await prepareReconcileNativeBalance({
contractAddress: '0x...',
});
const receipt = await recover();
Native Token Recovery
Not supported for contract denominated with native tokens. Use reconcileNativeBalance
instead.
Only the contract owner can recover native tokens.
If native tokens are transferred to the contract unintentionally (via selfdestruct, etc), they can be recovered using the recoverNativeTokens
function.
import { prepareRecoverNativeTokens } from '@withfabric/protocol-sdks/stpv1';
const recover = await prepareRecoverNativeTokens({
contractAddress: '0x...',
recipient: '0x...',
});
const receipt = await recover();
Renouncing Ownership
This is a dangerous call. Once ownership is renounced, it cannot be recovered.
Only the contract owner can renounce ownership.
The owner can renounce ownership of the contract using Ownable (opens in a new tab). This will transfer funds, pause minting, and prevent all ownable functions from being called. This is intended to be used for shutting down a subscription.