Solidity API

X2EarnApps

This contract handles the x-2-earn applications of the VeBetterDAO ecosystem. The contract allows the insert, management and eligibility of apps for the B3TR allocation rounds.

_The contract is using AccessControl to handle the admin and upgrader roles. Only users with the DEFAULT_ADMIN_ROLE can add new apps, set the base URI and set the voting eligibility for an app. Admins can also control the app metadata and management. Each app has a set of admins and moderators that can manage the app and settings.

——————– Version 2 ——————– - The contract has been upgraded to version 2 to include the X2Earn endorsement system. - Added libraries to reduce the contract size and improve readability.

——————– Version 3 ——————– - The contract has been upgraded to version 3 to add node cooldown period._

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

The role that can upgrade the contract.

GOVERNANCE_ROLE

bytes32 GOVERNANCE_ROLE

The role that can manage the contract settings.

constructor

constructor() public

initializeV3

function initializeV3(uint48 _cooldownPeriod, address _xAllocationVotingGovernor) public

Initialize the version 3 contract

This function is called only once during the contract upgrade

Parameters

Name Type Description
_cooldownPeriod uint48 the cooldown period for the endorsement
_xAllocationVotingGovernor address

onlyRoleAndAppAdmin

modifier onlyRoleAndAppAdmin(bytes32 role, bytes32 appId)

Modifier to restrict access to only the admin role and the app admin role.

Parameters

Name Type Description
role bytes32
appId bytes32 the app ID

onlyRoleAndAppAdminOrModerator

modifier onlyRoleAndAppAdminOrModerator(bytes32 role, bytes32 appId)

Modifier to restrict access to only the admin role, the app admin role and the app moderator role.

Parameters

Name Type Description
role bytes32
appId bytes32 the app ID

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal

_See {UUPSUpgradeable-authorizeUpgrade}

version

function version() public pure virtual returns (string)

Returns the version of the contract

This should be updated every time a new version of implementation is deployed

Return Values

Name Type Description
[0] string sting The version of the contract

setBaseURI

function setBaseURI(string _baseURI) public

Update the base URI to retrieve the metadata of the x2earn apps

Parameters

Name Type Description
_baseURI string the base URI for the contract Emits a {BaseURIUpdated} event.

setVotingEligibility

function setVotingEligibility(bytes32 _appId, bool _isEligible) public virtual

See {IX2EarnApps-setVotingEligibility}.

submitApp

function submitApp(address _teamWalletAddress, address _admin, string _appName, string _appMetadataURI) public virtual

See {IX2EarnApps-submitApp}.

setAppAdmin

function setAppAdmin(bytes32 _appId, address _newAdmin) public

See {IX2EarnApps-setAppAdmin}.

updateTeamWalletAddress

function updateTeamWalletAddress(bytes32 _appId, address _newReceiverAddress) public

See {IX2EarnApps-updateTeamWalletAddress}.

setTeamAllocationPercentage

function setTeamAllocationPercentage(bytes32 _appId, uint256 _percentage) public

See {IX2EarnApps-setTeamAllocationPercentage}.

addAppModerator

function addAppModerator(bytes32 _appId, address _moderator) public

See {IX2EarnApps-addAppModerator}.

removeAppModerator

function removeAppModerator(bytes32 _appId, address _moderator) public

See {IX2EarnApps-removeAppModerator}.

removeAppCreator

function removeAppCreator(bytes32 _appId, address _creator) public

See {IX2EarnApps-removeAppCreator}.

addRewardDistributor

function addRewardDistributor(bytes32 _appId, address _distributor) public

See {IX2EarnApps-addRewardDistributor}.

addCreator

function addCreator(bytes32 _appId, address _creator) public

See {IX2EarnApps-addCreator}.

removeRewardDistributor

function removeRewardDistributor(bytes32 _appId, address _distributor) public

See {IX2EarnApps-removeRewardDistributor}.

updateAppMetadata

function updateAppMetadata(bytes32 _appId, string _newMetadataURI) public

See {IX2EarnApps-updateAppMetadata}.

updateGracePeriod

function updateGracePeriod(uint48 _newGracePeriod) public virtual

See {IX2EarnApps-updateGracePeriod}.

updateCooldownPeriod

function updateCooldownPeriod(uint256 _newCooldownPeriod) public virtual

See {IX2EarnApps-updateCooldownPeriod}.

updateNodeEndorsementScores

function updateNodeEndorsementScores(struct VechainNodesDataTypes.NodeStrengthScores _nodeStrengthScores) external

See {IX2EarnApps-updateNodeEndorsementScores}.

updateEndorsementScoreThreshold

function updateEndorsementScoreThreshold(uint256 _scoreThreshold) external

See {IX2EarnApps-updateEndorsementScoreThreshold}.

endorsementScoreThreshold

function endorsementScoreThreshold() external view returns (uint256)

See {IX2EarnApps-endorsementScoreThreshold}.

removeNodeEndorsement

function removeNodeEndorsement(bytes32 _appId, uint256 _nodeId) public virtual

See {IX2EarnApps-removeNodeEndorsement}.

removeXAppSubmission

function removeXAppSubmission(bytes32 _appId) public virtual

See {IX2EarnApps-removeXAppSubmission}.

setNodeManagementContract

function setNodeManagementContract(address _nodeManagementContract) public virtual

See {IX2EarnApps-setNodeManagementContract}.

setVeBetterPassportContract

function setVeBetterPassportContract(address _veBetterPassportContract) public virtual

See {IX2EarnApps-setVeBetterPassportContract}.

setXAllocationVotingGovernor

function setXAllocationVotingGovernor(address _xAllocationVotingGovernor) public virtual

See {IX2EarnApps-setXAllocationVotingGovernor}.

setX2EarnCreatorContract

function setX2EarnCreatorContract(address _x2EarnCreatorContract) public

See {IX2EarnApps-setX2EarnCreatorContract}.