Skip to main content

SupporterRules

SupporterRules

Manages the rules and data specific to Supporter users within the community.

This contract handles supporter registration, profile updates, token burning for environmental offsets and management of reduction commitments.

INVITER_PERCENTAGE

uint8 INVITER_PERCENTAGE

Commission percentage paid to the inviter when an invited supporter burns tokens.

MAX_COMMITMENTS

uint256 MAX_COMMITMENTS

The maximum number of commitments for supporters.

calculatorItemCertificates

mapping(address => mapping(uint64 => uint256)) calculatorItemCertificates

The relationship between address and burned tokens per calculator item.

reductionCommitments

mapping(address => uint64[]) reductionCommitments

The relationship between address and reduction commitment statements (stored as calculator item IDs).

declaredReduction

mapping(address => mapping(uint256 => bool)) declaredReduction

The relationship between an address and a mapping of items ids and booleans if declared commitment or not.

supportersAddress

mapping(uint256 => address) supportersAddress

The relationship between ID and supporter address.

offsetsCount

uint64 offsetsCount

Total number of offsets made across all supporters.

offsets

mapping(uint64 => struct Offset) offsets

The relationship between offset id and its data.

communityRules

contract ICommunityRules communityRules

CommunityRules contract interface.

researcherRules

contract IResearcherRules researcherRules

ResearcherRules contract interface.

regenerationCredit

contract IRegenerationCredit regenerationCredit

RegenerationCredit contract interface.

constructor

constructor(address communityRulesAddress, address researcherRulesAddress, address regenerationCreditAddress) public

Initializes the SupporterRules contract with addresses of crucial external contracts.

Parameters

NameTypeDescription
communityRulesAddressaddressAddress of the CommunityRules contract.
researcherRulesAddressaddressAddress of the ResearcherRules contract, used for CalculatorItem data.
regenerationCreditAddressaddress

addSupporter

function addSupporter(string name, string description, string profilePhoto) external

Allows a new user to register as a Supporter.

Registers the sender as a Supporter, assigning them a unique ID and updating CommunityRules. Requires name and profile photo length to be within limits.

Parameters

NameTypeDescription
namestringThe name of the supporter (max 100 characters).
descriptionstringBrief description of the the supporter (max 200 characters).
profilePhotostringThe profile photo URL/hash of the supporter (max 150 characters).

updateProfilePhoto

function updateProfilePhoto(string newPhoto) external

Allows a supporter to update their profile photo.

Updates the 'profilePhoto' field for the calling supporter. Only accessible by registered supporters, and enforces a max character limit.

Parameters

NameTypeDescription
newPhotostringUser's new profile photo URL/hash (max 150 characters).

offset

function offset(uint256 amount, uint256 minAmountToBurn, uint64 calculatorItemId, string message) external

Allows a supporter to burn tokens to compensate for a specific item's degradation, with a message to the community. Before calling this function, supporters must approve the SupporterRules contract to burn the required amount oftokens.

This function calls the token transfer function to pay comissions and burnFrom to trade tokens for the compensation certificate. If a valid calculatorItemId is provided, records the burned amount as a certificate for that item.

Parameters

NameTypeDescription
amountuint256Tokens to be burned (minimum 1 token in wei, i.e., 1e18).
minAmountToBurnuint256Slippage protection: the minimum amount the user expects to burn after commission.
calculatorItemIduint64The ID of the CalculatorItem, or 0 if not applicable.
messagestringA message to the community.

declareReductionCommitment

function declareReductionCommitment(uint64 calculatorItemId) external

Allows a supporter to declare a reduction commitment for a specific calculator item.

Records the calculator item ID as a commitment for the calling supporter. Requires the calculator item to exist and the sender to be a registered supporter.

Parameters

NameTypeDescription
calculatorItemIduint64The ID of the CalculatorItem for which the commitment is being declared.

getReductionCommitments

function getReductionCommitments(address addr) public view returns (uint64[])

Retrieves the list of reduction commitment item IDs for a specific address.

Parameters

NameTypeDescription
addraddressThe address of the supporter.

Return Values

NameTypeDescription
[0]uint64[]uint256[] An array of calculator item IDs representing the commitments.

getSupporter

function getSupporter(address addr) public view returns (struct Supporter)

Returns the detailed information of a supporter.

Retrieves the full Supporter struct data for a specific address.

Parameters

NameTypeDescription
addraddressThe address of the supporter.

Return Values

NameTypeDescription
[0]struct SupporterSupporter The Supporter struct containing their data.

SupporterRegistered

event SupporterRegistered(address supporterAddress, uint256 supporterId, string name, string profilePhoto, uint256 createdAtBlock)

Emitted when a new supporter is registered.

Parameters

NameTypeDescription
supporterAddressaddressThe address of the newly registered supporter.
supporterIduint256The unique ID assigned to the supporter.
namestringThe name of the supporter.
profilePhotostringThe URL or hash of the supporter's profile photo.
createdAtBlockuint256The block number at which the supporter was registered.

OffsetMade

event OffsetMade(address supporterAddress, uint256 offsetId, uint256 amountBurned, uint256 calculatorItemId, uint256 blockNumber, string message)

Emitted when a supporter burns tokens to offset degradation.

Parameters

NameTypeDescription
supporterAddressaddressThe address of the supporter.
offsetIduint256The unique ID of the offset record.
amountBurneduint256The amount of tokens burned by the supporter for the offset.
calculatorItemIduint256The ID of the calculator item, if associated.
blockNumberuint256The block number at which the offset occurred.
messagestring

ReductionCommitmentDeclared

event ReductionCommitmentDeclared(address supporterAddress, uint256 calculatorItemId, uint256 blockNumber)

Emitted when a supporter declares a reduction commitment.

Parameters

NameTypeDescription
supporterAddressaddressThe address of the supporter.
calculatorItemIduint256The ID of the calculator item for the commitment.
blockNumberuint256The block number at which the commitment was declared.

CommissionsPaid

event CommissionsPaid(address supporter, address inviter, uint256 amount)

Emitted when a supporter offset results in a commission payment to the inviter.

Parameters

NameTypeDescription
supporteraddressThe address of the supporter who paid the commission.
inviteraddressThe address of the inviter who received the commission.
amountuint256The commission amount paid.