KlimaCarbonRetirements

Git Source

Inherits: Ownable

This is used to store any offset retirements made through Klima retirement helper contracts.

State Variables

retirements

mapping(address => Retirement) public retirements;

isHelperContract

mapping(address => bool) public isHelperContract;

isMinterContract

mapping(address => bool) public isMinterContract;

Functions

carbonRetired

Stores the details of an offset transaction for future use

function carbonRetired(
    address _retiree,
    address _pool,
    uint256 _amount,
    string calldata _beneficiaryString,
    string calldata _retirementMessage
) public;

Parameters

NameTypeDescription
_retireeaddressAddress of the retiree. Not the address of a helper contract.
_pooladdressAddress of the carbon pool token.
_amountuint256Number of tons offset. Expected is with 18 decimals.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.

getUnclaimedTotal

Return any unclaimed NFT totals for an address

function getUnclaimedTotal(address _minter) public view returns (uint256);

Parameters

NameTypeDescription
_minteraddressAddress of user trying to mint.

Returns

NameTypeDescription
<none>uint256The net amount of offsets not used for minting an NFT to date.

offsetClaimed

This function updates the total claimed amount for minting an NFT.

function offsetClaimed(address _minter, uint256 _amount) public returns (bool);

Parameters

NameTypeDescription
_minteraddressAddress of the user trying to mint.
_amountuint256Amount being claimed for the mint. Expected value in 18 decimals.

getRetirementIndexInfo

This returns information on a specific retirement for an address.

function getRetirementIndexInfo(address _retiree, uint256 _index)
    public
    view
    returns (address, uint256, string memory, string memory);

Parameters

NameTypeDescription
_retireeaddressAddress that retired the offsets.
_indexuint256Index of all retirements made. Starts at 0.

Returns

NameTypeDescription
<none>addressReturns a tuple of the address for the pool address, amount offset in 18 decimals, and beneficiary description and message used in the retirement.
<none>uint256
<none>string
<none>string

getRetirementPoolInfo

This returns the total amount offset by an address for a specific pool.

function getRetirementPoolInfo(address _retiree, address _pool) public view returns (uint256);

Parameters

NameTypeDescription
_retireeaddressAddress that performed the retirement.
_pooladdressAddress of the pool token.

Returns

NameTypeDescription
<none>uint256Int with 18 decimals for the total amount offset for this pool token.

getRetirementTotals

This returns totals about retirements and claims on an address

function getRetirementTotals(address _retiree) public view returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
_retireeaddressAddress that performed the retirement.

Returns

NameTypeDescription
<none>uint256Int tuple. Total retirements, total tons retired, total tons claimed for NFTs.
<none>uint256
<none>uint256

addHelperContract

Allow contract owner to whitelist new helper contracts. This is to prevent writing abuse from external interfaces.

function addHelperContract(address _helper) public onlyOwner;

Parameters

NameTypeDescription
_helperaddressAddress of the helper contract.

removeHelperContract

Allow contract owner to remove helper contracts. This is to prevent writing abuse from external interfaces.

function removeHelperContract(address _helper) public onlyOwner;

Parameters

NameTypeDescription
_helperaddressAddress of the helper contract.

addMinterContract

Allow contract owner to whitelist new reward contracts. This is to prevent writing abuse from external interfaces.

function addMinterContract(address _minter) public onlyOwner;

Parameters

NameTypeDescription
_minteraddressAddress of the helper contract.

removeMinterContract

Allow contract owner to remove reward contracts. This is to prevent writing abuse from external interfaces.

function removeMinterContract(address _minter) public onlyOwner;

Parameters

NameTypeDescription
_minteraddressAddress of the helper contract.

Events

HelperAdded

event HelperAdded(address helper);

HelperRemoved

event HelperRemoved(address helper);

MinterAdded

event MinterAdded(address minter);

MinterRemoved

event MinterRemoved(address minter);

Structs

Retirement

struct Retirement {
    uint256 totalRetirements;
    uint256 totalCarbonRetired;
    uint256 totalClaimed;
    mapping(uint256 => address) retiredPool;
    mapping(uint256 => uint256) retiredAmount;
    mapping(uint256 => string) retirementBeneficiary;
    mapping(uint256 => string) retirementMessage;
    mapping(address => uint256) totalPoolRetired;
}