ICertificateNFTManager
Inherits:
Functions
Section titled “Functions”mainHubAddress
Section titled “mainHubAddress”Returns the current MainHub address connected to the contract
function mainHubAddress() external view returns (address hubAddress);Returns
| Name | Type | Description |
|---|---|---|
hubAddress | address | The MainHub address |
setMainHub
Section titled “setMainHub”Sets the connected MainHub address
function setMainHub(address mainHubAddress) external;Parameters
| Name | Type | Description |
|---|---|---|
mainHubAddress | address | The new MainHub address |
createFromCertificate
Section titled “createFromCertificate”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
| Name | Type | Description |
|---|---|---|
beneficiary | address | The address of the token beneficiary (account to receive the token) |
certificateId | uint256 | The certificate id within the caller project |
Returns
| Name | Type | Description |
|---|---|---|
newTokenId | uint256 | The newly minted token id |
getCertificateOwner
Section titled “getCertificateOwner”Returns the certificate owner based on the project address and certificate id
function getCertificateOwner( address projectAddress, uint256 certificateId) external view returns (address ownerAddress);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | The address of the token project |
certificateId | uint256 | The certificate id within the project |
Returns
| Name | Type | Description |
|---|---|---|
ownerAddress | address | The certificate owner account address |
getTokenProjectAddress
Section titled “getTokenProjectAddress”Returns the project address connected to the NFT token
function getTokenProjectAddress(uint256 tokenId) external view returns (address projectAddress);Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id |
Returns
| Name | Type | Description |
|---|---|---|
projectAddress | address | The token project address connected to the token id |
getTokenId
Section titled “getTokenId”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
| Name | Type | Description |
|---|---|---|
projectAddress | address | The address of the token project |
certificateId | uint256 | The certificate id within the project |
Returns
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The resulting token id |
getTokenTriplet
Section titled “getTokenTriplet”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
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id |
Returns
| Name | Type | Description |
|---|---|---|
triplet | TokenTriplet | The token triplet |
getAccountTokenCount
Section titled “getAccountTokenCount”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
| Name | Type | Description |
|---|---|---|
account | address | The account address |
Returns
| Name | Type | Description |
|---|---|---|
tokenCount | uint256 | The count of tokens the user has |
getAccountPaginatedTokens
Section titled “getAccountPaginatedTokens”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
| Name | Type | Description |
|---|---|---|
account | address | The account address |
offset | uint256 | The offset to start from. |
limit | uint256 | The limit of tokens to return. |
Returns
| Name | Type | Description |
|---|---|---|
tokens | TokenTriplet[] | The tokens array. |
getAccountPaginatedProjects
Section titled “getAccountPaginatedProjects”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
| Name | Type | Description |
|---|---|---|
account | address | The account address |
offset | uint256 | The offset to start from. |
limit | uint256 | The limit of projects to return. |
Returns
| Name | Type | Description |
|---|---|---|
projectAddresses | address[] | The project addresses array. |
getAccountTokenCountByProject
Section titled “getAccountTokenCountByProject”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
| Name | Type | Description |
|---|---|---|
account | address | The account address |
projectAddress | address | The project address |
Returns
| Name | Type | Description |
|---|---|---|
tokenCount | uint256 | The amount of tokens |
getAccountPaginatedTokensByProject
Section titled “getAccountPaginatedTokensByProject”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
| Name | Type | Description |
|---|---|---|
account | address | The account address |
projectAddress | address | The project address |
offset | uint256 | The offset to start from |
limit | uint256 | The limit of tokens to return |
Returns
| Name | Type | Description |
|---|---|---|
triplets | TokenTriplet[] | The tokens triplets array |
certificateBurnedCallback
Section titled “certificateBurnedCallback”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
| Name | Type | Description |
|---|---|---|
certificateId | uint256 | The certificate id |
certificateUpdatedCallback
Section titled “certificateUpdatedCallback”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
| Name | Type | Description |
|---|---|---|
certificateId | uint256 | The certificate id |
contractURI
Section titled “contractURI”Represents the URI for the contract metadata
It inherits baseURI set by the platform
function contractURI() external view returns (string memory uri);Returns
| Name | Type | Description |
|---|---|---|
uri | string | The contract URI |
tokenURI
Section titled “tokenURI”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
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id |
Returns
| Name | Type | Description |
|---|---|---|
uri | string | The token URI |
setMetadataBaseURI
Section titled “setMetadataBaseURI”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
| Name | Type | Description |
|---|---|---|
newMetadataBaseURI | string | The new metadata base URI |
Events
Section titled “Events”MetadataUpdate
Section titled “MetadataUpdate”Emitted whenever a certificate is updated
This allows for automatic metadata updates on Marketplaces
event MetadataUpdate(uint256 tokenId);Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id |
MainHubChange
Section titled “MainHubChange”Emitted whenever the main hub address is updated by the super admin
event MainHubChange(address oldMainHubAddress, address newMainHubAddress);Parameters
| Name | Type | Description |
|---|---|---|
oldMainHubAddress | address | The old main hub address |
newMainHubAddress | address | The new main hub address |
MetadataBaseURIChange
Section titled “MetadataBaseURIChange”Emitted whenever the metadata base URI is updated by the super admin
event MetadataBaseURIChange(string oldBaseURI, string newBaseURI);Parameters
| Name | Type | Description |
|---|---|---|
oldBaseURI | string | The old base URI |
newBaseURI | string | The new base URI |
Structs
Section titled “Structs”TokenAttachedCertificate
Section titled “TokenAttachedCertificate”Keeps track of certificates for a project
struct TokenAttachedCertificate { address projectAddress; uint256 certificateId;}Properties
| Name | Type | Description |
|---|---|---|
projectAddress | address | Address of the project |
certificateId | uint256 | Id of the certificate |
AccountTracker
Section titled “AccountTracker”Keeps track of tokens for an account
struct AccountTracker { EnumerableSet.UintSet globalTokens; EnumerableMap.AddressToUintMap participatingProjects; mapping(address => EnumerableSet.UintSet) tokensByProject;}Properties
| Name | Type | Description |
|---|---|---|
globalTokens | EnumerableSet.UintSet | A set of all token ids owned by the account |
participatingProjects | EnumerableMap.AddressToUintMap | A map of project addresses to the amount of tokens owned by the account in that project |
tokensByProject | mapping(address => EnumerableSet.UintSet) | Mapping of project addresses to sets of tokenIds owned by the account in that project |
TokenTriplet
Section titled “TokenTriplet”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
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The NFT token id |
projectAddress | address | ProjectDiamond address |
certificateId | uint256 | Certificate id within the project |