Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xe54296d900F1950dB35D1d4Ec6ffDBC201Ea224e
Balance 0 ETH
Nonce 1
Code Size 2659 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

2659 bytes
0x608060405234801561000f575f5ffd5b5060043610610111575f3560e01c80638b5521ed1161009e578063d547741f1161006e578063d547741f14610393578063d9ba32fc146103a6578063e43252d714610405578063f30c0e0814610418578063fe1ced5e1461042b575f5ffd5b80638b5521ed1461033457806391d1485414610347578063a217fddf1461035a578063bb8b3ea914610361575f5ffd5b806336568abe116100e457806336568abe1461019557806364be6c5e146101a8578063715da4f2146102e7578063743a508d146102fa5780637a997ab71461030d575f5ffd5b806301ffc9a714610115578063248a9ca31461013d578063266d62c11461016d5780632f2ff15d14610182575b5f5ffd5b6101286101233660046108e3565b61043e565b60405190151581526020015b60405180910390f35b61015f61014b366004610911565b5f9081526020819052604090206001015490565b604051908152602001610134565b61018061017b366004610943565b610474565b005b610180610190366004610972565b61049b565b6101806101a3366004610972565b6104c5565b6102746101b6366004610943565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a0810191909152506001600160801b039081165f90815260026020818152604092839020835160c08101855281546001600160a01b03168152600182015480871693820193909352600160801b90920490941692810192909252919091015467ffffffffffffffff8116606083015260ff600160401b8204811615156080840152600160481b90910416151560a082015290565b60405161013491905f60c08201905060018060a01b0383511682526001600160801b0360208401511660208301526001600160801b03604084015116604083015267ffffffffffffffff606084015116606083015260808301511515608083015260a0830151151560a083015292915050565b6101806102f536600461099c565b6104fd565b6101806103083660046109c4565b610534565b61015f7fdc72ed553f2544c34465af23b847953efeb813428162d767f9ba5f4013be676081565b610180610342366004610943565b610624565b610128610355366004610972565b61065f565b61015f5f81565b60035461037b90600160801b90046001600160801b031681565b6040516001600160801b039091168152602001610134565b6101806103a1366004610972565b610687565b6103e56103b43660046109de565b6001600160a01b03165f9081526001602052604090205467ffffffffffffffff811691600160401b90910460ff1690565b6040805167ffffffffffffffff9093168352901515602083015201610134565b6101806104133660046109de565b6106ab565b60035461037b906001600160801b031681565b6101806104393660046109de565b6106f6565b5f6001600160e01b03198216637965db0b60e01b148061046e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b61047c610721565b600380546001600160801b03928316600160801b029216919091179055565b5f828152602081905260409020600101546104b581610762565b6104bf838361076f565b50505050565b6001600160a01b03811633146104ee5760405163334bd91960e11b815260040160405180910390fd5b6104f882826107fe565b505050565b610505610721565b6001600160801b039182165f9081526002602052604090206001018054918316600160801b0291909216179055565b61053c610721565b61054582610867565b600380545f9061055d906001600160801b03166109f7565b82546101009290920a6001600160801b038181021990931691831602179091556003805482165f90815260026020819052604080832080546001600160a01b0319166001600160a01b03989098169790971790965582548416825285822060010180546fffffffffffffffffffffffffffffffff1916958516959095179094558154831681528481208401805467ffffffffffffffff19164267ffffffffffffffff161790559054909116815291909120018054600160401b60ff60401b19909116179055565b61062c610721565b6001600160801b03165f90815260026020819052604090912001805469ff0000000000000000001916600160481b179055565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b5f828152602081905260409020600101546106a181610762565b6104bf83836107fe565b6106b3610721565b6106bc81610867565b6001600160a01b03165f908152600160205260409020805468ffffffffffffffffff191667ffffffffffffffff421617600160401b179055565b6106fe610721565b6001600160a01b03165f908152600160205260409020805460ff60401b19169055565b61074b7fdc72ed553f2544c34465af23b847953efeb813428162d767f9ba5f4013be67603361065f565b610760576107606302c139b560e51b33610885565b565b61076c813361089a565b50565b5f61077a838361065f565b6107f7575f838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556107af3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161046e565b505f61046e565b5f610809838361065f565b156107f7575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161046e565b6001600160a01b03811661076c5761076c637299a72960e01b6108db565b815f526001600160a01b03811660045260245ffd5b6108a4828261065f565b6108d75760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440160405180910390fd5b5050565b805f5260045ffd5b5f602082840312156108f3575f5ffd5b81356001600160e01b03198116811461090a575f5ffd5b9392505050565b5f60208284031215610921575f5ffd5b5035919050565b80356001600160801b038116811461093e575f5ffd5b919050565b5f60208284031215610953575f5ffd5b61090a82610928565b80356001600160a01b038116811461093e575f5ffd5b5f5f60408385031215610983575f5ffd5b823591506109936020840161095c565b90509250929050565b5f5f604083850312156109ad575f5ffd5b6109b683610928565b915061099360208401610928565b5f5f604083850312156109d5575f5ffd5b6109b68361095c565b5f602082840312156109ee575f5ffd5b61090a8261095c565b5f6001600160801b0382166001600160801b038103610a2457634e487b7160e01b5f52601160045260245ffd5b6001019291505056fea264697066735822122095d104a9ea99fb79bcbe0852e51d822fc16c2766b93f3d3d3d8d487701a2fa2e64736f6c634300081d0033

Verified Source Code Partial Match

Compiler: v0.8.29+commit.ab55807c EVM: cancun Optimization: Yes (200 runs)
WhiteList.sol 506 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.29 >=0.4.16 >=0.8.4 ^0.8.0 ^0.8.20;

// lib/openzeppelin-contracts/contracts/utils/Context.sol

// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// src/Lib/CustomRevert.sol

/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
    /// @dev Reverts with the selector of a custom error in the scratch space
    function revertWith(bytes4 selector) internal pure {
        assembly ("memory-safe") {
            mstore(0, selector)
            revert(0, 0x04)
        }
    }

    /// @dev Reverts with a custom error with an address argument in the scratch space
    function revertWith(bytes4 selector, address addr) internal pure {
        assembly ("memory-safe") {
            mstore(0, selector)
            mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
            revert(0, 0x24)
        }
    }

}

// lib/openzeppelin-contracts/contracts/access/IAccessControl.sol

// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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 to signal this.
     */
    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. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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);
}

// lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol

// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// lib/openzeppelin-contracts/contracts/access/AccessControl.sol

// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.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.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /// @inheritdoc IERC165
    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 returns (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) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        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}.
     */
    function getRoleAdmin(bytes32 role) public view virtual 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 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 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 `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        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) internal virtual {
        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) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` from `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) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

// src/WhiteList.sol

contract WhiteList is AccessControl {

    using CustomRevert for bytes4;

    bytes32 public constant WHITELIST_ROLE = 0xdc72ed553f2544c34465af23b847953efeb813428162d767f9ba5f4013be6760;

    error notSetRole(address caller);
    error addressZero();

    struct Record {
        ///@dev date it's set as uint64 because the maximum value 18446744073709551616 in Unix time would be Monday, 
        ///July 17, 7815, which is approximately 5791 years from now.
        uint64 date;
        bool status;
    }

    mapping(address => Record) private whitelistAddress;

    struct GrantInformation {
        address user;
        uint128 amount;
        uint128 amountSold;
        uint64 date;
        bool grantStatus;
        bool sold;
    }

    mapping(uint256 => GrantInformation) private grantInfo;

    uint128 public grantId;
    uint128 public nextGrantId;

    constructor() {
        _grantRole(DEFAULT_ADMIN_ROLE,msg.sender);
        _grantRole(WHITELIST_ROLE,msg.sender);
    }

    //Modifiers
    function onlyWhitelistRole() private view {
        if(!hasRole(WHITELIST_ROLE,msg.sender)){
            notSetRole.selector.revertWith(msg.sender);
        }
    }

    function notZeroAddress(address wallet) private pure {
        if(wallet == address(0)){
            addressZero.selector.revertWith();
        }
    }

    function addToWhitelist(address user) external {
        onlyWhitelistRole();
        notZeroAddress(user);
        whitelistAddress[user].date = uint64(block.timestamp);
        whitelistAddress[user].status = true;
    }

    function removeToWhitelist(address user) external {
        onlyWhitelistRole();
        whitelistAddress[user].status = false;
    }

    function getWhitelistStatus(address user) external view returns(uint64,bool) {
        return (whitelistAddress[user].date,
        whitelistAddress[user].status);
    }

    function addToGrant(address user, uint128 amount) external {
        onlyWhitelistRole();
        notZeroAddress(user);
        ++grantId;
        grantInfo[grantId].user = user;
        grantInfo[grantId].amount = amount;
        grantInfo[grantId].date = uint64(block.timestamp);
        grantInfo[grantId].grantStatus = true;
    }

    function updateAmountSold(uint128 _grantId, uint128 _amountSold) external {
        onlyWhitelistRole();
        grantInfo[_grantId].amountSold = _amountSold;
    }

    function grantSold(uint128 _grantId) external {
        onlyWhitelistRole();
        grantInfo[_grantId].sold = true;
    }

    function getGrantInfo(uint128 _grantId) external view returns(GrantInformation memory info) {
        info = grantInfo[_grantId];
    }

    function updateNextGrantId(uint128 nextId) external {
        onlyWhitelistRole();
        nextGrantId = nextId;
    }

}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
WHITELIST_ROLE 0x7a997ab7 → bytes32
getGrantInfo 0x64be6c5e → tuple
getRoleAdmin 0x248a9ca3 → bytes32
getWhitelistStatus 0xd9ba32fc → uint64, bool
grantId 0xf30c0e08 → uint128
hasRole 0x91d14854 → bool
nextGrantId 0xbb8b3ea9 → uint128
supportsInterface 0x01ffc9a7 → bool

Write Contract 9 functions

These functions modify contract state and require a wallet transaction to execute.

addToGrant 0x743a508d
address user
uint128 amount
addToWhitelist 0xe43252d7
address user
grantRole 0x2f2ff15d
bytes32 role
address account
grantSold 0x8b5521ed
uint128 _grantId
removeToWhitelist 0xfe1ced5e
address user
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
updateAmountSold 0x715da4f2
uint128 _grantId
uint128 _amountSold
updateNextGrantId 0x266d62c1
uint128 nextId

Recent Transactions

No transactions found for this address