You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This contract exchanges the coins/tokens of the user for carbon tokens (NCT) and redeems them for an underlying project token and retires them. It also keeps track on the cumulative retirements of each address.
Methods
addDonation
function addDonation(uint256carbonAmountToRetire, uint256donationPercentage) externalpurereturns (uint256)
Calculates the amount of carbon tokens that need to be swapped including donations.
Parameters
Name
Type
Description
carbonAmountToRetire
uint256
Carbon amount that needs to be retired.
donationPercentage
uint256
The given donation percentage which needs to be added.
Returns
Name
Type
Description
_0
uint256
carbonAmountWithDonation How many carbon tokens need to be received from swap to have enough for the donation.
beneficiaryRetirements
function beneficiaryRetirements(address) externalviewreturns (uint256)
The total amount of carbon retired by each beneficiary
Parameters
Name
Type
Description
_0
address
undefined
Returns
Name
Type
Description
_0
uint256
undefined
calculateNeededAmount
function calculateNeededAmount(addressfromToken, uint256carbonAmountToRetire, uint256donationPercentage, boolfees) externalviewreturns (uint256)
Calculates the needed amount of coins/tokens. the swapped tokens.
Parameters
Name
Type
Description
fromToken
address
Address of the token that is used to swap from. To estimate Matic tokens, use WMATIC address.
carbonAmountToRetire
uint256
Carbon Amount that needs to be purchased.
donationPercentage
uint256
The given donation percentage 1 = 1%.
fees
bool
a boolean to include fees for specific project redemption in cost estimation
Returns
Name
Type
Description
_0
uint256
tokenAmountNeeded How many tokens/coins needed for buying the needed carbon tokens.
callerRetirements
function callerRetirements(address) externalviewreturns (uint256)
The total amount of carbon retired by each address that has called this contract
Parameters
Name
Type
Description
_0
address
undefined
Returns
Name
Type
Description
_0
uint256
undefined
donationAddress
function donationAddress() externalviewreturns (address)
Address to where the donations are sent to
Returns
Name
Type
Description
_0
address
undefined
getRetirementCallerAddresses
function getRetirementCallerAddresses() externalviewreturns (address[])
A getter function for the array holding all addresses that have retired via this contract.
Returns
Name
Type
Description
_0
address[]
retireeAddresses An array (can be empty) of all addresses that have retired.
getRetirementCallerCount
function getRetirementCallerCount() externalviewreturns (uint256)
A function to get the number of addresses that have retired via this contract.
Returns
Name
Type
Description
_0
uint256
uint256 The length of the retireeAddresses array.
onERC721Received
function onERC721Received(address_operator, address_from, uint256_tokenId, bytes_data) external nonpayable returns (bytes4)
Required for use with safeTransferFrom() (from OpenZeppelin's ERC721 contract) used by Toucan's RetirementCertificates in order to transfer the ERC721 retirement certificates to this contract).
Parameters
Name
Type
Description
_operator
address
undefined
_from
address
undefined
_tokenId
uint256
undefined
_data
bytes
undefined
Returns
Name
Type
Description
_0
bytes4
undefined
redemptionFee
function redemptionFee(uint256carbonAmountToRetire) externalviewreturns (uint256)
Calculates the redemptionFees that needs to be added to exactly redeem carbonAmountToRetire.
Receives Matic, swaps to carbon token, retires the swapped tokens via autoRedeem2 and mints the retirement certificate. Forwards donations in carbon tokens. Returns any excess Matic.
Parameters
Name
Type
Description
carbonAmountToRetire
uint256
The number of carbon tokens to be retired.
donationPercentage
uint256
Donation as a percentage 1 = 1% added for donation.
beneficiaryAddress
address
The retirement beneficiary to specify in the retirement certificate.
beneficiaryString
string
The retirement beneficiary name to specify in the retirement certificate.
retirementMessage
string
The retirement message to specify in the retirement certificate.
Returns
Name
Type
Description
tco2Addresses
address[]
An array of the TCO2 addresses that were retired.
tco2Amounts
uint256[]
An array of the amounts of each TCO2 that was retired.
tco2CertificateTokenIds
uint256[]
An array of the corresponding retirement certificate ids.
Takes a user approved token, swaps to carbon token, retires the swapped tokens via autoRedeem2 and mints the certificate. Forwards donations in carbon tokens. Only takes as many tokens as needed.
Parameters
Name
Type
Description
fromToken
address
Address of the erc20 token sent to buy carbon tokens with.
carbonAmountToRetire
uint256
The number of carbon tokens to be retired.
donationPercentage
uint256
Donation as a percentage 1 = 1% added for donation.
beneficiaryAddress
address
The retirement beneficiary to specify in the retirement certificate.
beneficiaryString
string
The retirement beneficiary name to specify in the retirement certificate.
retirementMessage
string
The retirement message to specify in the retirement certificate.
Returns
Name
Type
Description
tco2Addresses
address[]
An array of the TCO2 addresses that were retired.
tco2Amounts
uint256[]
An array of the amounts of each TCO2 that was retired.
tco2CertificateTokenIds
uint256[]
An array of the corresponding retirement certificate ids.
retireWithMatic
function retireWithMatic(uint256carbonAmountToRetire, uint256donationPercentage, addresstco2Address) externalpayablereturns (address[] tco2Addresses, uint256[] tco2Amounts)
Receives Matic, swaps to carbon token, retires the swapped tokens via autoRedeem2. Forwards donations in carbon tokens. Returns any excess Matic.
Parameters
Name
Type
Description
carbonAmountToRetire
uint256
The number of carbon tokens to be retired.
donationPercentage
uint256
Donation as a percentage 1 = 1% added for donation.
tco2Address
address
The TCO2 address to redeem and retire credits from. If address(0) is supplied it will redeem the default TCO2 in the pool.
Returns
Name
Type
Description
tco2Addresses
address[]
An array of the TCO2 addresses that were retired.
tco2Amounts
uint256[]
An array of the amounts of each TCO2 that was retired.
Takes a user approved token, swaps to carbon token, retires the swapped tokens via autoRedeem2. Forwards donations in carbon tokens. Only takes as many tokens as needed.
Parameters
Name
Type
Description
fromToken
address
Address of the erc20 token sent to buy carbon tokens with.
carbonAmountToRetire
uint256
The number of carbon tokens to be retired.
donationPercentage
uint256
Donation as a percentage 1 = 1% added for donation.
tco2Address
address
The TCO2 address to redeem and retire credits from. If address(0) is supplied it will redeem the default TCO2 in the pool.
Returns
Name
Type
Description
tco2Addresses
address[]
An array of the TCO2 addresses that were retired.
tco2Amounts
uint256[]
An array of the amounts of each TCO2 that was retired.
retirementBeneficiaryAddresses
function retirementBeneficiaryAddresses(uint256) externalviewreturns (address)
An array of addresses that have been specified as retirement beneficiaries
Parameters
Name
Type
Description
_0
uint256
undefined
Returns
Name
Type
Description
_0
address
undefined
retirementCallerAddresses
function retirementCallerAddresses(uint256) externalviewreturns (address)
An array of addresses which have retired carbon by calling this contract
Parameters
Name
Type
Description
_0
uint256
undefined
Returns
Name
Type
Description
_0
address
undefined
totalCarbonRetired
function totalCarbonRetired() externalviewreturns (uint256)
The total amount of carbon retired via this contract