Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MembershipLevel
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
import "../@galaxis/registries/contracts/CommunityList.sol";
import "../@galaxis/registries/contracts/CommunityRegistry.sol";
import "../Community/ICommunityTokensRegistry.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
struct MembershipLevelStoredData {
bytes32 name;
uint256 amountOne;
uint256 amountTwelve;
bytes metadata;
bool isActive;
}
struct MembershipLevelInfo {
uint256 order;
uint256 position;
bytes32 name;
uint256 amountOne;
uint256 amountTwelve;
bytes metadata;
bool isActive;
}
contract MembershipLevel is IGenericVersionable, UsesGalaxisRegistry {
function baseVersion() public pure virtual returns (uint256) {
return 2025040601;
}
function version() public pure virtual returns (uint256) {
return 2025040601;
}
uint256 public communityId;
CommunityRegistry public communityRegistry;
IERC20 public PaymentToken;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
uint256 public lastOrderId = 1;
uint256 public levelCount = 0;
mapping(uint256 => MembershipLevelStoredData) public data;
mapping(uint256 => uint256) public ordering;
event MembershipLevelCreated(uint256 id, bytes32 name, uint256 amountOne, uint256 amountTwelve);
event MembershipLevelUpdated(uint256 id, bytes32 name, uint256 amountOne, uint256 amountTwelve);
event MembershipLevelStatusChanged(uint256 position, bool isActive);
constructor(
address _galaxisRegistry,
uint32 _communityId,
uint8 _paymentTokenId
) UsesGalaxisRegistry(_galaxisRegistry) {
if (_communityId == 0) return; // for deploying goldens
communityId = _communityId;
CommunityList communityList = CommunityList(galaxisRegistry.getRegistryAddress("COMMUNITY_LIST"));
(, address crAddr, ) = communityList.communities(_communityId);
require(crAddr != address(0), "MembershipLevel: Invalid community id");
communityRegistry = CommunityRegistry( crAddr );
ICommunityTokensRegistry ComunityTokenRegistry = ICommunityTokensRegistry(
galaxisRegistry.getRegistryAddress("COMMUNITY_TOKEN_REGISTRY")
);
TokenRecord[] memory PaymentTokenAddresses = ComunityTokenRegistry.getPaymentTokens(_communityId);
PaymentToken = IERC20(PaymentTokenAddresses[_paymentTokenId]._address);
}
function addLevel(
bytes32[] memory name,
uint256[] memory amountOne,
uint256[] memory amountTwelve,
bytes[] memory metadata
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: addLevel DEFAULT_ADMIN_ROLE required");
for(uint8 i = 0; i < name.length; i++) {
data[lastOrderId] = MembershipLevelStoredData(name[i], amountOne[i], amountTwelve[i], metadata[i],true);
ordering[lastOrderId] = lastOrderId;
lastOrderId++;
levelCount++;
emit MembershipLevelCreated(lastOrderId - 1, name[i], amountOne[i], amountTwelve[i]);
}
}
function updateLevel(
uint256 position,
bytes32 name,
uint256 amountOne,
uint256 amountTwelve,
bytes memory metadata
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateLevel DEFAULT_ADMIN_ROLE required");
bool isActive = data[position].isActive;
data[position] = MembershipLevelStoredData(name, amountOne, amountTwelve, metadata,isActive);
emit MembershipLevelUpdated(position, name, amountOne, amountTwelve);
}
function setLevelStatus(uint256 position, bool isActive) public {
require(data[position].isActive != isActive, "MembershipLevel: Level is already in the desired state");
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateLevel DEFAULT_ADMIN_ROLE required");
data[position].isActive = isActive;
emit MembershipLevelStatusChanged(position, isActive);
}
function updateOrdering(
uint256[] memory positions,
uint256[] memory ids
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateOrdering DEFAULT_ADMIN_ROLE required");
for(uint8 i = 0; i < ids.length; i++) {
ordering[positions[i]] = ids[i];
}
}
function getMembershipLevels() public view returns (MembershipLevelInfo[] memory) {
MembershipLevelInfo[] memory results = new MembershipLevelInfo[](levelCount);
for(uint8 i = 1; i <= levelCount; i++) {
MembershipLevelStoredData storage stored = data[ordering[i]];
results[i-1] = MembershipLevelInfo(
i,
ordering[i],
stored.name,
stored.amountOne,
stored.amountTwelve,
stored.metadata,
stored.isActive
);
}
return results;
}
function getMembershipData(uint256 index) public view returns (MembershipLevelStoredData memory) {
return data[index];
}
function getMembershipAmountOne(uint256 index) public view returns (uint256) {
require(data[index].isActive,"MembershipLevel : level not active");
return data[index].amountOne;
}
function getMembershipAmountTwelve(uint256 index) public view returns (uint256) {
require(data[index].isActive,"MembershipLevel : level not active");
return data[index].amountTwelve;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "./Versionable/IVersionable.sol";
contract CommunityList is AccessControlEnumerable, IVersionable {
function version() external pure returns (uint256) {
return 2024040301;
}
bytes32 public constant CONTRACT_ADMIN = keccak256("CONTRACT_ADMIN");
uint256 public numberOfEntries;
struct community_entry {
string name;
address registry;
uint32 id;
}
mapping(uint32 => community_entry) public communities; // community_id => record
mapping(uint256 => uint32) public index; // entryNumber => community_id for enumeration
event CommunityAdded(uint256 pos, string community_name, address community_registry, uint32 community_id);
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(CONTRACT_ADMIN,msg.sender);
}
function addCommunity(uint32 community_id, string memory community_name, address community_registry) external onlyRole(CONTRACT_ADMIN) {
uint256 pos = numberOfEntries++;
index[pos] = community_id;
communities[community_id] = community_entry(community_name, community_registry, community_id);
emit CommunityAdded(pos, community_name, community_registry, community_id);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./Versionable/IVersionable.sol";
import "./UsesGalaxisRegistry.sol";
contract CommunityRegistry is AccessControlEnumerable, UsesGalaxisRegistry, IVersionable {
function version() virtual external pure returns(uint256) {
return 2024040401;
}
bytes32 public constant COMMUNITY_REGISTRY_ADMIN = keccak256("COMMUNITY_REGISTRY_ADMIN");
uint32 public community_id;
string public community_name;
mapping(bytes32 => address) addresses;
mapping(bytes32 => uint256) uints;
mapping(bytes32 => bool) booleans;
mapping(bytes32 => string) strings;
mapping (uint => string) public addressEntries;
mapping (uint => string) public uintEntries;
mapping (uint => string) public boolEntries;
mapping (uint => string) public stringEntries;
uint public numberOfAddresses;
uint public numberOfUINTs;
uint public numberOfBooleans;
uint public numberOfStrings;
bool initialised;
bool public independant;
event IndependanceDay(bool gain_independance);
modifier onlyAdmin() {
require(
isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender)
,"CommunityRegistry : Unauthorised");
_;
}
modifier onlyPropertyAdmin() {
require(
isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender) ||
hasRole(COMMUNITY_REGISTRY_ADMIN,msg.sender)
,"CommunityRegistry : Unauthorised");
_;
}
function isUserCommunityAdmin(bytes32 role, address user) public view returns (bool) {
if (hasRole(DEFAULT_ADMIN_ROLE,user) ) return true; // community_admin can do anything
if (independant){
return(
hasRole(role,user)
);
} else { // for Factories
return(roleManager().hasRole(role,user));
}
}
function roleManager() internal view returns (IAccessControlEnumerable) {
address addr = galaxisRegistry.getRegistryAddress("ROLE_MANAGER"); // universal
if (addr != address(0)) return IAccessControlEnumerable(addr);
addr = galaxisRegistry.getRegistryAddress("MAINNET_CHAIN_IMPLEMENTER"); // mainnet
if (addr != address(0)) return IAccessControlEnumerable(addr);
addr = galaxisRegistry.getRegistryAddress("L2_RECEIVER"); // mainnet
require(addr != address(0),"CommunityRegistry : no higher authority found");
return IAccessControlEnumerable(addr);
}
function grantRole(bytes32 key, address user) public override(AccessControl,IAccessControl) onlyAdmin {
_grantRole(key,user); // need to be able to grant it
}
constructor (
address _galaxisRegistry,
uint32 _community_id,
address _community_admin,
string memory _community_name
) UsesGalaxisRegistry(_galaxisRegistry){
_init(_community_id,_community_admin,_community_name);
}
function init(
uint32 _community_id,
address _community_admin,
string memory _community_name
) external {
_init(_community_id,_community_admin,_community_name);
}
function _init(
uint32 _community_id,
address _community_admin,
string memory _community_name
) internal {
require(!initialised,"This can only be called once");
initialised = true;
community_id = _community_id;
community_name = _community_name;
_setupRole(DEFAULT_ADMIN_ROLE, _community_admin); // default admin = launchpad
}
event AdminUpdated(address user, bool isAdmin);
event AppAdminChanged(address app,address user,bool state);
//===
event AddressChanged(string key, address value);
event UintChanged(string key, uint256 value);
event BooleanChanged(string key, bool value);
event StringChanged(string key, string value);
function setIndependant(bool gain_independance) external onlyAdmin {
if (independant != gain_independance) {
independant = gain_independance;
emit IndependanceDay(gain_independance);
}
}
function setAdmin(address user,bool status ) external onlyAdmin {
if (status)
_grantRole(COMMUNITY_REGISTRY_ADMIN,user);
else
_revokeRole(COMMUNITY_REGISTRY_ADMIN,user);
}
function hash(string memory field) internal pure returns (bytes32) {
return keccak256(abi.encode(field));
}
function setRegistryAddress(string memory fn, address value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
addresses[hf] = value;
addressEntries[numberOfAddresses++] = fn;
emit AddressChanged(fn,value);
}
function setRegistryBool(string memory fn, bool value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
booleans[hf] = value;
boolEntries[numberOfBooleans++] = fn;
emit BooleanChanged(fn,value);
}
function setRegistryString(string memory fn, string memory value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
strings[hf] = value;
stringEntries[numberOfStrings++] = fn;
emit StringChanged(fn,value);
}
function setRegistryUINT(string memory fn, uint value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
uints[hf] = value;
uintEntries[numberOfUINTs++] = fn;
emit UintChanged(fn,value);
}
function getRegistryAddress(string memory key) external view returns (address) {
return addresses[hash(key)];
}
function getRegistryBool(string memory key) external view returns (bool) {
return booleans[hash(key)];
}
function getRegistryUINT(string memory key) external view returns (uint256) {
return uints[hash(key)];
}
function getRegistryString(string memory key) external view returns (string memory) {
return strings[hash(key)];
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
interface IRegistry {
function setRegistryAddress(string memory fn, address value) external ;
function setRegistryBool(string memory fn, bool value) external ;
function setRegistryUINT(string memory key) external returns (uint256) ;
function setRegistryString(string memory fn, string memory value) external ;
function setAdmin(address user,bool status ) external;
function setAppAdmin(address app, address user, bool state) external;
function getRegistryAddress(string memory key) external view returns (address) ;
function getRegistryBool(string memory key) external view returns (bool);
function getRegistryUINT(string memory key) external view returns (uint256) ;
function getRegistryString(string memory key) external view returns (string memory) ;
function isAdmin(address user) external view returns (bool) ;
function isAppAdmin(address app, address user) external view returns (bool);
function numberOfAddresses() external view returns(uint256);
function addressEntries(uint256) external view returns(string memory);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "./IRegistry.sol";
contract UsesGalaxisRegistry {
IRegistry immutable public galaxisRegistry;
constructor(address _galaxisRegistry) {
galaxisRegistry = IRegistry(_galaxisRegistry);
}
}//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
import "./IVersionable.sol";
/**
* @title IGenericVersionable
* @dev Interface for generic versionable contracts extending IVersionable.
*/
interface IGenericVersionable is IVersionable {
/**
* @notice Get the base version of the contract.
* @return The base version.
*/
function baseVersion() external pure returns (uint256);
}//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
/**
* @title IVersionable
* @dev Interface for versionable contracts.
*/
interface IVersionable {
/**
* @notice Get the current version of the contract.
* @return The current version.
*/
function version() external pure returns (uint256);
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
struct TokenRecord {
bytes32 _name;
address _address;
}
interface ICommunityTokensRegistry {
function getPaymentTokens(uint32 communityId) external view returns (TokenRecord[] memory);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_galaxisRegistry","type":"address"},{"internalType":"uint32","name":"_communityId","type":"uint32"},{"internalType":"uint8","name":"_paymentTokenId","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amountOne","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTwelve","type":"uint256"}],"name":"MembershipLevelCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"position","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"MembershipLevelStatusChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amountOne","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTwelve","type":"uint256"}],"name":"MembershipLevelUpdated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PaymentToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"name","type":"bytes32[]"},{"internalType":"uint256[]","name":"amountOne","type":"uint256[]"},{"internalType":"uint256[]","name":"amountTwelve","type":"uint256[]"},{"internalType":"bytes[]","name":"metadata","type":"bytes[]"}],"name":"addLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"baseVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"communityId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"communityRegistry","outputs":[{"internalType":"contract CommunityRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"data","outputs":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"amountOne","type":"uint256"},{"internalType":"uint256","name":"amountTwelve","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"galaxisRegistry","outputs":[{"internalType":"contract IRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getMembershipAmountOne","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getMembershipAmountTwelve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getMembershipData","outputs":[{"components":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"amountOne","type":"uint256"},{"internalType":"uint256","name":"amountTwelve","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct MembershipLevelStoredData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMembershipLevels","outputs":[{"components":[{"internalType":"uint256","name":"order","type":"uint256"},{"internalType":"uint256","name":"position","type":"uint256"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"amountOne","type":"uint256"},{"internalType":"uint256","name":"amountTwelve","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct MembershipLevelInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastOrderId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"levelCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"ordering","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"position","type":"uint256"},{"internalType":"bool","name":"isActive","type":"bool"}],"name":"setLevelStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"position","type":"uint256"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"amountOne","type":"uint256"},{"internalType":"uint256","name":"amountTwelve","type":"uint256"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"updateLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"positions","type":"uint256[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"updateOrdering","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]Contract Creation Code
60a06040526001600355600060045534801561001a57600080fd5b50604051611c8d380380611c8d83398101604081905261003991610380565b6001600160a01b03831660805263ffffffff8216156103485763ffffffff82166000908155608051604051631d2e660b60e21b815260206004820152600e60248201526d10d3d353555392551657d31254d560921b60448201526001600160a01b03909116906374b9982c90606401602060405180830381865afa1580156100c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e991906103cd565b60405163d0f4a53760e01b815263ffffffff851660048201529091506000906001600160a01b0383169063d0f4a53790602401600060405180830381865afa158015610139573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610161919081019061045d565b509150506001600160a01b0381166101cd5760405162461bcd60e51b815260206004820152602560248201527f4d656d626572736869704c6576656c3a20496e76616c696420636f6d6d756e696044820152641d1e481a5960da1b606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0383811691909117909155608051604051631d2e660b60e21b815260206004820152601860248201527f434f4d4d554e4954595f544f4b454e5f52454749535452590000000000000000604482015260009291909116906374b9982c90606401602060405180830381865afa15801561025f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028391906103cd565b6040516288128f60e41b815263ffffffff871660048201529091506000906001600160a01b0383169063088128f090602401600060405180830381865afa1580156102d2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102fa9190810190610529565b9050808560ff1681518110610311576103116105fd565b602002602001015160200151600260006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505050505b505050610613565b80516001600160a01b038116811461036757600080fd5b919050565b805163ffffffff8116811461036757600080fd5b60008060006060848603121561039557600080fd5b61039e84610350565b92506103ac6020850161036c565b9150604084015160ff811681146103c257600080fd5b809150509250925092565b6000602082840312156103df57600080fd5b6103e882610350565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715610427576104276103ef565b60405290565b604051601f8201601f191681016001600160401b0381118282101715610455576104556103ef565b604052919050565b60008060006060848603121561047257600080fd5b83516001600160401b038082111561048957600080fd5b818601915086601f83011261049d57600080fd5b8151818111156104af576104af6103ef565b602091506104c5601f8201601f1916830161042d565b81815288838386010111156104d957600080fd5b60005b828110156104f75784810184015182820185015283016104dc565b5060008383830101528096505050610510818701610350565b935050506105206040850161036c565b90509250925092565b6000602080838503121561053c57600080fd5b82516001600160401b038082111561055357600080fd5b818501915085601f83011261056757600080fd5b815181811115610579576105796103ef565b610587848260051b0161042d565b818152848101925060069190911b8301840190878211156105a757600080fd5b928401925b818410156105f257604084890312156105c55760008081fd5b6105cd610405565b845181526105dc868601610350565b81870152835260409390930192918401916105ac565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b60805161165f61062e60003960006101d1015261165f6000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80637f50861a116100ad578063a217fddf11610071578063a217fddf14610255578063b2ae54b81461017e578063bb2212ed1461025d578063d3e403a314610270578063f0ba84401461029057600080fd5b80637f50861a146101f3578063853db03e146101fc5780639ca1ca751461021c578063a196354a1461022f578063a200ac861461024257600080fd5b80635662ecc7116100f45780635662ecc714610192578063651a2b4c1461019b57806365c78a7a146101a45780636eaac018146101b95780637671114d146101cc57600080fd5b80631e9c8c1c1461012657806354751c5a1461015657806354a00cc41461016b57806354fd4d501461017e575b600080fd5b600254610139906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610169610164366004610ed3565b6102b4565b005b610169610179366004610f48565b610423565b6378b3aad95b60405190815260200161014d565b61018460035481565b61018460045481565b6101ac610596565b60405161014d9190610fbe565b6101696101c7366004611182565b61077d565b6101397f000000000000000000000000000000000000000000000000000000000000000081565b61018460005481565b61018461020a366004611284565b60066020526000908152604090205481565b61018461022a366004611284565b610a67565b61018461023d366004611284565b610aae565b600154610139906001600160a01b031681565b610184600081565b61016961026b36600461129d565b610af5565b61028361027e366004611284565b610c51565b60405161014d9190611301565b6102a361029e366004611284565b610d60565b60405161014d959493929190611353565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610327919061138c565b61034c5760405162461bcd60e51b8152600401610343906113b0565b60405180910390fd5b60008581526005602081815260408084206004810154825160a0810184528a81528085018a81529381018981526060820189815260ff9093168015156080840152978d9052959094528351825591516001820155925160028401555190919060038201906103ba9082611491565b506080918201516004909101805460ff19169115159190911790556040805188815260208101889052908101869052606081018590527ffece2aee3aeb814a0b746503341b833d3c76bb59b11bc794d1183bdd3047c1aa910160405180910390a1505050505050565b60008281526005602052604090206004015481151560ff9091161515036104ab5760405162461bcd60e51b815260206004820152603660248201527f4d656d626572736869704c6576656c3a204c6576656c20697320616c726561646044820152757920696e20746865206465736972656420737461746560501b6064820152608401610343565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156104fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051e919061138c565b61053a5760405162461bcd60e51b8152600401610343906113b0565b600082815260056020908152604091829020600401805460ff19168415159081179091558251858152918201527fcbca864e401e8126ed15420979cfba9cbcaf2b142db178da9d1248679240c2e8910160405180910390a15050565b6060600060045467ffffffffffffffff8111156105b5576105b5610e1c565b60405190808252806020026020018201604052801561062b57816020015b6106186040518060e001604052806000815260200160008152602001600080191681526020016000815260200160008152602001606081526020016000151581525090565b8152602001906001900390816105d35790505b50905060015b6004548160ff16116107775760ff811660008181526006602081815260408084205480855260058352818520825160e0810184528781529690955292825290840191909152815490830152600181015460608301526002810154608083015260038101805491929160a0830191906106a89061140d565b80601f01602080910402602001604051908101604052809291908181526020018280546106d49061140d565b80156107215780601f106106f657610100808354040283529160200191610721565b820191906000526020600020905b81548152906001019060200180831161070457829003601f168201915b5050509183525050600483015460ff16151560209091015283610745600185611567565b60ff168151811061075857610758611586565b602002602001018190525050808061076f9061159c565b915050610631565b50919050565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156107cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f0919061138c565b61085a5760405162461bcd60e51b815260206004820152603560248201527f4d656d626572736869704c6576656c3a206164644c6576656c2044454641554c6044820152741517d05113525397d493d311481c995c5d5a5c9959605a1b6064820152608401610343565b60005b84518160ff161015610a60576040518060a00160405280868360ff168151811061088957610889611586565b60200260200101518152602001858360ff16815181106108ab576108ab611586565b60200260200101518152602001848360ff16815181106108cd576108cd611586565b60200260200101518152602001838360ff16815181106108ef576108ef611586565b6020026020010151815260200160011515815250600560006003548152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301908161094b9190611491565b50608091909101516004909101805460ff1916911515919091179055600380546000818152600660205260408120829055909190610988836115bb565b90915550506004805490600061099d836115bb565b91905055507fc66bb1e3bc3d1d438025c995a5d3249d144722808b4fb703690a9ea00dc9898a60016003546109d291906115d4565b868360ff16815181106109e7576109e7611586565b6020026020010151868460ff1681518110610a0457610a04611586565b6020026020010151868560ff1681518110610a2157610a21611586565b6020908102919091018101516040805195865291850193909352830152606082015260800160405180910390a180610a588161159c565b91505061085d565b5050505050565b60008181526005602052604081206004015460ff16610a985760405162461bcd60e51b8152600401610343906115e7565b5060009081526005602052604090206002015490565b60008181526005602052604081206004015460ff16610adf5760405162461bcd60e51b8152600401610343906115e7565b5060009081526005602052604090206001015490565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b68919061138c565b610bda5760405162461bcd60e51b815260206004820152603b60248201527f4d656d626572736869704c6576656c3a207570646174654f72646572696e672060448201527f44454641554c545f41444d494e5f524f4c4520726571756972656400000000006064820152608401610343565b60005b81518160ff161015610c4c57818160ff1681518110610bfe57610bfe611586565b602002602001015160066000858460ff1681518110610c1f57610c1f611586565b60200260200101518152602001908152602001600020819055508080610c449061159c565b915050610bdd565b505050565b6040805160a0810182526000808252602082018190529181018290526060808201526080810191909152600560008381526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382018054610cc79061140d565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf39061140d565b8015610d405780601f10610d1557610100808354040283529160200191610d40565b820191906000526020600020905b815481529060010190602001808311610d2357829003601f168201915b50505091835250506004919091015460ff16151560209091015292915050565b600560205260009081526040902080546001820154600283015460038401805493949293919291610d909061140d565b80601f0160208091040260200160405190810160405280929190818152602001828054610dbc9061140d565b8015610e095780601f10610dde57610100808354040283529160200191610e09565b820191906000526020600020905b815481529060010190602001808311610dec57829003601f168201915b5050506004909301549192505060ff1685565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e5b57610e5b610e1c565b604052919050565b600082601f830112610e7457600080fd5b813567ffffffffffffffff811115610e8e57610e8e610e1c565b610ea1601f8201601f1916602001610e32565b818152846020838601011115610eb657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a08688031215610eeb57600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff811115610f1e57600080fd5b610f2a88828901610e63565b9150509295509295909350565b8015158114610f4557600080fd5b50565b60008060408385031215610f5b57600080fd5b823591506020830135610f6d81610f37565b809150509250929050565b6000815180845260005b81811015610f9e57602081850181015186830182015201610f82565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561106157603f19898403018552815160e081518552888201518986015287820151888601526060808301518187015250608080830151818701525060a080830151828288015261103d83880182610f78565b60c09485015115159790940196909652505094870194925090860190600101610fe7565b509098975050505050505050565b600067ffffffffffffffff82111561108957611089610e1c565b5060051b60200190565b600082601f8301126110a457600080fd5b813560206110b96110b48361106f565b610e32565b8083825260208201915060208460051b8701019350868411156110db57600080fd5b602086015b848110156110f757803583529183019183016110e0565b509695505050505050565b600082601f83011261111357600080fd5b813560206111236110b48361106f565b82815260059290921b8401810191818101908684111561114257600080fd5b8286015b848110156110f757803567ffffffffffffffff8111156111665760008081fd5b6111748986838b0101610e63565b845250918301918301611146565b6000806000806080858703121561119857600080fd5b843567ffffffffffffffff808211156111b057600080fd5b818701915087601f8301126111c457600080fd5b813560206111d46110b48361106f565b82815260059290921b8401810191818101908b8411156111f357600080fd5b948201945b83861015611211578535825294820194908201906111f8565b9850508801359250508082111561122757600080fd5b61123388838901611093565b9450604087013591508082111561124957600080fd5b61125588838901611093565b9350606087013591508082111561126b57600080fd5b5061127887828801611102565b91505092959194509250565b60006020828403121561129657600080fd5b5035919050565b600080604083850312156112b057600080fd5b823567ffffffffffffffff808211156112c857600080fd5b6112d486838701611093565b935060208501359150808211156112ea57600080fd5b506112f785828601611093565b9150509250929050565b602081528151602082015260208201516040820152604082015160608201526000606083015160a0608084015261133b60c0840182610f78565b90506080840151151560a08401528091505092915050565b85815284602082015283604082015260a06060820152600061137860a0830185610f78565b905082151560808301529695505050505050565b60006020828403121561139e57600080fd5b81516113a981610f37565b9392505050565b60208082526038908201527f4d656d626572736869704c6576656c3a207570646174654c6576656c2044454660408201527f41554c545f41444d494e5f524f4c452072657175697265640000000000000000606082015260800190565b600181811c9082168061142157607f821691505b60208210810361077757634e487b7160e01b600052602260045260246000fd5b601f821115610c4c576000816000526020600020601f850160051c8101602086101561146a5750805b601f850160051c820191505b8181101561148957828155600101611476565b505050505050565b815167ffffffffffffffff8111156114ab576114ab610e1c565b6114bf816114b9845461140d565b84611441565b602080601f8311600181146114f457600084156114dc5750858301515b600019600386901b1c1916600185901b178555611489565b600085815260208120601f198616915b8281101561152357888601518255948401946001909101908401611504565b50858210156115415787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b60ff828116828216039081111561158057611580611551565b92915050565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff81036115b2576115b2611551565b60010192915050565b6000600182016115cd576115cd611551565b5060010190565b8181038181111561158057611580611551565b60208082526022908201527f4d656d626572736869704c6576656c203a206c6576656c206e6f742061637469604082015261766560f01b60608201526080019056fea2646970667358221220ba0a8b0197421a0c66f27819ff99dac43ad66fadc657eeff748571d8a2c1ffc764736f6c63430008190033000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101215760003560e01c80637f50861a116100ad578063a217fddf11610071578063a217fddf14610255578063b2ae54b81461017e578063bb2212ed1461025d578063d3e403a314610270578063f0ba84401461029057600080fd5b80637f50861a146101f3578063853db03e146101fc5780639ca1ca751461021c578063a196354a1461022f578063a200ac861461024257600080fd5b80635662ecc7116100f45780635662ecc714610192578063651a2b4c1461019b57806365c78a7a146101a45780636eaac018146101b95780637671114d146101cc57600080fd5b80631e9c8c1c1461012657806354751c5a1461015657806354a00cc41461016b57806354fd4d501461017e575b600080fd5b600254610139906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610169610164366004610ed3565b6102b4565b005b610169610179366004610f48565b610423565b6378b3aad95b60405190815260200161014d565b61018460035481565b61018460045481565b6101ac610596565b60405161014d9190610fbe565b6101696101c7366004611182565b61077d565b6101397f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae281565b61018460005481565b61018461020a366004611284565b60066020526000908152604090205481565b61018461022a366004611284565b610a67565b61018461023d366004611284565b610aae565b600154610139906001600160a01b031681565b610184600081565b61016961026b36600461129d565b610af5565b61028361027e366004611284565b610c51565b60405161014d9190611301565b6102a361029e366004611284565b610d60565b60405161014d959493929190611353565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610327919061138c565b61034c5760405162461bcd60e51b8152600401610343906113b0565b60405180910390fd5b60008581526005602081815260408084206004810154825160a0810184528a81528085018a81529381018981526060820189815260ff9093168015156080840152978d9052959094528351825591516001820155925160028401555190919060038201906103ba9082611491565b506080918201516004909101805460ff19169115159190911790556040805188815260208101889052908101869052606081018590527ffece2aee3aeb814a0b746503341b833d3c76bb59b11bc794d1183bdd3047c1aa910160405180910390a1505050505050565b60008281526005602052604090206004015481151560ff9091161515036104ab5760405162461bcd60e51b815260206004820152603660248201527f4d656d626572736869704c6576656c3a204c6576656c20697320616c726561646044820152757920696e20746865206465736972656420737461746560501b6064820152608401610343565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156104fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051e919061138c565b61053a5760405162461bcd60e51b8152600401610343906113b0565b600082815260056020908152604091829020600401805460ff19168415159081179091558251858152918201527fcbca864e401e8126ed15420979cfba9cbcaf2b142db178da9d1248679240c2e8910160405180910390a15050565b6060600060045467ffffffffffffffff8111156105b5576105b5610e1c565b60405190808252806020026020018201604052801561062b57816020015b6106186040518060e001604052806000815260200160008152602001600080191681526020016000815260200160008152602001606081526020016000151581525090565b8152602001906001900390816105d35790505b50905060015b6004548160ff16116107775760ff811660008181526006602081815260408084205480855260058352818520825160e0810184528781529690955292825290840191909152815490830152600181015460608301526002810154608083015260038101805491929160a0830191906106a89061140d565b80601f01602080910402602001604051908101604052809291908181526020018280546106d49061140d565b80156107215780601f106106f657610100808354040283529160200191610721565b820191906000526020600020905b81548152906001019060200180831161070457829003601f168201915b5050509183525050600483015460ff16151560209091015283610745600185611567565b60ff168151811061075857610758611586565b602002602001018190525050808061076f9061159c565b915050610631565b50919050565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156107cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f0919061138c565b61085a5760405162461bcd60e51b815260206004820152603560248201527f4d656d626572736869704c6576656c3a206164644c6576656c2044454641554c6044820152741517d05113525397d493d311481c995c5d5a5c9959605a1b6064820152608401610343565b60005b84518160ff161015610a60576040518060a00160405280868360ff168151811061088957610889611586565b60200260200101518152602001858360ff16815181106108ab576108ab611586565b60200260200101518152602001848360ff16815181106108cd576108cd611586565b60200260200101518152602001838360ff16815181106108ef576108ef611586565b6020026020010151815260200160011515815250600560006003548152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301908161094b9190611491565b50608091909101516004909101805460ff1916911515919091179055600380546000818152600660205260408120829055909190610988836115bb565b90915550506004805490600061099d836115bb565b91905055507fc66bb1e3bc3d1d438025c995a5d3249d144722808b4fb703690a9ea00dc9898a60016003546109d291906115d4565b868360ff16815181106109e7576109e7611586565b6020026020010151868460ff1681518110610a0457610a04611586565b6020026020010151868560ff1681518110610a2157610a21611586565b6020908102919091018101516040805195865291850193909352830152606082015260800160405180910390a180610a588161159c565b91505061085d565b5050505050565b60008181526005602052604081206004015460ff16610a985760405162461bcd60e51b8152600401610343906115e7565b5060009081526005602052604090206002015490565b60008181526005602052604081206004015460ff16610adf5760405162461bcd60e51b8152600401610343906115e7565b5060009081526005602052604090206001015490565b600154604051632474521560e21b8152600060048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b68919061138c565b610bda5760405162461bcd60e51b815260206004820152603b60248201527f4d656d626572736869704c6576656c3a207570646174654f72646572696e672060448201527f44454641554c545f41444d494e5f524f4c4520726571756972656400000000006064820152608401610343565b60005b81518160ff161015610c4c57818160ff1681518110610bfe57610bfe611586565b602002602001015160066000858460ff1681518110610c1f57610c1f611586565b60200260200101518152602001908152602001600020819055508080610c449061159c565b915050610bdd565b505050565b6040805160a0810182526000808252602082018190529181018290526060808201526080810191909152600560008381526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382018054610cc79061140d565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf39061140d565b8015610d405780601f10610d1557610100808354040283529160200191610d40565b820191906000526020600020905b815481529060010190602001808311610d2357829003601f168201915b50505091835250506004919091015460ff16151560209091015292915050565b600560205260009081526040902080546001820154600283015460038401805493949293919291610d909061140d565b80601f0160208091040260200160405190810160405280929190818152602001828054610dbc9061140d565b8015610e095780601f10610dde57610100808354040283529160200191610e09565b820191906000526020600020905b815481529060010190602001808311610dec57829003601f168201915b5050506004909301549192505060ff1685565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e5b57610e5b610e1c565b604052919050565b600082601f830112610e7457600080fd5b813567ffffffffffffffff811115610e8e57610e8e610e1c565b610ea1601f8201601f1916602001610e32565b818152846020838601011115610eb657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a08688031215610eeb57600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff811115610f1e57600080fd5b610f2a88828901610e63565b9150509295509295909350565b8015158114610f4557600080fd5b50565b60008060408385031215610f5b57600080fd5b823591506020830135610f6d81610f37565b809150509250929050565b6000815180845260005b81811015610f9e57602081850181015186830182015201610f82565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561106157603f19898403018552815160e081518552888201518986015287820151888601526060808301518187015250608080830151818701525060a080830151828288015261103d83880182610f78565b60c09485015115159790940196909652505094870194925090860190600101610fe7565b509098975050505050505050565b600067ffffffffffffffff82111561108957611089610e1c565b5060051b60200190565b600082601f8301126110a457600080fd5b813560206110b96110b48361106f565b610e32565b8083825260208201915060208460051b8701019350868411156110db57600080fd5b602086015b848110156110f757803583529183019183016110e0565b509695505050505050565b600082601f83011261111357600080fd5b813560206111236110b48361106f565b82815260059290921b8401810191818101908684111561114257600080fd5b8286015b848110156110f757803567ffffffffffffffff8111156111665760008081fd5b6111748986838b0101610e63565b845250918301918301611146565b6000806000806080858703121561119857600080fd5b843567ffffffffffffffff808211156111b057600080fd5b818701915087601f8301126111c457600080fd5b813560206111d46110b48361106f565b82815260059290921b8401810191818101908b8411156111f357600080fd5b948201945b83861015611211578535825294820194908201906111f8565b9850508801359250508082111561122757600080fd5b61123388838901611093565b9450604087013591508082111561124957600080fd5b61125588838901611093565b9350606087013591508082111561126b57600080fd5b5061127887828801611102565b91505092959194509250565b60006020828403121561129657600080fd5b5035919050565b600080604083850312156112b057600080fd5b823567ffffffffffffffff808211156112c857600080fd5b6112d486838701611093565b935060208501359150808211156112ea57600080fd5b506112f785828601611093565b9150509250929050565b602081528151602082015260208201516040820152604082015160608201526000606083015160a0608084015261133b60c0840182610f78565b90506080840151151560a08401528091505092915050565b85815284602082015283604082015260a06060820152600061137860a0830185610f78565b905082151560808301529695505050505050565b60006020828403121561139e57600080fd5b81516113a981610f37565b9392505050565b60208082526038908201527f4d656d626572736869704c6576656c3a207570646174654c6576656c2044454660408201527f41554c545f41444d494e5f524f4c452072657175697265640000000000000000606082015260800190565b600181811c9082168061142157607f821691505b60208210810361077757634e487b7160e01b600052602260045260246000fd5b601f821115610c4c576000816000526020600020601f850160051c8101602086101561146a5750805b601f850160051c820191505b8181101561148957828155600101611476565b505050505050565b815167ffffffffffffffff8111156114ab576114ab610e1c565b6114bf816114b9845461140d565b84611441565b602080601f8311600181146114f457600084156114dc5750858301515b600019600386901b1c1916600185901b178555611489565b600085815260208120601f198616915b8281101561152357888601518255948401946001909101908401611504565b50858210156115415787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b60ff828116828216039081111561158057611580611551565b92915050565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff81036115b2576115b2611551565b60010192915050565b6000600182016115cd576115cd611551565b5060010190565b8181038181111561158057611580611551565b60208082526022908201527f4d656d626572736869704c6576656c203a206c6576656c206e6f742061637469604082015261766560f01b60608201526080019056fea2646970667358221220ba0a8b0197421a0c66f27819ff99dac43ad66fadc657eeff748571d8a2c1ffc764736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _galaxisRegistry (address): 0xdBD9608fBcA959828C1615d29AEb3dc872d40Ae2
Arg [1] : _communityId (uint32): 0
Arg [2] : _paymentTokenId (uint8): 0
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae2
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.