Privileged Roles
There are several roles in the STP contract. Each role has different permissions. Owners can grant specific roles to other accounts to delegate responsibilities. This is helpful when the owner is a DAO or multisig.
- Owner
- Manager
- Agent
- Issuer
- Protocol Fee Recipient
- Client Fee Recipient
Owner Role
The owner is set to the creator (msg.sender) address upon deployment, unless otherwise specified. The owner has complete control over the contract. The exclusive controls of the owner are as follows:
- Creating or revoking Managers and Agents
setRoles
- Transferring ownership
setPendingOwner
- Updating the Transfer Recipient
setTransferRecipient
- Withdrawing funds to any address other than the transfer recipient
tranferFunds
- Refunding subscribers with contract funds
refund
- Token recovery
recoverCurrency
Manager Role
Managers can control nearly all metadata in the contract. Managers can do the following:
- Grant Time
grantTime
- Revoke Time
revokeTime
- Update Metadata URL
setMetadataURL
- Set Global Supply Cap
setGlobalSupplyCap
- Create Tiers
createTier
- Update Tiers
updateTier
- Manage Referral Codes
setReferralCode
- Create Reward Curves
createRewardCurve
Agent Role
Agents are designed to grant and revoke time to subscribers. Agents can do the following:
- Grant Time
grantTime
- Revoke Time
revokeTime
Issuer Role
Issuers are intended to allow reward pool share issuance for off-chain or on-chain activities beyond minting subscriptions. Privileges:
- Issue Reward Shares
issueRewardShares
Protocol Fee Recipient
The protocol fee recipient is the address that receives the protocol fee. The protocol fee is a percentage of the subscription price. The protocol fee recipient can do the following:
- Update the protocol fee recipient
updateProtocolFeeRecipient
- Remove protocol fees
updateProtocolFeeRecipient(0x0)
updateProtocolFeeRecipient
must be invoked via the factory contract updateProtocolFeeRecipient
, which supports multicall
Client Fee Recipient
The client fee recipient is the address that receives the client fee. The client fee is a percentage of the subscription price. The client fee recipient can do the following:
- Update the client fee recipient
updateClientFeeRecipient
- Remove client fees
updateClientFeeRecipient(0x0)
updateClientFeeRecipient
must be invoked via the factory contract updateClientFeeRecipient
, which supports multicall
Setting Roles
Only the contract owner can grant and revoke roles
Roles can be set using the setRoles
function. The roles are represented as a bitmask. The following roles are available:
- ROLE_MANAGER = 1
- ROLE_AGENT = 2
- ROLE_ISSUER = 4
import {
prepareSetRoles,
Role,
} from '@withfabric/protocol-sdks/stpv2';
// Add MANAGER and ISSUER roles to the account
const grant = await prepareSetRoles({
contractAddress: `0x...`,
account: `0x...`,
roles: [Role.MANAGER, Role.ISSUER],
});
const receipt = await grant();
// Revoke
const revoke = await prepareSetRoles({
contractAddress: `0x...`,
account: `0x...`,
roles: [],
});
const receipt2 = await revoke();
Factory Owner
The factory owner is the owner of the factory contract. The factory owner can do the following:
- Initiate ownership transfer
setPendingOwner
- Set the protocol fee recipient
setProtocolFeeRecipient
- Set a deploy fee
setDeployFee