Skip to content

ICertificateNFTManager

Inherits:

Returns the current MainHub address connected to the contract

function mainHubAddress() external view returns (address hubAddress);

Returns

NameTypeDescription
hubAddressaddressThe MainHub address

Sets the connected MainHub address

function setMainHub(address mainHubAddress) external;

Parameters

NameTypeDescription
mainHubAddressaddressThe new MainHub address

This function can only be called by a validated ProjectDiamond within the connected MainHub instance.

Mints a new token.

The ProjectDiamond address is inferred from msg.sender

function createFromCertificate(
address beneficiary,
uint256 certificateId
)
external
returns (uint256 newTokenId);

Parameters

NameTypeDescription
beneficiaryaddressThe address of the token beneficiary (account to receive the token)
certificateIduint256The certificate id within the caller project

Returns

NameTypeDescription
newTokenIduint256The newly minted token id

Returns the certificate owner based on the project address and certificate id

function getCertificateOwner(
address projectAddress,
uint256 certificateId
)
external
view
returns (address ownerAddress);

Parameters

NameTypeDescription
projectAddressaddressThe address of the token project
certificateIduint256The certificate id within the project

Returns

NameTypeDescription
ownerAddressaddressThe certificate owner account address

Returns the project address connected to the NFT token

function getTokenProjectAddress(uint256 tokenId) external view returns (address projectAddress);

Parameters

NameTypeDescription
tokenIduint256The token id

Returns

NameTypeDescription
projectAddressaddressThe token project address connected to the token id

Returns a NFT token id derived from the project address and certificate id

The token id is the uint256 representation of the keccak256 hash of the token project address and the certificate id

function getTokenId(
address projectAddress,
uint256 certificateId
)
external
pure
returns (uint256 tokenId);

Parameters

NameTypeDescription
projectAddressaddressThe address of the token project
certificateIduint256The certificate id within the project

Returns

NameTypeDescription
tokenIduint256The resulting token id

Returns the token triplet for a token id

The token triplet contains the token id, project address and certificate id

function getTokenTriplet(uint256 tokenId) external view returns (TokenTriplet memory triplet);

Parameters

NameTypeDescription
tokenIduint256The token id

Returns

NameTypeDescription
tripletTokenTripletThe token triplet

Returns the count of tokens a user has globally

This includes all tokens across all projects

function getAccountTokenCount(address account) external view returns (uint256 tokenCount);

Parameters

NameTypeDescription
accountaddressThe account address

Returns

NameTypeDescription
tokenCountuint256The count of tokens the user has

Returns all the tokens an account has globally, paginated.

This includes all tokens across all projects

function getAccountPaginatedTokens(
address account,
uint256 offset,
uint256 limit
)
external
view
returns (TokenTriplet[] memory tokens);

Parameters

NameTypeDescription
accountaddressThe account address
offsetuint256The offset to start from.
limituint256The limit of tokens to return.

Returns

NameTypeDescription
tokensTokenTriplet[]The tokens array.

Returns the projects an account has at least 1 token in, paginated.

function getAccountPaginatedProjects(
address account,
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory projectAddresses);

Parameters

NameTypeDescription
accountaddressThe account address
offsetuint256The offset to start from.
limituint256The limit of projects to return.

Returns

NameTypeDescription
projectAddressesaddress[]The project addresses array.

Returns the amount of tokens a user has scoped to a specific project

function getAccountTokenCountByProject(
address account,
address projectAddress
)
external
view
returns (uint256 tokenCount);

Parameters

NameTypeDescription
accountaddressThe account address
projectAddressaddressThe project address

Returns

NameTypeDescription
tokenCountuint256The amount of tokens

Returns the token ids an account has, per project, paginated.

function getAccountPaginatedTokensByProject(
address account,
address projectAddress,
uint256 offset,
uint256 limit
)
external
view
returns (TokenTriplet[] memory triplets);

Parameters

NameTypeDescription
accountaddressThe account address
projectAddressaddressThe project address
offsetuint256The offset to start from
limituint256The limit of tokens to return

Returns

NameTypeDescription
tripletsTokenTriplet[]The tokens triplets array

It is called by a ProjectDiamond when a certificate needs to be burned. Merging certificates, for example, is a common use case

This function validates if the caller is a valid ProjectDiamond inside the MainHub.

function certificateBurnedCallback(uint256 certificateId) external;

Parameters

NameTypeDescription
certificateIduint256The certificate id

It is called by a ProjectDiamond when a certificate NFT needs to be updated

This is useful for updating metadata on Marketplaces

This function does not validate the caller and can be used to force metadata updates

function certificateUpdatedCallback(uint256 certificateId) external;

Parameters

NameTypeDescription
certificateIduint256The certificate id

Represents the URI for the contract metadata

It inherits baseURI set by the platform

function contractURI() external view returns (string memory uri);

Returns

NameTypeDescription
uristringThe contract URI

Represents the URI for the token metadata

It inherits baseURI set by the platform

function tokenURI(uint256 tokenId) external view returns (string memory uri);

Parameters

NameTypeDescription
tokenIduint256The token id

Returns

NameTypeDescription
uristringThe token URI

Sets the token metadata base URI to be used as a prefix for the tokenURI

This function can only be called by a platform super admin

function setMetadataBaseURI(string memory newMetadataBaseURI) external;

Parameters

NameTypeDescription
newMetadataBaseURIstringThe new metadata base URI

Emitted whenever a certificate is updated

This allows for automatic metadata updates on Marketplaces

event MetadataUpdate(uint256 tokenId);

Parameters

NameTypeDescription
tokenIduint256The token id

Emitted whenever the main hub address is updated by the super admin

event MainHubChange(address oldMainHubAddress, address newMainHubAddress);

Parameters

NameTypeDescription
oldMainHubAddressaddressThe old main hub address
newMainHubAddressaddressThe new main hub address

Emitted whenever the metadata base URI is updated by the super admin

event MetadataBaseURIChange(string oldBaseURI, string newBaseURI);

Parameters

NameTypeDescription
oldBaseURIstringThe old base URI
newBaseURIstringThe new base URI

Keeps track of certificates for a project

struct TokenAttachedCertificate {
address projectAddress;
uint256 certificateId;
}

Properties

NameTypeDescription
projectAddressaddressAddress of the project
certificateIduint256Id of the certificate

Keeps track of tokens for an account

struct AccountTracker {
EnumerableSet.UintSet globalTokens;
EnumerableMap.AddressToUintMap participatingProjects;
mapping(address => EnumerableSet.UintSet) tokensByProject;
}

Properties

NameTypeDescription
globalTokensEnumerableSet.UintSetA set of all token ids owned by the account
participatingProjectsEnumerableMap.AddressToUintMapA map of project addresses to the amount of tokens owned by the account in that project
tokensByProjectmapping(address => EnumerableSet.UintSet)Mapping of project addresses to sets of tokenIds owned by the account in that project

Keeps track of token metadata so it can be used on pagination without the caller needing to decode the token id into project address and certificate id

struct TokenTriplet {
uint256 tokenId;
address projectAddress;
uint256 certificateId;
}

Properties

NameTypeDescription
tokenIduint256The NFT token id
projectAddressaddressProjectDiamond address
certificateIduint256Certificate id within the project