// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)pragmasolidity ^0.8.20;import {IAccessControl} from"./IAccessControl.sol";
import {Context} from"../utils/Context.sol";
import {ERC165} from"../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:
*
* ```solidity
* 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}:
*
* ```solidity
* 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. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/abstractcontractAccessControlisContext, IAccessControl, ERC165{
structRoleData {
mapping(address account =>bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32publicconstant DEFAULT_ADMIN_ROLE =0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/modifieronlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverridereturns (bool) {
return interfaceId ==type(IAccessControl).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/functionhasRole(bytes32 role, address account) publicviewvirtualreturns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/function_checkRole(bytes32 role) internalviewvirtual{
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/function_checkRole(bytes32 role, address account) internalviewvirtual{
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/functiongetRoleAdmin(bytes32 role) publicviewvirtualreturns (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.
*/functiongrantRole(bytes32 role, address account) publicvirtualonlyRole(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.
*/functionrevokeRole(bytes32 role, address account) publicvirtualonlyRole(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 `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/functionrenounceRole(bytes32 role, address callerConfirmation) publicvirtual{
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/function_setRoleAdmin(bytes32 role, bytes32 adminRole) internalvirtual{
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/function_grantRole(bytes32 role, address account) internalvirtualreturns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] =true;
emit RoleGranted(role, account, _msgSender());
returntrue;
} else {
returnfalse;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/function_revokeRole(bytes32 role, address account) internalvirtualreturns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] =false;
emit RoleRevoked(role, account, _msgSender());
returntrue;
} else {
returnfalse;
}
}
}
Contract Source Code
File 2 of 8: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)pragmasolidity ^0.8.20;/**
* @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.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
function_contextSuffixLength() internalviewvirtualreturns (uint256) {
return0;
}
}
Contract Source Code
File 3 of 8: ERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)pragmasolidity ^0.8.20;import {IERC165} from"./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);
* }
* ```
*/abstractcontractERC165isIERC165{
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualreturns (bool) {
return interfaceId ==type(IERC165).interfaceId;
}
}
Contract Source Code
File 4 of 8: GenesisGatewayMinter.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;import"@openzeppelin/contracts/access/AccessControl.sol";
import"./interfaces/IGenesisGateway.sol";
import"./interfaces/IERC20.sol";
contractGenesisGatewayMinterisAccessControl{
enumStatus {
Pause,
GL,
Completed
}
Status public status;
structMintDetails {
uint256 supply;
uint256 minted;
uint256 startTime;
uint256 duration;
}
MintDetails public mintPhase;
bytes32publicconstant ADMIN_ROLE =keccak256("ADMIN_ROLE");
IGenesisGateway public token;
uintpublic depositAmount =.04ether;
mapping(address=>bool) public depositors;
mapping(address=>bool) public whitelist;
mapping(address=>bool) public userMinted;
mapping(address=>bool) public depositWhitelist;
uintpublic depositStartTime =1725454800;
uintpublic depositDuration =1days;
eventDeposit(address depositor, uint256 amount, uint256 time);
constructor (
IGenesisGateway _tokenAddress
) {
token = IGenesisGateway(_tokenAddress);
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
_grantRole(ADMIN_ROLE, _msgSender());
mintPhase = MintDetails(
250,
0,
1725544800,
1days
);
status = Status(Status.GL);
}
modifierisMintValid (address _to) {
require(_to !=address(0), 'Zero Address');
if(status == Status.Pause){
revert('Minting is paused');
}
if(status == Status.Completed){
revert('Minting is completed');
}
if (status == Status.GL) {
require(mintPhase.startTime <=block.timestamp, 'GL minting is not started');
require(whitelist[_to], 'Not in GL whitelist');
require(!userMinted[_to], 'Already minted in gl');
require(mintPhase.startTime + mintPhase.duration >=block.timestamp, 'Time is up for GL');
require(mintPhase.minted +1<= mintPhase.supply, "Exceeded phase supply");
}
_;
}
functionmint(address _to) publicisMintValid(_to) {
_mint(_to);
userMinted[_to] =true;
mintPhase.minted +=1;
}
function_mint(address _to) private{
token.mint(_to, token.totalSupply() +1);
}
functionbatchMint(address _wallet, uint _count) publiconlyRole(ADMIN_ROLE) {
for (uint i =0; i < _count;) {
_mint(_wallet);
unchecked {
i++;
}
}
}
functiondeposit() publicpayable{
require(depositStartTime <=block.timestamp, "Deposit is not started");
require(depositStartTime + depositDuration >=block.timestamp, 'The time is up for the deposit');
require(depositWhitelist[msg.sender], "Not in FCFS whitelist");
require(msg.value== depositAmount, "invalid value");
require(!depositors[msg.sender], "Already deposited");
depositors[msg.sender] =true;
emit Deposit(msg.sender, msg.value, block.timestamp);
}
functionupdateDepositAmount(uint256 _depositAmount) publiconlyRole(ADMIN_ROLE) {
depositAmount = _depositAmount;
}
functionupdateDepositStartTime(uint256 _time) publiconlyRole(ADMIN_ROLE) {
depositStartTime = _time;
}
functionupdateDepositDuration(uint256 _duration) publiconlyRole(ADMIN_ROLE) {
depositDuration = _duration;
}
functionsetStatus(Status _status) publiconlyRole(ADMIN_ROLE) {
status = _status;
}
functionupdatePhase(uint256 _supply,
uint256 _startTime,
uint256 _duration
) publiconlyRole(ADMIN_ROLE) {
mintPhase.supply = _supply;
mintPhase.startTime = _startTime;
mintPhase.duration = _duration;
}
functionupdateWhitelist(address[] memory _addresses, bool _isWhitelist) publiconlyRole(ADMIN_ROLE) {
for (uint8 i =0; i < _addresses.length;) {
whitelist[_addresses[i]] = _isWhitelist;
unchecked {
i++;
}
}
}
functionupdateDepositWhitelist(address[] memory _addresses, bool _isWhitelist) publiconlyRole(ADMIN_ROLE) {
for (uint8 i =0; i < _addresses.length;) {
depositWhitelist[_addresses[i]] = _isWhitelist;
unchecked {
i++;
}
}
}
functionadminRefund(address[] memory recipients) publiconlyRole(ADMIN_ROLE) {
uint256 totalRecipients = recipients.length;
require(address(this).balance>= totalRecipients * depositAmount, "Insufficient contract balance");
for (uint16 i =0; i < totalRecipients;) {
require(depositors[recipients[i]], "The user has not deposited yet");
payable(recipients[i]).transfer(depositAmount);
depositors[recipients[i]] =false;
unchecked {
i++;
}
}
}
functionownerWithdrawTokens(uint256 amount,
address _to,
address _tokenAddr
) publiconlyRole(ADMIN_ROLE) {
require(_to !=address(0));
if(_tokenAddr ==address(0)){
payable(_to).transfer(amount);
} else {
IERC20(_tokenAddr).transfer(_to, amount);
}
}
}
Contract Source Code
File 5 of 8: IAccessControl.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)pragmasolidity ^0.8.20;/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/interfaceIAccessControl{
/**
* @dev The `account` is missing a role.
*/errorAccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/errorAccessControlBadConfirmation();
/**
* @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.
*/eventRoleAdminChanged(bytes32indexed role, bytes32indexed previousAdminRole, bytes32indexed 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}.
*/eventRoleGranted(bytes32indexed role, addressindexed account, addressindexed 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`)
*/eventRoleRevoked(bytes32indexed role, addressindexed account, addressindexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/functionhasRole(bytes32 role, address account) externalviewreturns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/functiongetRoleAdmin(bytes32 role) externalviewreturns (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.
*/functiongrantRole(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.
*/functionrevokeRole(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 `callerConfirmation`.
*/functionrenounceRole(bytes32 role, address callerConfirmation) external;
}
Contract Source Code
File 6 of 8: IERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)pragmasolidity ^0.8.20;/**
* @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}.
*/interfaceIERC165{
/**
* @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.
*/functionsupportsInterface(bytes4 interfaceId) externalviewreturns (bool);
}