Solidity API

GalaxyMember

This contract manages the unique assets owned by users within the Galaxy Member ecosystem.

_Extends ERC721 Non-Fungible Token Standard basic implementation with upgradeable pattern, burnable, pausable, and access control functionalities.

——————————— VERSION 2 ——————————— - Added Vechain Nodes contract to attach and detach nodes to tokens - Added NODES_MANAGER_ROLE to manage Vechain Nodes Contract address and free upgrade levels - Added free upgrade levels for each Vechain node level - Removed automatic highest level owned selection - Added dynamic level fetching of the token based on the attached Vechain node and B3TR donated for upgrading - Core logic functions are now overridable through inheritance - B3TRGovernor has been updated to V2 thus pointing to the new interface - NodeManagement contract has been added to permit attaching and detaching nodes from managed nodes too

——————————— VERSION 3 ——————————— - Updated Node Management interface to include getters (isNodeDelegator() and isNodeDelegated()) - Added selectFor function to allow the admin to select a token for the user - Added checkpoints for the selected token ID of the user - Added clock() and CLOCK_MODE() functions to allow for custom time tracking_

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

PAUSER_ROLE

bytes32 PAUSER_ROLE

MINTER_ROLE

bytes32 MINTER_ROLE

CONTRACTS_ADDRESS_MANAGER_ROLE

bytes32 CONTRACTS_ADDRESS_MANAGER_ROLE

NODES_MANAGER_ROLE

bytes32 NODES_MANAGER_ROLE

GalaxyMemberStorage

Storage structure for GalaxyMember

GalaxyMemberStorage structure holds all the state variables in a single location.

struct GalaxyMemberStorage {
  contract IXAllocationVotingGovernor xAllocationsGovernor;
  contract IB3TRGovernor b3trGovernor;
  contract IB3TR b3tr;
  address treasury;
  string _baseTokenURI;
  uint256 _nextTokenId;
  uint256 MAX_LEVEL;
  mapping(uint256 => uint256) levelOf;
  mapping(uint256 => uint256) _b3trToUpgradeToLevel;
  mapping(address => struct Checkpoints.Trace208) _selectedLevelCheckpoints;
  mapping(address => mapping(uint256 => uint256)) _ownedLevels;
  bool isPublicMintingPaused;
  contract ITokenAuction vechainNodes;
  contract INodeManagement nodeManagement;
  mapping(uint256 => uint256) _nodeToTokenId;
  mapping(uint256 => uint256) _tokenIdToNode;
  mapping(uint8 => uint256) _nodeToFreeUpgradeLevel;
  mapping(uint256 => uint256) _tokenIdToB3TRdonated;
  mapping(address => uint256) _selectedTokenID_DEPRECATED;
  mapping(address => struct Checkpoints.Trace208) _selectedTokenIDCheckpoints;
}

Selected

event Selected(address owner, uint256 tokenId)

Emitted when an account changes the selected token for voting rewards.

Upgraded

event Upgraded(uint256 tokenId, uint256 oldLevel, uint256 newLevel)

Emitted when a token is upgraded.

MaxLevelUpdated

event MaxLevelUpdated(uint256 oldLevel, uint256 newLevel)

Emitted when the max level is updated.

XAllocationsGovernorAddressUpdated

event XAllocationsGovernorAddressUpdated(address newAddress, address oldAddress)

Emitted when XAllocationVotingGovernor contract address is updated

B3trGovernorAddressUpdated

event B3trGovernorAddressUpdated(address newAddress, address oldAddress)

Emitted when B3TRGovernor contract address is updated

BaseURIUpdated

event BaseURIUpdated(string newBaseURI, string oldBaseURI)

Emitted when base URI is updated

B3TRtoUpgradeToLevelUpdated

event B3TRtoUpgradeToLevelUpdated(uint256[] b3trToUpgradeToLevel)

Emitted when B3TR required to upgrade to each level is updated

PublicMintingPaused

event PublicMintingPaused(bool isPaused)

Emitted when public minting is paused

NodeAttached

event NodeAttached(uint256 nodeTokenId, uint256 tokenId)

Emitted when a node is attached to a token

NodeDetached

event NodeDetached(uint256 nodeTokenId, uint256 tokenId)

Emitted when a node is detached from a token

whenPublicMintingNotPaused

modifier whenPublicMintingNotPaused()

Modifier to check if public minting is not paused

constructor

constructor() public

Ensures only initializer functions are called when deploying a proxy

InitializationData

Data for initializing the contract

Parameters

Name Type Description
struct InitializationData {
  string name;
  string symbol;
  address admin;
  address upgrader;
  address pauser;
  address minter;
  address contractsAddressManager;
  uint256 maxLevel;
  string baseTokenURI;
  uint256[] b3trToUpgradeToLevel;
  address b3tr;
  address treasury;
}

initialize

function initialize(struct GalaxyMember.InitializationData data) external

Initializes a new GalaxyMember contract

Sets initial values for all relevant contract properties and state variables.

initializeV2

function initializeV2(address _vechainNodes, address _nodesMangaement, address _nodesAdmin, uint256[] _nodeFreeLevels) external

Initializes a new GalaxyMember contract

Sets initial values for all relevant contract properties and state variables.

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal

Internal function to authorize contract upgrades

Restricts upgrade authorization to addresses with UPGRADER_ROLE

Parameters

Name Type Description
newImplementation address Address of the new contract implementation

pause

function pause() public virtual

Pauses the Galaxy Member contract

pausing the contract will prevent minting, upgrading, and transferring of tokens Only callable by the pauser role

unpause

function unpause() public virtual

Unpauses the Galaxy Member contract

Only callable by the pauser role

freeMint

function freeMint() public virtual

Allows a user to freely mint a token if they have participated in governance

Mints a token with level 1 and ensures that the public minting is not paused

upgrade

function upgrade(uint256 tokenId) public virtual

Upgrades a token to the next level

Requires the owner to have enough B3TR tokens and sufficient allowance for the contract to use them

Parameters

Name Type Description
tokenId uint256 Token ID to upgrade

select

function select(uint256 tokenID) public virtual

Allows the user to select a token for voting rewards multiplier

Parameters

Name Type Description
tokenID uint256 Token ID to select

selectFor

function selectFor(address owner, uint256 tokenID) public virtual

Allows the admin to select a token for the user

Parameters

Name Type Description
owner address The address of the owner to check
tokenID uint256

_select

function _select(address owner, uint256 tokenId) internal virtual

selects the specified token for the user

Parameters

Name Type Description
owner address The address of the owner to check
tokenId uint256 the token ID to select

burn

function burn(uint256 tokenId) public virtual

Allows the token owner to burn their token

Overrides the ERC721BurnableUpgradeable function to include custom burning logic

Parameters

Name Type Description
tokenId uint256 Token ID to burn

attachNode

function attachNode(uint256 nodeTokenId, uint256 tokenId) public virtual

detachNode

function detachNode(uint256 nodeTokenId, uint256 tokenId) public virtual

safeMint

function safeMint(address to) internal virtual

Internal function to safely mint a token

Adds a token to the total supply and assigns it to an address, incrementing the owner’s balance

Parameters

Name Type Description
to address Address to mint the token to

setMaxLevel

function setMaxLevel(uint256 level) public virtual

Sets the maximum level that tokens can be minted or upgraded to

Only callable by the admin role

setXAllocationsGovernorAddress

function setXAllocationsGovernorAddress(address _xAllocationsGovernor) public virtual

Sets the XAllocationVotingGovernor contract address

Only callable by the contractsAddressManager role

Parameters

Name Type Description
_xAllocationsGovernor address XAllocationVotingGovernor contract address

setB3trGovernorAddress

function setB3trGovernorAddress(address _b3trGovernor) public virtual

Sets the B3TRGovernor contract address

Only callable by the contractsAddressManager role

Parameters

Name Type Description
_b3trGovernor address B3TRGovernor contract address

setBaseURI

function setBaseURI(string baseTokenURI) public virtual

Sets the base URI for computing the tokenURI

Only callable by the admin role

Parameters

Name Type Description
baseTokenURI string Base URI for the Token

setB3TRtoUpgradeToLevel

function setB3TRtoUpgradeToLevel(uint256[] b3trToUpgradeToLevel) public virtual

Sets the amount of B3TR required to upgrade to each level

Only callable by the admin role

Parameters

Name Type Description
b3trToUpgradeToLevel uint256[] Mapping of B3TR requirements per level

setIsPublicMintingPaused

function setIsPublicMintingPaused(bool isPaused) public virtual

Pauses public minting

Only callable by the admin role

Parameters

Name Type Description
isPaused bool Flag to pause or unpause public minting

setVechainNodes

function setVechainNodes(address _vechainNodes) public virtual

Sets the Vechain Nodes contract address

Parameters

Name Type Description
_vechainNodes address Vechain Nodes contract address

setNodeToFreeUpgradeLevel

function setNodeToFreeUpgradeLevel(uint8 nodeLevel, uint256 level) public virtual

Sets the treasury contract address

Parameters

Name Type Description
nodeLevel uint8 Vechain node level (i.e., 1, 2, 3, 4, 5, 6, 7, 8 => Strength, Thunder, Mjolnir, VeThorX, StrengthX, ThunderX, MjolnirX)
level uint256 new free upgrade level

levelOf

function levelOf(uint256 tokenId) public view virtual returns (uint256)

Gets the level of the GM token

Parameters

Name Type Description
tokenId uint256 Token ID to check

getB3TRtoUpgrade

function getB3TRtoUpgrade(uint256 tokenId) public view virtual returns (uint256)

Gets the B3TR required to upgrade to the next level

Parameters

Name Type Description
tokenId uint256 Token ID to check

_getLevelOfAndB3TRleft

function _getLevelOfAndB3TRleft(uint256 tokenId, uint256 nodeId) internal view virtual returns (uint256, uint256)

Gets the level of the GM token and the B3TR Donated left to upgrade

Parameters

Name Type Description
tokenId uint256 Token ID to check
nodeId uint256

Return Values

Name Type Description
[0] uint256 level The level of the token
[1] uint256 b3trDonatedLeft The B3TR donated left to upgrade

getNodeLevelOf

function getNodeLevelOf(uint256 nodeId) public view virtual returns (uint8)

Gets the strength level of the Vechain node

Parameters

Name Type Description
nodeId uint256 Vechain Node Token ID

getSelectedTokenId

function getSelectedTokenId(address owner) public view virtual returns (uint256)

Gets the selected token ID for the user

Parameters

Name Type Description
owner address The address of the owner to check

getSelectedTokenIdAtBlock

function getSelectedTokenIdAtBlock(address owner, uint48 blockNumber) public view virtual returns (uint256)

Gets the selected token ID for the user in a specific block number

Parameters

Name Type Description
owner address The address of the owner to check
blockNumber uint48 The block number to check

getLevelAfterAttachingNode

function getLevelAfterAttachingNode(uint256 tokenId, uint256 nodeTokenId) public view virtual returns (uint256)

Gets the level of the token after attaching a node

Parameters

Name Type Description
tokenId uint256 - GM Token ID
nodeTokenId uint256 - Vechain Node Token ID

getLevelAfterDetachingNode

function getLevelAfterDetachingNode(uint256 tokenId) public view virtual returns (uint256)

Gets the level of the token after detaching a node

Parameters

Name Type Description
tokenId uint256 - GM Token ID

participatedInGovernance

function participatedInGovernance(address user) public view virtual returns (bool)

Gets whether the user has participated in governance

Parameters

Name Type Description
user address The address of the user to check

baseURI

function baseURI() public view virtual returns (string)

Gets the base URI for computing the tokenURI

getB3TRtoUpgradeToLevel

function getB3TRtoUpgradeToLevel(uint256 level) public view virtual returns (uint256)

Gets the B3TR required to upgrade to a specific level

Parameters

Name Type Description
level uint256 Level to upgrade to

tokenURI

function tokenURI(uint256 tokenId) public view virtual returns (string)

gets the token URI for a specific token

computes the token URI based on the base URI and the level of the token

Parameters

Name Type Description
tokenId uint256 Token ID to get the URI for

xAllocationsGovernor

function xAllocationsGovernor() external view returns (contract IXAllocationVotingGovernor)

Gets the xAllocationsGovernor contract address

b3trGovernor

function b3trGovernor() external view returns (contract IB3TRGovernor)

Gets the b3trGovernor contract address

b3tr

function b3tr() external view returns (contract IB3TR)

Gets the B3TR token contract address

treasury

function treasury() external view returns (address)

Gets the treasury contract address

MAX_LEVEL

function MAX_LEVEL() public view virtual returns (uint256)

Gets the maximum level that tokens can be minted or upgraded to

getIdAttachedToNode

function getIdAttachedToNode(uint256 nodeId) public view virtual returns (uint256)

Get the GM Token ID attached to the Vechain Node Token ID

Parameters

Name Type Description
nodeId uint256 Vechain node Token ID

getNodeIdAttached

function getNodeIdAttached(uint256 tokenId) public view virtual returns (uint256)

Get the Vechain Node Token ID attached to the GM Token ID

Parameters

Name Type Description
tokenId uint256 GM Token ID

getNodeToFreeLevel

function getNodeToFreeLevel(uint8 nodeLevel) public view virtual returns (uint256)

Get the GM level that can be upgraded for free for a given Vechain node level

Parameters

Name Type Description
nodeLevel uint8 Vechain node level

getB3TRdonated

function getB3TRdonated(uint256 tokenId) public view virtual returns (uint256)

Get the B3TR donated for upgrading a token

Parameters

Name Type Description
tokenId uint256 Token ID to check

version

function version() external pure virtual returns (string)

Retrieves the current version of the contract

This function is used to identify the version of the contract and should be updated in each new version

Return Values

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

TokenInfo

struct TokenInfo {
  uint256 tokenId;
  string tokenURI;
  uint256 tokenLevel;
  uint256 b3trToUpgrade;
}

getTokenInfoByTokenId

function getTokenInfoByTokenId(uint256 tokenId) public view virtual returns (struct GalaxyMember.TokenInfo)

Gets the token info by token ID

Parameters

Name Type Description
tokenId uint256 Token ID to get the info for

Return Values

Name Type Description
[0] struct GalaxyMember.TokenInfo TokenInfo The token info

getSelectedTokenInfoByOwner

function getSelectedTokenInfoByOwner(address owner) public view returns (struct GalaxyMember.TokenInfo)

Gets the selected token info for an address

Parameters

Name Type Description
owner address The address of the owner to check

Return Values

Name Type Description
[0] struct GalaxyMember.TokenInfo TokenInfo The selected token info

getTokensInfoByOwner

function getTokensInfoByOwner(address owner, uint256 page, uint256 size) public view returns (struct GalaxyMember.TokenInfo[])

Gets the tokens owned by an address

Parameters

Name Type Description
owner address The address of the owner to check
page uint256 The page number to fetch
size uint256 The number of tokens to fetch (cannot exceed 100)

Return Values

Name Type Description
[0] struct GalaxyMember.TokenInfo[] TokenInfo[] The tokens owned by the address

clock

function clock() public view virtual returns (uint48)

Clock used for flagging checkpoints.

CLOCK_MODE

function CLOCK_MODE() public view virtual returns (string)

Returns the mode of the clock.

_update

function _update(address to, uint256 tokenId, address auth) internal returns (address)

Performs automatic level updating upon token updates

_Overrides the update function to update the highest level owned by the owner

Parameters

Name Type Description
to address The address to transfer the token to
tokenId uint256 The token ID to update
auth address The address of the sender

_increaseBalance

function _increaseBalance(address account, uint128 value) internal

_Overrides the increaseBalance for ERC721Upgradeable and ERC721EnumerableUpgradeable

supportsInterface

function supportsInterface(bytes4 interfaceId) public view returns (bool)

Overrides the supportsInterface for ERC721Upgradeable, ERC721EnumerableUpgradeable, and AccessControlUpgradeable

_baseURI

function _baseURI() internal view returns (string)

_Overrides the baseURI for ERC721URIStorageUpgradeable