Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xCBb7d457f8462701FdFE4651c703EDd8815d5E14
Balance 0 ETH
Nonce 1
Code Size 2742 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

2742 bytes
0x6080604052600436106100c25760003560e01c80638456cb591161007f578063a98ad46c11610059578063a98ad46c146101d3578063f1a49354146101f3578063f2fde38b14610213578063fe475f6b1461023357600080fd5b80638456cb591461018d5780638da5cb5b146101a25780639e5939f3146101c057600080fd5b8063259cf89c146100c75780633371e2d9146100dc5780633f4ba83a146100fc5780635c975abb14610111578063633423be14610140578063715018a614610178575b600080fd5b6100da6100d53660046109e7565b610253565b005b3480156100e857600080fd5b506100da6100f7366004610a1a565b61035e565b34801561010857600080fd5b506100da6104c8565b34801561011d57600080fd5b50600054600160a01b900460ff1660405190151581526020015b60405180910390f35b34801561014c57600080fd5b50600354610160906001600160a01b031681565b6040516001600160a01b039091168152602001610137565b34801561018457600080fd5b506100da6104e2565b34801561019957600080fd5b506100da6104f4565b3480156101ae57600080fd5b506000546001600160a01b0316610160565b6100da6101ce366004610a1a565b61050c565b3480156101df57600080fd5b50600254610160906001600160a01b031681565b3480156101ff57600080fd5b506100da61020e366004610a3c565b610648565b34801561021f57600080fd5b506100da61022e366004610a3c565b6106c8565b34801561023f57600080fd5b506100da61024e366004610a3c565b610706565b61025b6107c0565b61026361080d565b6003546040516000916001600160a01b03169034908381818185875af1925050503d80600081146102b0576040519150601f19603f3d011682016040523d82523d6000602084013e6102b5565b606091505b505090508061030b5760405162461bcd60e51b815260206004820152601b60248201527f46756e6473207472616e7366657220756e7375636365737366756c000000000060448201526064015b60405180910390fd5b60408051848152602081018490526001600160a01b038616917f446543763deeeceb62d2ee649ed39292c7d2c825ed895128a5e62fa53c0d80f0910160405180910390a25061035960018055565b505050565b6103666107c0565b61036e61080d565b600081116103be5760405162461bcd60e51b815260206004820181905260248201527f416d6f756e74206d7573742062652067726561746572207468616e207a65726f6044820152606401610302565b6002546003546040516323b872dd60e01b81523360048201526001600160a01b039182166024820152604481018490529116906323b872dd906064016020604051808303816000875af1158015610419573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043d9190610a5e565b6104805760405162461bcd60e51b81526020600482015260146024820152731554d115081d1c985b9cd9995c8819985a5b195960621b6044820152606401610302565b604080518381526020810183905233917f8afb4ead3a1cd0a4b63dca5c82b7ee38c2ca753157815f47783c6575f2b63290910160405180910390a26104c460018055565b5050565b6104d0610866565b6104d86108b6565b6104e06108e3565b565b6104ea6108b6565b6104e06000610938565b6104fc6107c0565b6105046108b6565b6104e0610988565b6105146107c0565b61051c61080d565b8034146105605760405162461bcd60e51b815260206004820152601260248201527108aa89040ecc2d8eaca40dad2e6dac2e8c6d60731b6044820152606401610302565b6003546040516000916001600160a01b03169034908381818185875af1925050503d80600081146105ad576040519150601f19603f3d011682016040523d82523d6000602084013e6105b2565b606091505b50509050806106035760405162461bcd60e51b815260206004820152601960248201527f455448207472616e7366657220756e7375636365737366756c000000000000006044820152606401610302565b604080518481526020810184905233917f124f2a7008b4e373d609a73600e083a42ab0eb64fc9a1532638b4ecb26aebc19910160405180910390a2506104c460018055565b6106506108b6565b6001600160a01b0381166106a65760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206e65772055534454206164647265737300000000000000006044820152606401610302565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6106d06108b6565b6001600160a01b0381166106fa57604051631e4fbdf760e01b815260006004820152602401610302565b61070381610938565b50565b61070e6108b6565b6001600160a01b0381166107645760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964206e6577207061796d656e74206164647265737300000000006044820152606401610302565b6003546040516001600160a01b038084169216907fb3d3f832f05d764f8934189cba7879e2dd829dd3f92749ec959339fd5cd8b0be90600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b600054600160a01b900460ff16156104e05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610302565b60026001540361085f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610302565b6002600155565b600054600160a01b900460ff166104e05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610302565b6000546001600160a01b031633146104e05760405163118cdaa760e01b8152336004820152602401610302565b6108eb610866565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6109906107c0565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861091b3390565b80356001600160a01b03811681146109e257600080fd5b919050565b6000806000606084860312156109fc57600080fd5b610a05846109cb565b95602085013595506040909401359392505050565b60008060408385031215610a2d57600080fd5b50508035926020909101359150565b600060208284031215610a4e57600080fd5b610a57826109cb565b9392505050565b600060208284031215610a7057600080fd5b81518015158114610a5757600080fdfea26469706673582212208e9791df86c36cf050ab54b2f3246b6b9a462e831d280ff3683e6cd641514d2664736f6c634300081c0033

Verified Source Code Partial Match

Compiler: v0.8.28+commit.7893614a EVM: paris Optimization: Yes (200 runs)
PreSalePayment.sol 481 lines
//SPDX-License-Identifier: MIT

// OpenZeppelin Contracts (last updated v5.0.0) (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;
    }
}

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


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;


/**
 * @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: @openzeppelin/contracts/security/Pausable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;


/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

// File: @openzeppelin/contracts/security/ReentrancyGuard.sol


// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// 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);
}

// File: contracts/ERC20/payment.sol

contract PreSalePayment is Ownable, Pausable, ReentrancyGuard {
 
    IERC20 public usdtToken; // USDT token interface
    address public paymentAddress; // Payment address for receiving funds

    // Events for logging purchases and updates
    event PurchasedWithNative(address indexed user, uint256 numOfTokens, uint256 price);
    event PurchasedWithUSDT(address indexed user, uint256 numOfTokens, uint256 price);
    event PurchasedWithWert(address indexed user, uint256 numOfTokens, uint256 price);
    event PaymentAddressUpdated(address indexed previousAddress, address indexed newAddress);

    constructor( address _usdtToken, address _paymentAddress) Ownable(msg.sender) {
        require(_usdtToken != address(0), "Invalid USDT address");
        require(_paymentAddress != address(0), "Invalid payment address");
        
        usdtToken = IERC20(_usdtToken);
        paymentAddress = _paymentAddress;
    }
    function buyTokensWert(address user, uint256 numOfTokens, uint256 price)
        external
        payable
        whenNotPaused
        nonReentrant
    {
        (bool sent, ) = payable(paymentAddress).call{value: msg.value}("");
        require(sent, "Funds transfer unsuccessful");

        emit PurchasedWithWert(user, numOfTokens, price);
    }

    // Buy tokens using ETH
    function buyTokensWithNative(uint256 numOfTokens, uint256 value)
        external
        payable
        whenNotPaused
        nonReentrant
    {
        require(msg.value == value, "ETH value mismatch");
        (bool sent, ) = payable(paymentAddress).call{value: msg.value}("");
        require(sent, "ETH transfer unsuccessful");

        emit PurchasedWithNative(msg.sender, numOfTokens, value);
    }

    // Buy tokens using USDT
    function buyTokensWithUSDT(uint256 numOfTokens, uint256 value)
        external
        whenNotPaused
        nonReentrant
    {
        require(value > 0, "Amount must be greater than zero");
        require(
            usdtToken.transferFrom(msg.sender, paymentAddress, value),
            "USDT transfer failed"
        );

        emit PurchasedWithUSDT(msg.sender, numOfTokens, value);
    }

    // Update payment address
    function updatePaymentAddress(address newPaymentAddress) external onlyOwner {
        require(newPaymentAddress != address(0), "Invalid new payment address");
        emit PaymentAddressUpdated(paymentAddress, newPaymentAddress);
        paymentAddress = newPaymentAddress;
    }

    // Change USDT token address
    function changeUSDTTokenAddress(address newTokenAddress) external onlyOwner {
        require(newTokenAddress != address(0), "Invalid new USDT address");
        usdtToken = IERC20(newTokenAddress);
    }

    // Pause the contract
    function pause() external whenNotPaused onlyOwner {
        _pause();
    }

    // Unpause the contract
    function unpause() external whenPaused onlyOwner {
        _unpause();
    }
}

Read Contract

owner 0x8da5cb5b → address
paused 0x5c975abb → bool
paymentAddress 0x633423be → address
usdtToken 0xa98ad46c → address

Write Contract 9 functions

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

buyTokensWert 0x259cf89c
address user
uint256 numOfTokens
uint256 price
buyTokensWithNative 0x9e5939f3
uint256 numOfTokens
uint256 value
buyTokensWithUSDT 0x3371e2d9
uint256 numOfTokens
uint256 value
changeUSDTTokenAddress 0xf1a49354
address newTokenAddress
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
updatePaymentAddress 0xfe475f6b
address newPaymentAddress

Recent Transactions

No transactions found for this address