Skip to main content

RegenerationCredit

RegenerationCredit

Regeneration Credit, token backed by the community's environmental regeneration impact. This contract manages the token's supply, transfers, approvals, and introduces specific functionalities for managing tokens within designated "contract pools" and for burning tokens to certify environmental offset.

Inherits from OpenZeppelin's ERC20 for standard token functionalities and Ownable for deploy setup.

NAME

string NAME

The official name of the token.

SYMBOL

string SYMBOL

Token symbol.

DECIMALS

uint8 DECIMALS

The number of decimal places used by the token.

totalCertified_

uint256 totalCertified_

The total amount of tokens that have been permanently burned/retired (certified) across the system. These tokens are out from circulation and represent environmental offset.

totalLocked_

uint256 totalLocked_

The total amount of tokens that are currently held by designated contract pools.

certificate

mapping(address => uint256) certificate

A mapping to track the amount of tokens burned (certified) by a specific user/supporter. Represents their individual contribution to environmental offset.

constructor

constructor(uint256 totalSupply) public

Initializes the RegenerationCredit contract by minting the initial supply. Also sets the token's name, symbol, and decimals via the ERC20 base constructor.

Parameters

NameTypeDescription
totalSupplyuint256The total amount of tokens to be minted.

addContractPool

function addContractPool(address _fundAddress, uint256 _numTokens) external returns (bool)

This function is used to fund and activate distribution pools within the ecosystem.

Requirements:

  • Only the contract owner can call this function.
  • fundAddress must not be the zero address.
  • The caller must have sufficient balance to transfer numTokens.

Allows the contract owner to designate a new address as a "contract pool" and transfer an initial allocation of tokens to it. Tokens are set as locked when transfered to the pool.

Parameters

NameTypeDescription
_fundAddressaddressThe address of the contract to be designated as a pool.
_numTokensuint256The amount of tokens to transfer to the new pool.

burnTokens

function burnTokens(uint256 amount) external

Compensate your environmental degradation by burning Regeneration Credit tokens. Burning tokens permanently removes them from circulation and increases your compensation certificate.

Requirements:

  • The caller (msg.sender) must have amount tokens.
  • amount must be greater than 0.

Note: This functions uses the token 18 decimals, to burn 1 RC user must write 1000000000000000000.

Allows any user to burn their own tokens.

Parameters

NameTypeDescription
amountuint256The amount of tokens to burn from the caller's balance.

burnFrom

function burnFrom(address account, uint256 amount) public

Destroys a specific amount of tokens from a target account and updates certification records.

Overrides the standard ERC20Burnable burnFrom to include custom certification logic by calling the internal _burnTokensInternal function.

Parameters

NameTypeDescription
accountaddressThe address of the token holder whose tokens will be burned.
amountuint256The amount of tokens to burn.

decreaseLocked

function decreaseLocked(uint256 numTokens) external

Called only by a system pool contract, this function remove the transfered tokens from totalLocked.

Allows a designated "contract pool" to register a new decreaseLocked.

Parameters

NameTypeDescription
numTokensuint256The amount of tokens to transfer.

totalCertified

function totalCertified() public view returns (uint256)

Returns the total amount of tokens that have been permanently burned/retired (certified) across the system.

Return Values

NameTypeDescription
[0]uint256uint256 The total certified tokens.

totalLocked

function totalLocked() public view returns (uint256)

Returns the total amount of tokens that are currently held by designated contract pools.

Return Values

NameTypeDescription
[0]uint256uint256 The total tokens locked in pools.

contractPool

function contractPool(address poolAddress) public view returns (bool)

Checks if a given address is a designated "contract pool" in the system.

Parameters

NameTypeDescription
poolAddressaddressThe address to check.

Return Values

NameTypeDescription
[0]boolbool true if the address is a contract pool, false otherwise.

mustBeContractPool

modifier mustBeContractPool()

Modifier that restricts a function's execution to only addresses that are designated as "contract pools" in the contractsPools mapping.

TokensCertified

event TokensCertified(address account, uint256 amount, uint256 newAccountCertifiedTotal)

Emitted when tokens are burned (certified) by a user.

Parameters

NameTypeDescription
accountaddressThe address from which tokens were burned.
amountuint256The amount of tokens burned.
newAccountCertifiedTotaluint256The total amount of tokens certified by account.