Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x39c0BC24f458516b2b761Fb573c063369Cd386F7
Balance 0 ETH
Nonce 1
Code Size 1695 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

1695 bytes
0x6080806040526004361015610012575f80fd5b5f3560e01c90816361d027b3146105555750806369fe0e2d146104fb578063715018a6146104a457806385f080c2146104685780638da5cb5b1461044157806392630546146103d9578063a29002ac146103bc578063cf5be0e014610385578063d371cd501461022e578063ddca3f4314610211578063e1f1c4a7146101f5578063efdf07d5146101d8578063f0f44260146101435763f2fde38b146100b6575f80fd5b3461013f57602036600319011261013f576004356001600160a01b0381169081900361013f576100e4610643565b801561012c575f80546001600160a01b03198116831782556001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3005b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b3461013f57602036600319011261013f576004356001600160a01b0381169081900361013f57610171610643565b8015610193576bffffffffffffffffffffffff60a01b60015416176001555f80f35b60405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207472656173757279206164647265737300000000000000006044820152606490fd5b3461013f575f36600319011261013f576020600354604051908152f35b3461013f575f36600319011261013f5760206040516127108152f35b3461013f575f36600319011261013f576020600254604051908152f35b602036600319011261013f576004356001600160a01b0381169081810361013f5760025434106103765733821461036757620151804204335f5260046020528060405f20541461035857335f52600460205260405f205560055460018101809111610344576005555f90826102ff575b505f80806102ad819434610578565b6001546001600160a01b03165af16102c36105de565b50156102f057337f1dae76dcd764555e67098f3d58983f26d8c514131cf517c44875f3a7a6745c8a5f80a3005b634033e4e360e01b5f5260045ffd5b9050600354803402903482041434151715610344575f808061271081940480955af16103296105de565b5015610335578261029e565b6387df070960e01b5f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b63b899724f60e01b5f5260045ffd5b632af47b8760e11b5f5260045ffd5b631a84bc4160e21b5f5260045ffd5b3461013f57602036600319011261013f576004356001600160a01b038116810361013f576103b4602091610585565b604051908152f35b3461013f575f36600319011261013f576020600554604051908152f35b3461013f57602036600319011261013f576004356103f5610643565b61271081101561040457600355005b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420726566657272616c206665657360581b6044820152606490fd5b3461013f575f36600319011261013f575f546040516001600160a01b039091168152602090f35b3461013f57602036600319011261013f576004356001600160a01b0381169081900361013f575f526004602052602060405f2054604051908152f35b3461013f575f36600319011261013f576104bc610643565b5f80546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461013f57602036600319011261013f57600435610517610643565b801561052257600255005b60405162461bcd60e51b815260206004820152600b60248201526a496e76616c69642066656560a81b6044820152606490fd5b3461013f575f36600319011261013f576001546001600160a01b03168152602090f35b9190820391821161034457565b6001600160a01b03165f908152600460205260409020546201518042049081116105d957600181018091116103445762015180810290808204620151801490151715610344576105d6904290610578565b90565b505f90565b3d1561063e573d9067ffffffffffffffff821161062a5760405191601f8101601f19908116603f0116830167ffffffffffffffff81118482101761062a5760405282523d5f602084013e565b634e487b7160e01b5f52604160045260245ffd5b606090565b5f546001600160a01b0316330361065657565b63118cdaa760e01b5f523360045260245ffdfea26469706673582212207cd4b9e22bce9c7d1691c08d650e7c134bc0c86ab3abf60c5f531010834b709d64736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: Yes (200 runs)
GMCounter_flattened.sol 230 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Context.sol


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

pragma solidity ^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.
 */
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;
    }
}

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

// File: contracts/GMCounter.sol


contract GMCounter is Ownable {
    address public treasury;
    uint256 public fee;
    uint256 public referralFees;

    uint256 public constant BASIS_POINTS = 10000;

    mapping(address => uint256) public lastGM;

    uint256 public totalGMs;

    event GMSent(address indexed sender, address indexed referral);

    error InsufficientETH();
    error AlreadySentGM();
    error ReferralTransferFailed();
    error FeeTransferFailed();
    error SelfReferral();

    constructor(
        address _treasury,
        uint256 _fee,
        uint256 _referralFees
    ) Ownable(msg.sender) {
        treasury = _treasury;
        fee = _fee;
        referralFees = _referralFees;
    }

    function sayGM(address referral) external payable {
        if (msg.value < fee) {
            revert InsufficientETH();
        }

        if (referral == msg.sender) {
            revert SelfReferral();
        }

        uint256 today = block.timestamp / 86400;

        if (lastGM[msg.sender] == today) {
            revert AlreadySentGM();
        }

        lastGM[msg.sender] = today;
        
        totalGMs += 1;
        
        uint256 referralAmount = 0;

        if (referral != address(0)) {
            referralAmount = (msg.value * referralFees) / BASIS_POINTS;
            (bool refSuccess, ) = referral.call{value: referralAmount}("");
            if (!refSuccess) {
                revert ReferralTransferFailed();
            }
        }

        uint256 remaining = msg.value - referralAmount;

        (bool success, ) = treasury.call{value: remaining}("");

        if (!success) {
            revert FeeTransferFailed();
        }
        
        emit GMSent(msg.sender, referral);
    }

    function nextGMTimer(address user) external view returns (uint256) {
        uint256 today = block.timestamp / 86400;

        if (lastGM[user] < today) {
            return 0;
        }

        uint256 nextDay = (today + 1) * 86400;
        return nextDay - block.timestamp;
    }

    function setTreasury(address _treasury) external onlyOwner {
        require(_treasury != address(0), "Invalid treasury address");
        treasury = _treasury;
    }

    function setFee(uint256 _fee) external onlyOwner {
        require(_fee > 0, "Invalid fee");
        fee = _fee;
    }

    function setReferralFees(uint256 _referralFees) external onlyOwner {
        require(_referralFees < BASIS_POINTS, "Invalid referral fees");
        referralFees = _referralFees;
    }
}

Read Contract

BASIS_POINTS 0xe1f1c4a7 → uint256
fee 0xddca3f43 → uint256
lastGM 0x85f080c2 → uint256
nextGMTimer 0xcf5be0e0 → uint256
owner 0x8da5cb5b → address
referralFees 0xefdf07d5 → uint256
totalGMs 0xa29002ac → uint256
treasury 0x61d027b3 → address

Write Contract 6 functions

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

renounceOwnership 0x715018a6
No parameters
sayGM 0xd371cd50
address referral
setFee 0x69fe0e2d
uint256 _fee
setReferralFees 0x92630546
uint256 _referralFees
setTreasury 0xf0f44260
address _treasury
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address