Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5C0C58462F2F2E447745BF8042C39062BF8257E9
Balance 0 ETH
Nonce 1
Code Size 3498 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3498 bytes
0x608080604052600436101561001d575b50361561001b57600080fd5b005b60003560e01c908163016312f914610bcc575080630197d97214610bae57806306f837d314610b905780631bfce85314610b7257806327b3bf1114610b545780632866ed2114610b365780633751789614610b18578063380d831b14610af85780634b8624c414610adc5780634e71d92d14610a3d578063667eeee51461098b578063715018a614610932578063790ca4131461091457806382760cd21461088e5780638da5cb5b14610865578063980977e4146107b357806398b9b623146106975780639b8906ae146106795780639d76ea5814610650578063a277d5b114610632578063a87430ba146105d2578063ad5c613d14610418578063b2af127c1461035a578063b3daa6521461033d578063d3a2622914610313578063e086e5ec146102bc578063ea28edad146101f05763f2fde38b1461015e573861000f565b346101eb5760203660031901126101eb576004356001600160a01b038116908190036101eb5761018c610d4b565b80156101d557600080546001600160a01b03198116831782556001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3005b631e4fbdf760e01b600052600060045260246000fd5b600080fd5b346101eb5760003660031901126101eb57610209610d4b565b6002600654036102ab576002600755426008556000602061026760018060a01b03600a541661023d60035460045490610c6b565b60405163a9059cbb60e01b8152336004820152602481019190915293849283919082906044820190565b03925af1801561029f5761027757005b61001b9060203d602011610298575b6102908183610be6565b810190610d33565b503d610286565b6040513d6000823e3d90fd5b639d98b04b60e01b60005260046000fd5b346101eb5760003660031901126101eb576102d5610d4b565b600080808047335af13d1561030e573d6102ee81610c1e565b906102fc6040519283610be6565b8152600060203d92013e5b156101eb57005b610307565b346101eb5760003660031901126101eb57602061033560035460045490610c6b565b604051908152f35b346101eb5760003660031901126101eb57602060405161a8c08152f35b346101eb5760203660031901126101eb576004356001600160a01b038116908190036101eb57610388610d4b565b6040516370a0823160e01b815230600482015290602082602481845afa91821561029f576000926103e2575b5060405163a9059cbb60e01b8152336004820152602481019290925260209082908160008160448101610267565b91506020823d602011610410575b816103fd60209383610be6565b810103126101eb579051906102676103b4565b3d91506103f0565b60203660031901126101eb5760043567ffffffffffffffff81116101eb57366023820112156101eb5780600401359067ffffffffffffffff82116101eb5736602483830101116101eb576009541580156105c6575b6105b55761047d60055434610c78565b60009160009380610561575b5050600454926104998285610c8b565b938360011b948486046002148515171561054b57856104b791610c8b565b6003541061053a57826104dc6104d3610527956104fc94610c8b565b96600097610c8b565b60045533865260016020526104f685604088205492610c8b565b90610c8b565b3385526001602052604085205560018060a01b03169182845260016020526002604085200154610c8b565b9082526001602052600260408320015580f35b632d573a5560e01b60005260046000fd5b634e487b7160e01b600052601160045260246000fd5b809192945060246040519301833760029082019081528190036020019020546001600160a01b03169182610597575b8380610489565b9050600381028181046003148215171561054b576064900490610590565b633482502f60e01b60005260046000fd5b5060026006541461046d565b346101eb5760203660031901126101eb576004356001600160a01b038116908190036101eb576000526001602052608060406000208054906001810154906003600282015491015491604051938452602084015260408301526060820152f35b346101eb5760003660031901126101eb576020600454604051908152f35b346101eb5760003660031901126101eb57600a546040516001600160a01b039091168152602090f35b346101eb5760003660031901126101eb576020600654604051908152f35b346101eb5760403660031901126101eb5760043567ffffffffffffffff81116101eb576106c8903690600401610c3a565b9060243567ffffffffffffffff81116101eb576106ea83913690600401610c3a565b6106f5939193610d4b565b36829003601e19019060005b8481101561001b578181101561079d576001600160a01b03600582901b87810135918216918290036101eb57600090860135858112156107995786019081359167ffffffffffffffff8311610799576020019082360382136107965750906020600194939282604051938492833781016002815203019020906bffffffffffffffffffffffff60a01b82541617905501610701565b80fd5b5080fd5b634e487b7160e01b600052603260045260246000fd5b346101eb5760003660031901126101eb5760026007540361085457336000526001602052600060206102676107ee6002604085200154610c98565b33845260018352610806600360408620015482610c6b565b3380865260018552604080872060030193909355600a54925163a9059cbb60e01b8152600481019190915260248101919091529384926001600160a01b039092169183919082906044820190565b633f54562b60e11b60005260046000fd5b346101eb5760003660031901126101eb576000546040516001600160a01b039091168152602090f35b346101eb5760403660031901126101eb576024356108aa610d4b565b6009546109035760206000914260095560043560055580600355606460018060a01b03600a54169160405194859384926323b872dd60e01b845233600485015230602485015260448401525af1801561029f5761027757005b6319f4db0f60e31b60005260046000fd5b346101eb5760003660031901126101eb576020600954604051908152f35b346101eb5760003660031901126101eb5761094b610d4b565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101eb5760203660031901126101eb5760043567ffffffffffffffff81116101eb57366023820112156101eb5780600401356109c781610c1e565b906109d56040519283610be6565b80825236602482850101116101eb57602081600092602483960183860137830101526040519080519060005b828110610a2c575050600290820190815281900382019020546040516001600160a01b039091168152f35b818101850151848201528401610a01565b346101eb5760003660031901126101eb576002600754036108545733600052600160205260006020610267610a756040842054610c98565b33845260018352610a8d600160408620015482610c6b565b338086526001808652604080882090910193909355600a54925163a9059cbb60e01b8152600481019190915260248101919091529384926001600160a01b039092169183919082906044820190565b346101eb5760003660031901126101eb57602060405160038152f35b346101eb5760003660031901126101eb57610b11610d4b565b6002600655005b346101eb5760003660031901126101eb576020600354604051908152f35b346101eb5760003660031901126101eb576020600754604051908152f35b346101eb5760003660031901126101eb576020600854604051908152f35b346101eb5760203660031901126101eb576020610335600435610c98565b346101eb5760003660031901126101eb576020600554604051908152f35b346101eb5760003660031901126101eb576020604051621275008152f35b346101eb5760003660031901126101eb5780604b60209252f35b90601f8019910116810190811067ffffffffffffffff821117610c0857604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff8111610c0857601f01601f191660200190565b9181601f840112156101eb5782359167ffffffffffffffff83116101eb576020808501948460051b0101116101eb57565b9190820391821161054b57565b8181029291811591840414171561054b57565b9190820180921161054b57565b6008548015610d2c57610cab8142610c6b565b90604b830290831591848104604b1483171561054b57606490049261a8c0811015610cd857505050905090565b62131dc011610ce75750505090565b61a8c0810180911161054b57610cfd9042610c6b565b9060198402938404601914171561054b57610d2262127500916064610d299504610c78565b0490610c8b565b90565b5050600090565b908160209103126101eb575180151581036101eb5790565b6000546001600160a01b03163303610d5f57565b63118cdaa760e01b6000523360045260246000fdfea26469706673582212208daf5dd468d7fd4abb2e9ae235dcb015a95248e6f0ec28228036b3458a94cab564736f6c634300081a0033

Verified Source Code Full Match

Compiler: v0.8.26+commit.8a97fa7a EVM: paris Optimization: Yes (200 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * 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);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// 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;
    }
}
PresaleV2.sol 174 lines
// SPDX-License-Identifier: None

pragma solidity ^0.8.24;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract PresaleV2 is Ownable {

    struct UserInfo {
        uint256 tokensPurchased;
        uint256 purchasedAmountClaimed;
        uint256 tokensReferred;
        uint256 referredAmountClaimed;
    }

    mapping(address => UserInfo) public users;
    mapping(bytes => address) public referrers;

    uint256 public totalTokensSupplied;
    uint256 public totalTokensPurchased;
    uint256 public tokenRatio;

    uint256 public constant VESTING_PERIOD = 14 days;
    uint256 public constant CLIFF_DURATION = 12 hours;
    uint256 public constant INITIAL_UNLOCK_PERCENT = 75;

    uint256 public constant BONUS = 3; // 3% 
    uint256 private constant PERCENT = 100;

    uint256 private constant FALSE = 1;
    uint256 private constant TRUE = 2;

    uint256 public saleEnded = FALSE;
    uint256 public claimEnabled = FALSE;
    
    uint256 public claimTime;
    uint256 public launchTime;

    IERC20 public tokenAddress;

    error ExceedsSupply();
    error SaleNotEnded();
    error InvalidSaleState();
    error NotEnabled();
    error AlreadyLaunched();

    constructor(address _tokenAddress) Ownable(msg.sender) {
        tokenAddress = IERC20(_tokenAddress);
    }

    receive() external payable {}

    function launch(uint256 ratio, uint256 suppliedTokens) external onlyOwner {
        if (launchTime != 0) { 
            revert AlreadyLaunched();
        }
        launchTime = block.timestamp;
        tokenRatio = ratio;
        totalTokensSupplied = suppliedTokens;
        tokenAddress.transferFrom(msg.sender, address(this), suppliedTokens);
    }

    function endSale() external onlyOwner {
        saleEnded = TRUE;
    }

    function enableClaims() external onlyOwner {
        if (saleEnded != TRUE) {
            revert SaleNotEnded();
        }
        claimEnabled = TRUE;
        claimTime = block.timestamp;
        // Transfers extra tokens back to the owner
        tokenAddress.transfer(msg.sender, totalTokensSupplied - totalTokensPurchased);
    }

    function purchase(bytes calldata referral) external payable {
        if (launchTime == 0 || saleEnded == TRUE) { 
            revert InvalidSaleState();
        }

        uint256 tokenAmountPreBonus = msg.value * tokenRatio; // tokens based on ETH amount alone

        uint256 bonusAmount;
        address referrer;
        if (referral.length != 0) {
            // if the user supplied referral data check the referral address
            referrer = referrers[referral]; 
            if (referrer != address(0)) {
                // calculate the bonus if valid referral code
                bonusAmount = tokenAmountPreBonus * BONUS / PERCENT;
            }
        }
        
        if (totalTokensPurchased + tokenAmountPreBonus + (bonusAmount * 2) > totalTokensSupplied) {
            revert ExceedsSupply();
        }        

        totalTokensPurchased = totalTokensPurchased + tokenAmountPreBonus + (bonusAmount * 2);
        users[msg.sender].tokensPurchased = users[msg.sender].tokensPurchased + (tokenAmountPreBonus + bonusAmount);
        users[referrer].tokensReferred = users[referrer].tokensReferred + bonusAmount;
    }

    function claimTokensReferred() external {
        if (claimEnabled != TRUE) {
            revert NotEnabled();
        }
        // Claimable tokens vest over time 
        uint256 vested = vestedAmount(users[msg.sender].tokensReferred);
        // Calculate claimable, update claimed amount, send user their tokens
        uint256 claimable = vested - users[msg.sender].referredAmountClaimed;
        users[msg.sender].referredAmountClaimed = vested;
        tokenAddress.transfer(msg.sender, claimable);
    }

    // Allows the users to claim tokens once enabled
    function claim() external {
        if (claimEnabled != TRUE) {
            revert NotEnabled();
        }
        // Claimable tokens vest over time 
        uint256 vested = vestedAmount(users[msg.sender].tokensPurchased);
        // Calculate claimable, update claimed amount, send user their tokens
        uint256 claimable = vested - users[msg.sender].purchasedAmountClaimed;
        users[msg.sender].purchasedAmountClaimed = vested;
        tokenAddress.transfer(msg.sender, claimable);
    }

    function setReferrers(bytes[] calldata codes, address[] calldata addresses) external onlyOwner {
        for(uint256 i; i < codes.length; ) {
            referrers[codes[i]] = addresses[i];
            unchecked {
                ++i;
            }
        }
    }

    // Withdraws all ETH from the contract
    function withdrawETH() external onlyOwner {
        (bool success, ) = msg.sender.call{value: address(this).balance}(""); 
        require(success);
    }
   
    // Withdraws all of a specified token to a contract - should only be used on the presale token in case of emergency
    function emergencyWithdrawTokens(address token) external onlyOwner {
        IERC20(token).transfer(msg.sender, IERC20(token).balanceOf(address(this)));
    }

    function tokensRemainingToPurchase() external view returns (uint256){
        return totalTokensSupplied - totalTokensPurchased;
    }

    // Calculates the amount of vested tokens from the time claiming was enabled
    function vestedAmount(uint256 totalPurchased) public view returns (uint256) {
        if (claimTime == 0) {
            return 0;
        }
        uint256 elapsedTime = block.timestamp - claimTime;
        uint256 initalUnlockAmount = (totalPurchased * INITIAL_UNLOCK_PERCENT) / PERCENT;
        if (elapsedTime < CLIFF_DURATION) {
            // Before 12 hours, only the initial 75% is available
            return initalUnlockAmount;
        } else if (elapsedTime >= CLIFF_DURATION + VESTING_PERIOD) {
            // After the vesting period, 100% is vested
            return totalPurchased;
        } else { // calculate vested amount 
            elapsedTime = block.timestamp - (claimTime + CLIFF_DURATION); // vesting starts from cliff duration
            uint256 nonInitialAmount = (totalPurchased * (PERCENT - INITIAL_UNLOCK_PERCENT)) / PERCENT; // amount that vests after initial unlock
            uint256 currVestedAmount = (nonInitialAmount * elapsedTime) / VESTING_PERIOD; // amount of non-initial that has vested
            return initalUnlockAmount + currVestedAmount; // initial unlock + vested amount 
        }
    }
}

Read Contract

BONUS 0x4b8624c4 → uint256
CLIFF_DURATION 0xb3daa652 → uint256
INITIAL_UNLOCK_PERCENT 0x016312f9 → uint256
VESTING_PERIOD 0x0197d972 → uint256
claimEnabled 0x2866ed21 → uint256
claimTime 0x27b3bf11 → uint256
launchTime 0x790ca413 → uint256
owner 0x8da5cb5b → address
referrers 0x667eeee5 → address
saleEnded 0x9b8906ae → uint256
tokenAddress 0x9d76ea58 → address
tokenRatio 0x06f837d3 → uint256
tokensRemainingToPurchase 0xd3a26229 → uint256
totalTokensPurchased 0xa277d5b1 → uint256
totalTokensSupplied 0x37517896 → uint256
users 0xa87430ba → uint256, uint256, uint256, uint256
vestedAmount 0x1bfce853 → uint256

Write Contract 11 functions

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

claim 0x4e71d92d
No parameters
claimTokensReferred 0x980977e4
No parameters
emergencyWithdrawTokens 0xb2af127c
address token
enableClaims 0xea28edad
No parameters
endSale 0x380d831b
No parameters
launch 0x82760cd2
uint256 ratio
uint256 suppliedTokens
purchase 0xad5c613d
bytes referral
renounceOwnership 0x715018a6
No parameters
setReferrers 0x98b9b623
bytes[] codes
address[] addresses
transferOwnership 0xf2fde38b
address newOwner
withdrawETH 0xe086e5ec
No parameters

Recent Transactions

No transactions found for this address