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_
bytes32 UPGRADER_ROLE
bytes32 PAUSER_ROLE
bytes32 MINTER_ROLE
bytes32 CONTRACTS_ADDRESS_MANAGER_ROLE
bytes32 NODES_MANAGER_ROLE
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;
}
event Selected(address owner, uint256 tokenId)
Emitted when an account changes the selected token for voting rewards.
event Upgraded(uint256 tokenId, uint256 oldLevel, uint256 newLevel)
Emitted when a token is upgraded.
event MaxLevelUpdated(uint256 oldLevel, uint256 newLevel)
Emitted when the max level is updated.
event XAllocationsGovernorAddressUpdated(address newAddress, address oldAddress)
Emitted when XAllocationVotingGovernor contract address is updated
event B3trGovernorAddressUpdated(address newAddress, address oldAddress)
Emitted when B3TRGovernor contract address is updated
event BaseURIUpdated(string newBaseURI, string oldBaseURI)
Emitted when base URI is updated
event B3TRtoUpgradeToLevelUpdated(uint256[] b3trToUpgradeToLevel)
Emitted when B3TR required to upgrade to each level is updated
event PublicMintingPaused(bool isPaused)
Emitted when public minting is paused
event NodeAttached(uint256 nodeTokenId, uint256 tokenId)
Emitted when a node is attached to a token
event NodeDetached(uint256 nodeTokenId, uint256 tokenId)
Emitted when a node is detached from a token
modifier whenPublicMintingNotPaused()
Modifier to check if public minting is not paused
constructor() public
Ensures only initializer functions are called when deploying a proxy
Data for initializing the contract
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;
}
function initialize(struct GalaxyMember.InitializationData data) external
Initializes a new GalaxyMember contract
Sets initial values for all relevant contract properties and state variables.
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.
function _authorizeUpgrade(address newImplementation) internal
Internal function to authorize contract upgrades
Restricts upgrade authorization to addresses with UPGRADER_ROLE
Name | Type | Description |
---|---|---|
newImplementation | address | Address of the new contract implementation |
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
function unpause() public virtual
Unpauses the Galaxy Member contract
Only callable by the pauser role
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
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
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to upgrade |
function select(uint256 tokenID) public virtual
Allows the user to select a token for voting rewards multiplier
Name | Type | Description |
---|---|---|
tokenID | uint256 | Token ID to select |
function selectFor(address owner, uint256 tokenID) public virtual
Allows the admin to select a token for the user
Name | Type | Description |
---|---|---|
owner | address | The address of the owner to check |
tokenID | uint256 |
function _select(address owner, uint256 tokenId) internal virtual
selects the specified token for the user
Name | Type | Description |
---|---|---|
owner | address | The address of the owner to check |
tokenId | uint256 | the token ID to select |
function burn(uint256 tokenId) public virtual
Allows the token owner to burn their token
Overrides the ERC721BurnableUpgradeable function to include custom burning logic
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to burn |
function attachNode(uint256 nodeTokenId, uint256 tokenId) public virtual
function detachNode(uint256 nodeTokenId, uint256 tokenId) public virtual
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
Name | Type | Description |
---|---|---|
to | address | Address to mint the token to |
function setMaxLevel(uint256 level) public virtual
Sets the maximum level that tokens can be minted or upgraded to
Only callable by the admin role
function setXAllocationsGovernorAddress(address _xAllocationsGovernor) public virtual
Sets the XAllocationVotingGovernor contract address
Only callable by the contractsAddressManager role
Name | Type | Description |
---|---|---|
_xAllocationsGovernor | address | XAllocationVotingGovernor contract address |
function setB3trGovernorAddress(address _b3trGovernor) public virtual
Sets the B3TRGovernor contract address
Only callable by the contractsAddressManager role
Name | Type | Description |
---|---|---|
_b3trGovernor | address | B3TRGovernor contract address |
function setBaseURI(string baseTokenURI) public virtual
Sets the base URI for computing the tokenURI
Only callable by the admin role
Name | Type | Description |
---|---|---|
baseTokenURI | string | Base URI for the Token |
function setB3TRtoUpgradeToLevel(uint256[] b3trToUpgradeToLevel) public virtual
Sets the amount of B3TR required to upgrade to each level
Only callable by the admin role
Name | Type | Description |
---|---|---|
b3trToUpgradeToLevel | uint256[] | Mapping of B3TR requirements per level |
function setIsPublicMintingPaused(bool isPaused) public virtual
Pauses public minting
Only callable by the admin role
Name | Type | Description |
---|---|---|
isPaused | bool | Flag to pause or unpause public minting |
function setVechainNodes(address _vechainNodes) public virtual
Sets the Vechain Nodes contract address
Name | Type | Description |
---|---|---|
_vechainNodes | address | Vechain Nodes contract address |
function setNodeToFreeUpgradeLevel(uint8 nodeLevel, uint256 level) public virtual
Sets the treasury contract address
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 |
function levelOf(uint256 tokenId) public view virtual returns (uint256)
Gets the level of the GM token
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to check |
function getB3TRtoUpgrade(uint256 tokenId) public view virtual returns (uint256)
Gets the B3TR required to upgrade to the next level
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to check |
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
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to check |
nodeId | uint256 |
Name | Type | Description |
---|---|---|
[0] | uint256 | level The level of the token |
[1] | uint256 | b3trDonatedLeft The B3TR donated left to upgrade |
function getNodeLevelOf(uint256 nodeId) public view virtual returns (uint8)
Gets the strength level of the Vechain node
Name | Type | Description |
---|---|---|
nodeId | uint256 | Vechain Node Token ID |
function getSelectedTokenId(address owner) public view virtual returns (uint256)
Gets the selected token ID for the user
Name | Type | Description |
---|---|---|
owner | address | The address of the owner to check |
function getSelectedTokenIdAtBlock(address owner, uint48 blockNumber) public view virtual returns (uint256)
Gets the selected token ID for the user in a specific block number
Name | Type | Description |
---|---|---|
owner | address | The address of the owner to check |
blockNumber | uint48 | The block number to check |
function getLevelAfterAttachingNode(uint256 tokenId, uint256 nodeTokenId) public view virtual returns (uint256)
Gets the level of the token after attaching a node
Name | Type | Description |
---|---|---|
tokenId | uint256 | - GM Token ID |
nodeTokenId | uint256 | - Vechain Node Token ID |
function getLevelAfterDetachingNode(uint256 tokenId) public view virtual returns (uint256)
Gets the level of the token after detaching a node
Name | Type | Description |
---|---|---|
tokenId | uint256 | - GM Token ID |
function participatedInGovernance(address user) public view virtual returns (bool)
Gets whether the user has participated in governance
Name | Type | Description |
---|---|---|
user | address | The address of the user to check |
function baseURI() public view virtual returns (string)
Gets the base URI for computing the tokenURI
function getB3TRtoUpgradeToLevel(uint256 level) public view virtual returns (uint256)
Gets the B3TR required to upgrade to a specific level
Name | Type | Description |
---|---|---|
level | uint256 | Level to upgrade to |
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
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to get the URI for |
function xAllocationsGovernor() external view returns (contract IXAllocationVotingGovernor)
Gets the xAllocationsGovernor contract address
function b3trGovernor() external view returns (contract IB3TRGovernor)
Gets the b3trGovernor contract address
function b3tr() external view returns (contract IB3TR)
Gets the B3TR token contract address
function treasury() external view returns (address)
Gets the treasury contract address
function MAX_LEVEL() public view virtual returns (uint256)
Gets the maximum level that tokens can be minted or upgraded to
function getIdAttachedToNode(uint256 nodeId) public view virtual returns (uint256)
Get the GM Token ID attached to the Vechain Node Token ID
Name | Type | Description |
---|---|---|
nodeId | uint256 | Vechain node Token ID |
function getNodeIdAttached(uint256 tokenId) public view virtual returns (uint256)
Get the Vechain Node Token ID attached to the GM Token ID
Name | Type | Description |
---|---|---|
tokenId | uint256 | GM Token ID |
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
Name | Type | Description |
---|---|---|
nodeLevel | uint8 | Vechain node level |
function getB3TRdonated(uint256 tokenId) public view virtual returns (uint256)
Get the B3TR donated for upgrading a token
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to check |
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
Name | Type | Description |
---|---|---|
[0] | string | string The version of the contract |
struct TokenInfo {
uint256 tokenId;
string tokenURI;
uint256 tokenLevel;
uint256 b3trToUpgrade;
}
function getTokenInfoByTokenId(uint256 tokenId) public view virtual returns (struct GalaxyMember.TokenInfo)
Gets the token info by token ID
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to get the info for |
Name | Type | Description |
---|---|---|
[0] | struct GalaxyMember.TokenInfo | TokenInfo The token info |
function getSelectedTokenInfoByOwner(address owner) public view returns (struct GalaxyMember.TokenInfo)
Gets the selected token info for an address
Name | Type | Description |
---|---|---|
owner | address | The address of the owner to check |
Name | Type | Description |
---|---|---|
[0] | struct GalaxyMember.TokenInfo | TokenInfo The selected token info |
function getTokensInfoByOwner(address owner, uint256 page, uint256 size) public view returns (struct GalaxyMember.TokenInfo[])
Gets the tokens owned by an address
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) |
Name | Type | Description |
---|---|---|
[0] | struct GalaxyMember.TokenInfo[] | TokenInfo[] The tokens owned by the address |
function clock() public view virtual returns (uint48)
Clock used for flagging checkpoints.
function CLOCK_MODE() public view virtual returns (string)
Returns the mode of the clock.
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
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 |
function _increaseBalance(address account, uint128 value) internal
_Overrides the increaseBalance for ERC721Upgradeable and ERC721EnumerableUpgradeable
function supportsInterface(bytes4 interfaceId) public view returns (bool)
Overrides the supportsInterface for ERC721Upgradeable, ERC721EnumerableUpgradeable, and AccessControlUpgradeable
function _baseURI() internal view returns (string)
_Overrides the baseURI for ERC721URIStorageUpgradeable