Retirement certificates

The RetirementCertificates contract lets users mint RetirementCertificate NFTs that act as proof of retirement. These NFTs display how many TCO2 tokens a user has retired, along with retirement details such as the beneficiary of the retirement and a message. This contract extends ERC721 and is upgradeable.

mintCertificate

Mints a new RetirementCertificates NFT based on existing 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.

Note: This information is publicly written to the blockchain in plaintext.

function mintCertificate(
  address retiringEntity,
  string calldata retiringEntityString,
  address beneficiary,
  string calldata beneficiaryString,
  string calldata retirementMessage,
  uint256[] calldata retirementEventIds
) external;

Params

NameTypeDescription

retiringEntity

address

The entity that has retired TCO2 and is eligible to mint an NFT

retiringEntityString

string

An identifiable string for the retiring entity, e.g. 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, e.g. 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

NameTypeDescription

tokenId

uint256

The ID of the RetirementCertificate 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

NameTypeDescription

user

address

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

Return Values

NameTypeDescription

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 24 hours 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

NameTypeDescription

tokenId

uint256

The ID of the RetirementCertificates NFT to update

retiringEntityString

string

An identifiable string for the retiring entity, e.g. 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, e.g. their name

retirementMessage

string

A retirement message to be set in the NFT

getRetiredAmount

This function returns the amount of TCO2 tokens retired by a user that's associated with a given RetirementCertificates NFT. The function sums up all the retirement amounts from all of event IDs attached to the RetirementCertificate.

function getRetiredAmount(uint256 tokenId) external view returns (uint256);

Params

NameTypeDescription

tokenId

uint256

The ID of the RetirementCertificates NFT to fetch the amount for

Return Values

NameTypeDescription

amount

uint256

The amount of retired TCO2 tokens associated with that tokenId

Last updated