Skip to main content

mQuarkSubscriber

It is responsible for managing the subscriptions, unlocking tokens, transferring URIs, setting subscription prices, and other necessary settings by the protocol.

Functions

setRegistryAddress

function setRegistryAddress(address _registry) external

Sets the address of the registry contract.

Parameters:

NameTypeDescription
_registryaddressThe address of the registry contract to be set

setRoyalty

  function setRoyalty(uint256 _royalty) external;

Sets the royalty percentage for the subcription.

Parameters:

NameTypeDescription
_royaltyuint256The royalty percentage to be set.

setControllerAddress

function setControllerAddress(address _controller) external

Sets the address of the controller contract for the collection.

Parameters:

NameTypeDescription
_controlleraddressThe address of the controller contract to be set

setImportedContractsAddress

 function setImportedContractsAddress(address _importedContracts) external

Sets the address of the controller contract for the collection.

Parameters:

NameTypeDescription
_importedContractsaddressThe address of the imported contracts interface contract to be set

setDefaultURI

 function setDefaultURI(
uint256 _entityId,
string calldata _defaultURI
) external

Sets the default URI of an entity. It is used to place in the subscription slot when a token is subscribed for the first time.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity to set the default URI for
_defaultURIaddressThe new default URI to be set

setSubscriptionPrice

  function setSubscriptionPrice(uint256 _entityId, uint256 _price) external

Sets the subscription price required to subscribe to an entity.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity to set the default URI for
_priceuint256The new subscription price to be set

setSigner

 function setSigner(uint256 _entityId, address _signer) external

Sets the signer address for an entity.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity to set the default URI for
_signeruint256The new signer address to be set

setCollection

 function setCollection(
bool _free,
bool _external,
uint256 _entityId,
uint256 _templateId,
address _collectionAddress
) external

Sets the configuration for a collection.

Parameters:

NameTypeDescription
_freeboolIndicating if the collection is free
_externalboolIndicating if the collection is external
_entityIduint256The ID of the entity the collection belongs to
_templateIduint256The ID of the template associated with the collection
_collectionAddressaddressThe address of the collection contract

subscribeToEntity

  function subscribeToEntity(
uint256 _tokenId,
address _tokenContract,
uint256 _subscriptionId,
bool _directUpdateEnabled
) external payable

Allows a user to subscribe to a collection by paying the subscription price. If true, direct update allows the entity to update the URI slot of the token without the user's approval.

Parameters:

NameTypeDescription
_tokenIdboolThe ID of the token being subscribed to
_tokenContractboolThe address of the token contract
_subscriptionIduint256The ID of the subscription being purchased
_directUpdateEnabledboolIndicating if direct update is enabled

subscribeToEntities

 function subscribeToEntities(
uint256 _tokenId,
address _tokenContract,
uint256[] calldata _subscriptionIds,
bool[] calldata _directUpdateEnabled
) external payable

Allows a user to subscribe to a collection by paying the subscription price.If true, direct update allows the entity to update the URI slot of the token without the user's approval.

Parameters:

NameTypeDescription
_tokenIdboolThe ID of the token being subscribed to
_tokenContractboolThe address of the token contract
_subscriptionIdsuint256[]The ID of the subscription being purchased
_directUpdateEnabledbool[]Indicating if direct update is enabled

updateURISlot

function updateURISlot(bytes calldata _signature, bytes calldata _updateInfo) external

Makes a call to the mQuark contract to update the URI slot of a single token. The function expects the update information to be encoded as bytes since token owners will have only one parameter instead of five separate parameters.

Parameters:

NameTypeDescription
_signatureboolThe ID of the token being subscribed to
_updateInfoboolEncoded and hashed(SHA-256) data containing the following:
NameTypeDescription
entityaddressAddress of the entity that is responsible for the slot
entityIduint64ID of the entity
tokenContractaddressContract address of the given token
tokenIduint256Token ID
updatedUristringThe newly generated URI for the token

directUpdateURISlot / directUpdateURISlots

function directUpdateURISlot(
bytes calldata _signature,
bytes calldata _updateInfo,
bool _isSlotURIUpdate,
) external
function directUpdateURISlots(
bytes[] calldata _signatures,
string[] calldata _updatedUris,
uint256[] calldata _tokenIds,
uint256 _entityId,
address _contractAddress,
bool _isSlotURIUpdate
) external

Subscribed Entity can make a call to the contract to update the URI slot of a single token. The function expects the update information to be encoded as bytes since token owners will have only one parameter instead of five separate parameters.

Parameters:

NameTypeDescription
_signatureboolThe ID of the token being subscribed to
_updateInfoboolEncoded and hashed(SHA-256) data containing the following:
_isSlotURIUpdateboolIndicating if the update is for a slot URI or a token URI
NameTypeDescription
entityaddressAddress of the entity that is responsible for the slot
entityIduint64ID of the entity
tokenContractaddressContract address of the given token
tokenIduint256Token ID
updatedUristringThe newly generated URI for the token

unlockToken

function unlockToken(uint256 _tokenId, address _tokenContract) external payable

Allows a user to unlock a token by paying the required fee.

Parameters:

NameTypeDescription
_tokenIduint256The ID of the token to unlock
_tokenContractaddressThe contract address of the token

transferTokenEntityURI

function transferTokenEntityURI(
SellOrder calldata seller,
BuyOrder calldata buyer,
bytes calldata sellerSignature,
bytes calldata buyerSignature
) external payable

Makes a call to mQuark to transfer an entity slot URI of a single token to another token's the same entity slot.

Parameters:

NameTypeDescription
sellerSellOrderThe struct containing the sell order details
buyerBuyOrderThe struct containing the buy order details
sellerSignaturebytesSigned data by the seller's wallet
buyerSignaturebytesSigned data by the buyer's wallet

withdraw

function withdraw(
uint256 _entityId,
uint256 _amount
) external

Allows the owner of an entity to withdraw a certain amount of Ether from their entity's balance.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity
_amountuint256The amount of Ether to withdraw

withdrawProtocol

function withdrawProtocol(uint256 _amount) external

Allows the default admin role to withdraw a certain amount of Ether from the protocol balance.

Parameters:

NameTypeDescription
_amountuint256The ID of the entity

getCollection

function getCollection(
address _contractAddress
)
external
view
noDelegateCall
returns (uint256 entityId, uint256 templateId, bool free, bool isExternal, address collectionAddress)

Retrieves information about a collection based on its contract address.

Parameters:

NameTypeDescription
_contractAddress_contractAddressThe contract address of the collection

Return Values:

NameTypeDescription
entityIduint256The ID of the entity associated with the collection
templateIduint256The ID of the template associated with the collection
freeboolIndicates if the collection is free
isExternalboolIndicates if the collection is an external contract
collectionAddressaddressThe contract address of the collection

getIsSubscribed

function getIsSubscribed(
uint256 _tokenId,
address _tokenContract,
uint64 _subscriptionId
) external view returns (bool)

Checks if a token is subscribed to a specific subscription ID.

Parameters:

NameTypeDescription
_tokenIduint256The ID of the token
_tokenContractaddressThe contract address of the token
_subscriptionIduint64The ID of the subscription

Return Values:

TypeDescription
booltrue if the token is subscribed to the specified subscription ID, otherwise false

getIsUnlocked

function getIsUnlocked(uint256 _tokenId, address _tokenContract) external view returns (bool)

Checks if a token is unlocked.

Parameters:

NameTypeDescription
_tokenIduint256The ID of the token
_tokenContractaddressThe contract address of the token

Return Values:

TypeDescription
booltrue if the token is unlocked, otherwise false

getEntityConfig

  function getEntityConfig(
uint256 _entityId
)
external
view
returns (uint256 entityId, uint256 subscriptionPrice, string memory defaultURI, bool uriSet, address signer)

Retrieves the configuration of an entity.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity

Return Values:

NameTypeDescription
_entityIduint256The ID of the entity
subscriptionPriceuint256The subscription price of the entity
defaultURIstringThe default URI of the entity
uriSetboolIndicates if the URI is set for the entity
signeraddressThe address of the signer for the entity

getEntityBalance

function getEntityBalance(uint256 _entityId) external view returns (uint256)

Retrieves the balance of an entity.

Parameters:

NameTypeDescription
_entityIduint256The ID of the entity

Return Values:

TypeDescription
uint256The balance of the entity

getIsAddressRegisteredAsEntity

 function getIsAddressRegisteredAsEntity(address _address) external view returns (bool)

Returns a boolean indicating whether an address is registered as an entity.

Parameters:

NameTypeDescription
_addressaddressThe address to check

Return Values:

TypeDescription
boolA boolean indicating if the address is registered as an entity

calculateBatchSubscriptionPrice

 function calculateBatchSubscriptionPrice(uint256[] calldata _subscriptionIds) public view returns (uint256)

Calculates the total subscription price for a batch of subscription IDs.

Parameters:

NameTypeDescription
_subscriptionIdsuint256[]The array of subscription IDs

Return Values:

TypeDescription
boolThe total subscription price

Events

WithdrawProtocol

 event WithdrawProtocol(address to, uint256 amount);

Emitted when protocol funds are withdrawn to a specified address.

Parameters:

NameTypeDescription
toaddressThe address to which the funds are withdrawn.
amountaddressThe amount of funds withdrawn.

Withdraw

  event Withdraw(uint256 entityId, address to, uint256 amount);

Emitted when funds are withdrawn from an entity to a specified address.

Parameters:

NameTypeDescription
entityIduint256The ID of the entity from which funds are withdrawn.
toaddressThe address to which the funds are withdrawn.
amountaddressThe amount of funds withdrawn.

RoyaltySet

  event RoyaltySet(uint256 royalty);

Emitted when the royalty percentage is set.

Parameters:

NameTypeDescription
royaltyuint256The new royalty percentage.

RegistrySet

  event RegistrySet(address registry);

Emitted when the registry contract address is set.

Parameters:

NameTypeDescription
registryaddressThe address of the registry contract.

ControllerSet

  event ControllerSet(address controller);

Emitted when the controller contract address is set.

Parameters:

NameTypeDescription
controlleraddressThe address of the controller contract.

Unlocked

event Unlocked(uint256 tokenId, address tokenContract, address to, uint256 amount);

Emitted when a token is unlocked.

Parameters:

NameTypeDescription
tokenIduint256The ID of the unlocked token.
tokenContractaddressThe address of the token contract.
toaddressThe address to which the unlocked token is transferred.
amountuint256The amount of unlocked tokens transferred.

URISlotUpdated

event URISlotUpdated(uint256 entityId, address tokenContract, uint256 tokenId, string updatedUri);

Emitted when the URI slot of a token is updated.

Parameters:

NameTypeDescription
entityIduint256The ID of the entity associated with the token.
tokenContractaddressThe address of the token contract.
tokenIduint256The ID of the token whose URI slot is updated.
updatedUristringThe updated URI value.

SubscribedBatch

event SubscribedBatch(
uint256 tokenId,
address tokenContract,
uint256[] subscriptionIds,
address to,
string[] defaultUris,
uint256 amount
);

Emitted when multiple subscriptions are made in batch.

Parameters:

NameTypeDescription
tokenIduint256The ID of the token for which the subscriptions are made.
tokenContractaddressThe address of the token contract.
subscriptionIdsuint256[]The IDs of the subscriptions made.
toaddressThe address to which the token is subscribed.
defaultUrisstring[]The default URIs associated with the subscriptions.
amountuint256The total amount paid for the subscriptions.

Subscribed

event Subscribed(
uint256 tokenId,
address tokenContract,
uint256 subscriptionId,
address to,
string defaultUri,
uint256 amount
);

Emitted when a single subscription is made.

Parameters:

NameTypeDescription
tokenIduint256The ID of the token for which the subscriptions are made.
tokenContractaddressThe address of the token contract.
subscriptionIduint64The ID of the subscription made.
toaddressThe address to which the token is subscribed.
defaultUristringThe default URI associated with the subscription.
amountuint256The total amount paid for the subscriptions.

SubscriptionPriceSet

 event SubscriptionPriceSet(uint256 entityId, uint256 price);

Emitted when the subscription price is set for an entity.

Parameters:

NameTypeDescription
entityIduint256The ID of the entity for which the default URI is set.
priceuint256The subscription price.

DefaultURISet

 event DefaultURISet(uint256 entityId, string defaultURI);

Emitted when the default URI is set for an entity.

Parameters:

NameTypeDescription
entityIduint256The ID of the entity for which the default URI is set.
defaultURIstringThe default URI.

EntityInitialized

 event EntityInitialized(address contractAddress, uint256 entityId, address signer, string defaultURI, uint256 price);

Emitted when an entity is initialized.

Parameters:

NameTypeDescription
contractAddressaddressThe address of the entity contract.
entityIduint256The ID of the entity.
signeraddressThe address of the entity signer.
defaultURIstringThe default URI associated with the entity.
priceuint256The subscription price of the entity.

TokenEntityUriTransferred

 event TokenEntityUriTransferred(
address fromTokenContract,
uint256 fromTokenId,
address toTokenContract,
uint256 toTokenId,
uint256 entityId,
uint256 price,
string uri,
address from,
address to
);

Emitted when the entity URI of a token is transferred to another token.

Parameters:

NameTypeDescription
fromTokenContractaddressThe address of the token contract from which the entity URI is transferred.
fromTokenIduint256The ID of the token from which the entity URI is transferred.
toTokenContractaddressThe address of the token contract to which the entity URI is transferred.
toTokenIduint256The ID of the token to which the entity URI is transferred.
entityIduint256The ID of the entity associated with the entity URI.
priceuint256The price associated with the entity URI transfer.
uristringThe entity URI being transferred.
fromaddressThe address from which the entity URI is transferred.
toaddressThe address to which the entity URI is transferred.