Toucan
Ask or search…
K
Comment on page

Retirement Certificates

The RetirementCertificates contract lets users mint NFTs that act as proof of retirement. These NFTs display how many TCO2s a user has burnt. They can also contain a beneficiary of the retirement and a message. This contract extends ERC721 and is upgradeable.

mintCertificate

Mints a new RetirementCertificates NFT based on existent Retired events. The function can either be called by a valid TCO2 contract (in its retireAndMintCertificate() function) or by a user who owns Retired events.
function mintCertificate(
address retiringEntity,
string calldata retiringEntityString,
address beneficiary,
string calldata beneficiaryString,
string calldata retirementMessage,
uint256[] calldata retirementEventIds
) external;

Params

Name
Type
Description
retiringEntity
address
The entity that has retired TCO2 and is eligible to mint an NFT.
retiringEntityString
string
An identifiable string for the retiring entity, eg. their name.
beneficiary
address
The address of the beneficiary to set in the NFT.
beneficiaryString
string
An identifiable string for the beneficiary to set in the NFT, eg. their name
retirementMessage
string
A retirement message to be set in the NFT
retirementEventIds
uint256[]
An array with with event IDs to associate with the NFT.

attachRetirementEvents

This function allows you to attach the Retired events to a RetirementCertificates NFT.
For context, if you go back to the TCO2 contract docs you will see that you are able to retire TCO2 without minting a RetirementCertificates, but you do get a retirementEventId.
This allows you to update the amount in an existent RetirementCertificates NFT with new retirements.
function attachRetirementEvents(
uint256 tokenId,
uint256[] calldata retirementEventIds
) external;

Params

Name
Type
Description
tokenId
uint256
The ID of the NFT to attach events to.
retirementEventIds
uint256[]
An array with with event IDs to associate with the NFT.

getUserEvents

Fetches all the Retired events that a given user owns.
function getUserEvents(address user)external view returns (uint256[] memory);

Params

Name
Type
Description
user
address
The address of the user for whom to fetch all events.

Return Values

Name
Type
Description
retirementEventIds
uint256[]
The IDs of the events owned by the given user.

updateCertificate

This function allows you to update the retirementMessage, beneficiary, and beneficiaryString of a RetirementCertificates NFT (within 24h of creation). Empty param values are ignored and will not overwrite the existing stored values in the NFT.
function updateCertificate(
uint256 tokenId,
string calldata retiringEntityString,
address beneficiary,
string calldata beneficiaryString,
string calldata retirementMessage
) external;

Params

Name
Type
Description
tokenId
uint256
The ID of the RetirementCertificates NFT to update
retiringEntityString
string
An identifiable string for the retiring entity, eg. their name.
beneficiary
address
The address of the beneficiary to set in the NFT.
beneficiaryString
string
An identifiable string for the beneficiary to set in the NFT, eg. their name
retirementMessage
string
A retirement message to be set in the NFT

getRetiredAmount

This function returns the amount of TCO2 retired by a user that's associated with a given RetirementCertificates NFT.
function getRetiredAmount(uint256 tokenId) external view returns (uint256);

Params

Name
Type
Description
tokenId
uint256
The ID of the RetirementCertificates NFT to fetch the amount for.

Return Values

Name
Type
Description
amount
uint256
The amount of retired TCO2.