ETH Price: $3,322.20 (-2.71%)

Contract

0x8AC905E1C03190bc75d708A9dE5Fc5FF8008dd9F
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040209562922024-10-13 11:15:5944 days ago1728818159IN
 Create: XYZPresale
0 ETH0.015902429.10989857

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
XYZPresale

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
paris EvmVersion
File 1 of 8 : XYZPresale.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

import './IXYZPresale.sol';
import '@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol';
import '@uniswap/lib/contracts/libraries/TransferHelper.sol';

interface IERC20 {
    function decimals() external view returns (uint8);
}

// @notice A contract for handling the XYZ token presale, supporting payments in native coins and USD ERC20 tokens.
contract XYZPresale is PausableUpgradeable, OwnableUpgradeable, IXYZPresale {
    uint256 constant XYZ_BASE = 1e18;
    uint256 constant USD_BASE = 1e6;
    uint256 constant NATIVE_COIN_PRICE_TO_USD_CONVERSION_FACTOR = 1e20; // 1e18 * 1e8 / 1e6

    AggregatorV3Interface public nativeCoinPriceFeed;
    mapping(address => uint256) public paymentTokensBases;

    uint128 public xyzPrice;

    uint128 public totalCollectedUSD;
    address public treasury;

    mapping(address => uint256) internal _balances;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @param nativeCoinPriceFeed_ Price feed for the native currency.
     * @param paymentTokens_ Array of accepted USD ERC20 tokens for payment.
     * @param xyzPrice_ Initial price of 1 XYZ token in USD, scaled by 1e6.
     * @param treasury_ Address of the treasury to receive payments.
     * @param owner_ The contract owner address.
     */
    function initialize(
        AggregatorV3Interface nativeCoinPriceFeed_,
        address[] calldata paymentTokens_,
        uint128 xyzPrice_,
        address treasury_,
        address owner_
    ) external initializer {
        if (xyzPrice_ == 0) revert InvalidPrice();

        __Ownable_init(owner_);
        _pause();

        nativeCoinPriceFeed = nativeCoinPriceFeed_;
        xyzPrice = xyzPrice_;
        treasury = treasury_;

        for (uint256 i = 0; i < paymentTokens_.length; i++) {
            _addPaymentToken(paymentTokens_[i]);
        }
    }

    /**
     * @notice Owner: Pauses the presale, preventing purchases.
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @notice Owner: Unpauses the presale, allowing purchases.
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @notice Owner: Credits a recipient with tokens from an external purchase.
     * @param recipient Address receiving the purchased XYZ tokens.
     * @param purchasedXYZ Amount of XYZ tokens purchased.
     * @param paidUSD The amount of the USD used for the purchase, scaled by 1e6;
     * @param paymentDetails Additional details of the payment.
     */
    function creditExternalPurchase(
        address recipient,
        uint256 purchasedXYZ,
        uint128 paidUSD,
        bytes[] calldata paymentDetails
    ) external onlyOwner {
        _balances[recipient] += purchasedXYZ;
        totalCollectedUSD += paidUSD;

        emit ExternallyPurchased(recipient, purchasedXYZ, paidUSD, paymentDetails);
    }

    /**
     * @notice Owner: Updates the status of an ERC20 token as a valid payment method.
     * @param token The token address to update.
     * @param isPaymentToken Whether the token is accepted for payment.
     */
    function updateTokenStatus(address token, bool isPaymentToken) external onlyOwner {
        if (bool(paymentTokensBases[token] != 0) == isPaymentToken) revert NoChange();

        if (isPaymentToken) {
            _addPaymentToken(token);
        } else {
            paymentTokensBases[token] = 0;
        }

        emit TokenStatusUpdated(token, isPaymentToken);
    }

    /**
     * @notice Owner: Updates the treasury address where payments are sent.
     * @param newTreasury The new treasury address.
     */
    function updateTreasuryAddress(address newTreasury) external onlyOwner {
        if (treasury == newTreasury) revert NoChange();

        treasury = newTreasury;

        emit TreasuryAddressUpdated(newTreasury);
    }

    /**
     * @notice Owner: Updates the price of the XYZ token.
     * @param newPrice The new price for XYZ in USD, scaled by 1e6.
     */
    function updateXYZPrice(uint128 newPrice) external onlyOwner {
        if (newPrice == xyzPrice) revert NoChange();
        if (newPrice == 0) revert InvalidPrice();

        xyzPrice = newPrice;

        emit XYZPriceUpdated(newPrice);
    }

    /**
     * @notice Purchase XYZ tokens using native currency.
     * @param recipient The address receiving the purchased XYZ tokens.
     */
    function purchaseWithNativeCoin(address recipient) external payable whenNotPaused {
        TransferHelper.safeTransferETH(treasury, msg.value);

        (, int256 nativeCoinPrice, , , ) = nativeCoinPriceFeed.latestRoundData();
        uint256 paidUSD = (msg.value * uint256(nativeCoinPrice)) / NATIVE_COIN_PRICE_TO_USD_CONVERSION_FACTOR;
        uint256 purchasedXYZ = _processPurchase(recipient, paidUSD);

        emit Purchased(msg.sender, recipient, address(0), msg.value, purchasedXYZ, paidUSD);
    }

    /**
     * @notice Purchase XYZ tokens using an ERC20 token.
     * @param recipient The address receiving the purchased XYZ tokens.
     * @param paymentToken The ERC20 token used for payment.
     * @param paymentAmount The amount of the token used for the purchase.
     */
    function purchaseWithToken(address recipient, address paymentToken, uint256 paymentAmount) external whenNotPaused {
        uint256 paymentTokenBase = paymentTokensBases[paymentToken];
        if (paymentTokenBase == 0) revert InvalidPaymentToken();

        TransferHelper.safeTransferFrom(paymentToken, msg.sender, treasury, paymentAmount);

        uint256 paidUSD = (paymentAmount * USD_BASE) / paymentTokenBase;
        uint256 purchasedXYZ = _processPurchase(recipient, paidUSD);

        emit Purchased(msg.sender, recipient, paymentToken, paymentAmount, purchasedXYZ, paidUSD);
    }

    /**
     * @notice Returns the balance of XYZ tokens for `account`.
     */
    function balanceOf(address account) external view returns (uint256) {
        return _balances[account];
    }

    /**
     * @notice Returns the current price of 1 XYZ token in native currency.
     * @return The price of 1 XYZ token in native coin.
     */
    function xyzPriceInNativeCoin() external view returns (uint256) {
        (, int256 nativeCoinPrice, , , ) = nativeCoinPriceFeed.latestRoundData();
        return (xyzPrice * NATIVE_COIN_PRICE_TO_USD_CONVERSION_FACTOR) / uint256(nativeCoinPrice);
    }

    /**
     * @notice Adds an ERC20 token to the list of accepted payment tokens.
     * @param paymentToken The ERC20 token to add.
     */
    function _addPaymentToken(address paymentToken) internal {
        uint256 paymentTokenDecimals = IERC20(paymentToken).decimals();
        if (paymentTokenDecimals == 0) revert ZeroDecimalsPaymentToken();

        paymentTokensBases[paymentToken] = 10 ** paymentTokenDecimals;
    }

    /**
     * @notice Processes the purchase and calculates the amount of XYZ tokens to credit.
     * @param recipient The address receiving the purchased tokens.
     * @param paidUSD The amount of USD used for the purchase, scaled by 1e6.
     * @return The amount of XYZ tokens credited to the recipient.
     */
    function _processPurchase(address recipient, uint256 paidUSD) internal returns (uint256) {
        uint256 purchasedXYZ = (paidUSD * XYZ_BASE) / xyzPrice;

        if (purchasedXYZ == 0) revert InsufficientPurchase();

        totalCollectedUSD += uint128(paidUSD);
        _balances[recipient] += purchasedXYZ;

        return purchasedXYZ;
    }
}

File 2 of 8 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(
    uint80 _roundId
  ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

  function latestRoundData()
    external
    view
    returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

File 3 of 8 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @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.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        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) {
        OwnableStorage storage $ = _getOwnableStorage();
        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 {
        OwnableStorage storage $ = _getOwnableStorage();
        address oldOwner = $._owner;
        $._owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 4 of 8 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 5 of 8 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    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 6 of 8 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

    function _getPausableStorage() private pure returns (PausableStorage storage $) {
        assembly {
            $.slot := PausableStorageLocation
        }
    }

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._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) {
        PausableStorage storage $ = _getPausableStorage();
        return $._paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

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

File 7 of 8 : TransferHelper.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.6.0;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeApprove: approve failed'
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeTransfer: transfer failed'
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::transferFrom: transferFrom failed'
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
    }
}

File 8 of 8 : IXYZPresale.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

interface IXYZPresale {
    event ExternallyPurchased(address indexed recipient, uint256 purchasedXYZ, uint128 paidUSD, bytes[] paymentDetails);
    event Purchased(
        address indexed purchaseer,
        address indexed recipient,
        address indexed paymentToken,
        uint256 paymentAmount,
        uint256 purchasedXYZ,
        uint256 paidUSD
    );
    event TokenStatusUpdated(address token, bool isPaymentToken);
    event TreasuryAddressUpdated(address newTreasury);
    event XYZPriceUpdated(uint256 newPrice);

    error InsufficientPurchase();
    error InvalidPaymentToken();
    error InvalidPrice();
    error NoChange();
    error ZeroDecimalsPaymentToken();

    function pause() external;
    function unpause() external;

    function creditExternalPurchase(
        address recipient,
        uint256 purchasedXYZ,
        uint128 paidUSD,
        bytes[] calldata paymentDetails
    ) external;

    function updateTokenStatus(address token, bool isPaymentToken) external;

    function updateTreasuryAddress(address newTreasury) external;

    function updateXYZPrice(uint128 newPrice) external;

    function purchaseWithNativeCoin(address recipient) external payable;

    function purchaseWithToken(address recipient, address paymentToken, uint256 paymentAmount) external;

    function balanceOf(address account) external view returns (uint256);

    function xyzPriceInNativeCoin() external view returns (uint256);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InsufficientPurchase","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidPaymentToken","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"NoChange","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ZeroDecimalsPaymentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"purchasedXYZ","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"paidUSD","type":"uint128"},{"indexed":false,"internalType":"bytes[]","name":"paymentDetails","type":"bytes[]"}],"name":"ExternallyPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"purchaseer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"address","name":"paymentToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"purchasedXYZ","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paidUSD","type":"uint256"}],"name":"Purchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"isPaymentToken","type":"bool"}],"name":"TokenStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"XYZPriceUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"purchasedXYZ","type":"uint256"},{"internalType":"uint128","name":"paidUSD","type":"uint128"},{"internalType":"bytes[]","name":"paymentDetails","type":"bytes[]"}],"name":"creditExternalPurchase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract AggregatorV3Interface","name":"nativeCoinPriceFeed_","type":"address"},{"internalType":"address[]","name":"paymentTokens_","type":"address[]"},{"internalType":"uint128","name":"xyzPrice_","type":"uint128"},{"internalType":"address","name":"treasury_","type":"address"},{"internalType":"address","name":"owner_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nativeCoinPriceFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"paymentTokensBases","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"purchaseWithNativeCoin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"name":"purchaseWithToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalCollectedUSD","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"isPaymentToken","type":"bool"}],"name":"updateTokenStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasury","type":"address"}],"name":"updateTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"newPrice","type":"uint128"}],"name":"updateXYZPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xyzPrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xyzPriceInNativeCoin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611e4a806100df6000396000f3fe60806040526004361061015f5760003560e01c806370a08231116100c0578063900ed17811610074578063dc71752d11610059578063dc71752d14610445578063f2fde38b14610482578063f58f8171146104a257600080fd5b8063900ed17814610410578063d317a83c1461043057600080fd5b8063841e4561116100a5578063841e4561146103915780638456cb59146103b15780638da5cb5b146103c657600080fd5b806370a0823114610339578063715018a61461037c57600080fd5b80633f4ba83a11610117578063572d0640116100fc578063572d0640146102805780635c975abb146102ca57806361d027b31461030c57600080fd5b80633f4ba83a14610219578063480a58ee1461022e57600080fd5b80632458a95f116101485780632458a95f146101c657806339f91003146101e65780633f34439f146101f957600080fd5b8063080e6398146101645780632430e9d614610186575b600080fd5b34801561017057600080fd5b5061018461017f3660046117a3565b6104c2565b005b34801561019257600080fd5b506101b36101a13660046117e7565b60016020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156101d257600080fd5b506101846101e1366004611850565b6105dc565b6101846101f43660046117e7565b6106ea565b34801561020557600080fd5b506101846102143660046118c1565b610844565b34801561022557600080fd5b50610184610966565b34801561023a57600080fd5b5060005461025b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bd565b34801561028c57600080fd5b506002546102a9906fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff90911681526020016101bd565b3480156102d657600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1660405190151581526020016101bd565b34801561031857600080fd5b5060035461025b9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561034557600080fd5b506101b36103543660046117e7565b73ffffffffffffffffffffffffffffffffffffffff1660009081526004602052604090205490565b34801561038857600080fd5b50610184610978565b34801561039d57600080fd5b506101846103ac3660046117e7565b61098a565b3480156103bd57600080fd5b50610184610a59565b3480156103d257600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1661025b565b34801561041c57600080fd5b5061018461042b366004611910565b610a69565b34801561043c57600080fd5b506101b3610b63565b34801561045157600080fd5b506002546102a99070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b34801561048e57600080fd5b5061018461049d3660046117e7565b610c39565b3480156104ae57600080fd5b506101846104bd366004611949565b610ca2565b6104ca610f4a565b6002546fffffffffffffffffffffffffffffffff9081169082160361051b576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806fffffffffffffffffffffffffffffffff16600003610566576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff83169081179091556040519081527fd5b6bdd60da1484326fbe658be1b26f9c10be7cb231bcca7ae05c1aa1d1b0990906020015b60405180910390a150565b6105e4610f4a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526004602052604081208054869290610619908490611a05565b90915550506002805484919060109061065990849070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16611a18565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508473ffffffffffffffffffffffffffffffffffffffff167fbaf9add78373f0cac93f4be4f43865565b55440f8d45a3f8a94d884c6a51fc66858585856040516106db9493929190611a91565b60405180910390a25050505050565b6106f2610fd8565b6003546107159073ffffffffffffffffffffffffffffffffffffffff1634611034565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610783573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a79190611ba8565b505050915050600068056bc75e2d6310000082346107c59190611bf8565b6107cf9190611c0f565b905060006107dd8483611143565b604080513481526020810183905290810184905290915060009073ffffffffffffffffffffffffffffffffffffffff86169033907f0ca214f8a19535023cdee0ea74c48997966a87ed490c81c28c235d8c93c8d19a9060600160405180910390a450505050565b61084c610fd8565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040812054908190036108ac576040517f56e7ec5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546108d3908490339073ffffffffffffffffffffffffffffffffffffffff1685611276565b6000816108e3620f424085611bf8565b6108ed9190611c0f565b905060006108fb8683611143565b604080518681526020810183905290810184905290915073ffffffffffffffffffffffffffffffffffffffff808716919088169033907f0ca214f8a19535023cdee0ea74c48997966a87ed490c81c28c235d8c93c8d19a9060600160405180910390a4505050505050565b61096e610f4a565b610976611415565b565b610980610f4a565b61097660006114ac565b610992610f4a565b60035473ffffffffffffffffffffffffffffffffffffffff8083169116036109e6576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fb6a5e89655cf506139085f051af608195ed056f8dc550b180a1c38d401e2b6c4906020016105d1565b610a61610f4a565b610976611542565b610a71610f4a565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205481151590151503610ad4576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610ae857610ae3826115bb565b610b0f565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260408120555b6040805173ffffffffffffffffffffffffffffffffffffffff8416815282151560208201527fc2af510a9d71a987e12298c8d681a18ee686d181e6fb0bd4166cc01cd7eed4b3910160405180910390a15050565b60008054604080517ffeaf968c0000000000000000000000000000000000000000000000000000000081529051839273ffffffffffffffffffffffffffffffffffffffff169163feaf968c9160048083019260a09291908290030181865afa158015610bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf79190611ba8565b5050600254919350839250610c299168056bc75e2d6310000091506fffffffffffffffffffffffffffffffff16611bf8565b610c339190611c0f565b91505090565b610c41610f4a565b73ffffffffffffffffffffffffffffffffffffffff8116610c96576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610c9f816114ac565b50565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610ced5750825b905060008267ffffffffffffffff166001148015610d0a5750303b155b905081158015610d18575080155b15610d4f576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610db05784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b876fffffffffffffffffffffffffffffffff16600003610dfb576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e04866116a3565b610e0c611542565b6000805473ffffffffffffffffffffffffffffffffffffffff808e167fffffffffffffffffffffffff0000000000000000000000000000000000000000928316178355600280546fffffffffffffffffffffffffffffffff8d167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090911617905560038054918b16919092161790555b89811015610edb57610ed38b8b83818110610eb957610eb9611c4a565b9050602002016020810190610ece91906117e7565b6115bb565b600101610e9c565b508315610f3d5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b33610f897f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610976576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610c8d565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615610976576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff841690839060405161106b9190611c79565b60006040518083038185875af1925050503d80600081146110a8576040519150601f19603f3d011682016040523d82523d6000602084013e6110ad565b606091505b505090508061113e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527f20455448207472616e73666572206661696c65640000000000000000000000006064820152608401610c8d565b505050565b60025460009081906fffffffffffffffffffffffffffffffff1661116f670de0b6b3a764000085611bf8565b6111799190611c0f565b9050806000036111b5576040517fda2fc5e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600260108282829054906101000a90046fffffffffffffffffffffffffffffffff166111e29190611a18565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555080600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112679190611a05565b90915550909150505b92915050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905291516000928392908816916113159190611c79565b6000604051808303816000865af19150503d8060008114611352576040519150601f19603f3d011682016040523d82523d6000602084013e611357565b606091505b50915091508180156113815750805115806113815750808060200190518101906113819190611ca8565b61140d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c65640000000000000000000000000000006064820152608401610c8d565b505050505050565b61141d6116b4565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016105d1565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b61154a610fd8565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611487565b60008173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162c9190611cc5565b60ff1690508060000361166b576040517f2e99569000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61167681600a611e08565b73ffffffffffffffffffffffffffffffffffffffff90921660009081526001602052604090209190915550565b6116ab61170f565b610c9f81611776565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610976576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610976576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c4161170f565b80356fffffffffffffffffffffffffffffffff8116811461179e57600080fd5b919050565b6000602082840312156117b557600080fd5b6117be8261177e565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610c9f57600080fd5b6000602082840312156117f957600080fd5b81356117be816117c5565b60008083601f84011261181657600080fd5b50813567ffffffffffffffff81111561182e57600080fd5b6020830191508360208260051b850101111561184957600080fd5b9250929050565b60008060008060006080868803121561186857600080fd5b8535611873816117c5565b9450602086013593506118886040870161177e565b9250606086013567ffffffffffffffff8111156118a457600080fd5b6118b088828901611804565b969995985093965092949392505050565b6000806000606084860312156118d657600080fd5b83356118e1816117c5565b925060208401356118f1816117c5565b929592945050506040919091013590565b8015158114610c9f57600080fd5b6000806040838503121561192357600080fd5b823561192e816117c5565b9150602083013561193e81611902565b809150509250929050565b60008060008060008060a0878903121561196257600080fd5b863561196d816117c5565b9550602087013567ffffffffffffffff81111561198957600080fd5b61199589828a01611804565b90965094506119a890506040880161177e565b925060608701356119b8816117c5565b915060808701356119c8816117c5565b809150509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115611270576112706119d6565b6fffffffffffffffffffffffffffffffff818116838216019080821115611a4157611a416119d6565b5092915050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60006060820186835260206fffffffffffffffffffffffffffffffff87166020850152606060408501528185835260808501905060808660051b86010192508660005b87811015611b7f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8087860301835281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18a3603018112611b3557600080fd5b8901848101903567ffffffffffffffff811115611b5157600080fd5b803603821315611b6057600080fd5b611b6b878284611a48565b965050509183019190830190600101611ad4565b50929998505050505050505050565b805169ffffffffffffffffffff8116811461179e57600080fd5b600080600080600060a08688031215611bc057600080fd5b611bc986611b8e565b9450602086015193506040860151925060608601519150611bec60808701611b8e565b90509295509295909350565b8082028115828204841417611270576112706119d6565b600082611c45577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000825160005b81811015611c9a5760208186018101518583015201611c80565b506000920191825250919050565b600060208284031215611cba57600080fd5b81516117be81611902565b600060208284031215611cd757600080fd5b815160ff811681146117be57600080fd5b600181815b80851115611d4157817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611d2757611d276119d6565b80851615611d3457918102915b93841c9390800290611ced565b509250929050565b600082611d5857506001611270565b81611d6557506000611270565b8160018114611d7b5760028114611d8557611da1565b6001915050611270565b60ff841115611d9657611d966119d6565b50506001821b611270565b5060208310610133831016604e8410600b8410161715611dc4575081810a611270565b611dce8383611ce8565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611e0057611e006119d6565b029392505050565b60006117be8383611d4956fea2646970667358221220584f9cfe62043e59cd4eac50b828851b20679e4c7760c8bcfa6c882876f0c5b064736f6c63430008180033

Deployed Bytecode

0x60806040526004361061015f5760003560e01c806370a08231116100c0578063900ed17811610074578063dc71752d11610059578063dc71752d14610445578063f2fde38b14610482578063f58f8171146104a257600080fd5b8063900ed17814610410578063d317a83c1461043057600080fd5b8063841e4561116100a5578063841e4561146103915780638456cb59146103b15780638da5cb5b146103c657600080fd5b806370a0823114610339578063715018a61461037c57600080fd5b80633f4ba83a11610117578063572d0640116100fc578063572d0640146102805780635c975abb146102ca57806361d027b31461030c57600080fd5b80633f4ba83a14610219578063480a58ee1461022e57600080fd5b80632458a95f116101485780632458a95f146101c657806339f91003146101e65780633f34439f146101f957600080fd5b8063080e6398146101645780632430e9d614610186575b600080fd5b34801561017057600080fd5b5061018461017f3660046117a3565b6104c2565b005b34801561019257600080fd5b506101b36101a13660046117e7565b60016020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156101d257600080fd5b506101846101e1366004611850565b6105dc565b6101846101f43660046117e7565b6106ea565b34801561020557600080fd5b506101846102143660046118c1565b610844565b34801561022557600080fd5b50610184610966565b34801561023a57600080fd5b5060005461025b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bd565b34801561028c57600080fd5b506002546102a9906fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff90911681526020016101bd565b3480156102d657600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1660405190151581526020016101bd565b34801561031857600080fd5b5060035461025b9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561034557600080fd5b506101b36103543660046117e7565b73ffffffffffffffffffffffffffffffffffffffff1660009081526004602052604090205490565b34801561038857600080fd5b50610184610978565b34801561039d57600080fd5b506101846103ac3660046117e7565b61098a565b3480156103bd57600080fd5b50610184610a59565b3480156103d257600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1661025b565b34801561041c57600080fd5b5061018461042b366004611910565b610a69565b34801561043c57600080fd5b506101b3610b63565b34801561045157600080fd5b506002546102a99070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b34801561048e57600080fd5b5061018461049d3660046117e7565b610c39565b3480156104ae57600080fd5b506101846104bd366004611949565b610ca2565b6104ca610f4a565b6002546fffffffffffffffffffffffffffffffff9081169082160361051b576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806fffffffffffffffffffffffffffffffff16600003610566576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff83169081179091556040519081527fd5b6bdd60da1484326fbe658be1b26f9c10be7cb231bcca7ae05c1aa1d1b0990906020015b60405180910390a150565b6105e4610f4a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526004602052604081208054869290610619908490611a05565b90915550506002805484919060109061065990849070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16611a18565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508473ffffffffffffffffffffffffffffffffffffffff167fbaf9add78373f0cac93f4be4f43865565b55440f8d45a3f8a94d884c6a51fc66858585856040516106db9493929190611a91565b60405180910390a25050505050565b6106f2610fd8565b6003546107159073ffffffffffffffffffffffffffffffffffffffff1634611034565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610783573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a79190611ba8565b505050915050600068056bc75e2d6310000082346107c59190611bf8565b6107cf9190611c0f565b905060006107dd8483611143565b604080513481526020810183905290810184905290915060009073ffffffffffffffffffffffffffffffffffffffff86169033907f0ca214f8a19535023cdee0ea74c48997966a87ed490c81c28c235d8c93c8d19a9060600160405180910390a450505050565b61084c610fd8565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040812054908190036108ac576040517f56e7ec5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546108d3908490339073ffffffffffffffffffffffffffffffffffffffff1685611276565b6000816108e3620f424085611bf8565b6108ed9190611c0f565b905060006108fb8683611143565b604080518681526020810183905290810184905290915073ffffffffffffffffffffffffffffffffffffffff808716919088169033907f0ca214f8a19535023cdee0ea74c48997966a87ed490c81c28c235d8c93c8d19a9060600160405180910390a4505050505050565b61096e610f4a565b610976611415565b565b610980610f4a565b61097660006114ac565b610992610f4a565b60035473ffffffffffffffffffffffffffffffffffffffff8083169116036109e6576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fb6a5e89655cf506139085f051af608195ed056f8dc550b180a1c38d401e2b6c4906020016105d1565b610a61610f4a565b610976611542565b610a71610f4a565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205481151590151503610ad4576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610ae857610ae3826115bb565b610b0f565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260408120555b6040805173ffffffffffffffffffffffffffffffffffffffff8416815282151560208201527fc2af510a9d71a987e12298c8d681a18ee686d181e6fb0bd4166cc01cd7eed4b3910160405180910390a15050565b60008054604080517ffeaf968c0000000000000000000000000000000000000000000000000000000081529051839273ffffffffffffffffffffffffffffffffffffffff169163feaf968c9160048083019260a09291908290030181865afa158015610bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf79190611ba8565b5050600254919350839250610c299168056bc75e2d6310000091506fffffffffffffffffffffffffffffffff16611bf8565b610c339190611c0f565b91505090565b610c41610f4a565b73ffffffffffffffffffffffffffffffffffffffff8116610c96576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610c9f816114ac565b50565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610ced5750825b905060008267ffffffffffffffff166001148015610d0a5750303b155b905081158015610d18575080155b15610d4f576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610db05784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b876fffffffffffffffffffffffffffffffff16600003610dfb576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e04866116a3565b610e0c611542565b6000805473ffffffffffffffffffffffffffffffffffffffff808e167fffffffffffffffffffffffff0000000000000000000000000000000000000000928316178355600280546fffffffffffffffffffffffffffffffff8d167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090911617905560038054918b16919092161790555b89811015610edb57610ed38b8b83818110610eb957610eb9611c4a565b9050602002016020810190610ece91906117e7565b6115bb565b600101610e9c565b508315610f3d5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b33610f897f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610976576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610c8d565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615610976576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff841690839060405161106b9190611c79565b60006040518083038185875af1925050503d80600081146110a8576040519150601f19603f3d011682016040523d82523d6000602084013e6110ad565b606091505b505090508061113e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527f20455448207472616e73666572206661696c65640000000000000000000000006064820152608401610c8d565b505050565b60025460009081906fffffffffffffffffffffffffffffffff1661116f670de0b6b3a764000085611bf8565b6111799190611c0f565b9050806000036111b5576040517fda2fc5e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600260108282829054906101000a90046fffffffffffffffffffffffffffffffff166111e29190611a18565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555080600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112679190611a05565b90915550909150505b92915050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905291516000928392908816916113159190611c79565b6000604051808303816000865af19150503d8060008114611352576040519150601f19603f3d011682016040523d82523d6000602084013e611357565b606091505b50915091508180156113815750805115806113815750808060200190518101906113819190611ca8565b61140d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c65640000000000000000000000000000006064820152608401610c8d565b505050505050565b61141d6116b4565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016105d1565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b61154a610fd8565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611487565b60008173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162c9190611cc5565b60ff1690508060000361166b576040517f2e99569000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61167681600a611e08565b73ffffffffffffffffffffffffffffffffffffffff90921660009081526001602052604090209190915550565b6116ab61170f565b610c9f81611776565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610976576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610976576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c4161170f565b80356fffffffffffffffffffffffffffffffff8116811461179e57600080fd5b919050565b6000602082840312156117b557600080fd5b6117be8261177e565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610c9f57600080fd5b6000602082840312156117f957600080fd5b81356117be816117c5565b60008083601f84011261181657600080fd5b50813567ffffffffffffffff81111561182e57600080fd5b6020830191508360208260051b850101111561184957600080fd5b9250929050565b60008060008060006080868803121561186857600080fd5b8535611873816117c5565b9450602086013593506118886040870161177e565b9250606086013567ffffffffffffffff8111156118a457600080fd5b6118b088828901611804565b969995985093965092949392505050565b6000806000606084860312156118d657600080fd5b83356118e1816117c5565b925060208401356118f1816117c5565b929592945050506040919091013590565b8015158114610c9f57600080fd5b6000806040838503121561192357600080fd5b823561192e816117c5565b9150602083013561193e81611902565b809150509250929050565b60008060008060008060a0878903121561196257600080fd5b863561196d816117c5565b9550602087013567ffffffffffffffff81111561198957600080fd5b61199589828a01611804565b90965094506119a890506040880161177e565b925060608701356119b8816117c5565b915060808701356119c8816117c5565b809150509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115611270576112706119d6565b6fffffffffffffffffffffffffffffffff818116838216019080821115611a4157611a416119d6565b5092915050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60006060820186835260206fffffffffffffffffffffffffffffffff87166020850152606060408501528185835260808501905060808660051b86010192508660005b87811015611b7f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8087860301835281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18a3603018112611b3557600080fd5b8901848101903567ffffffffffffffff811115611b5157600080fd5b803603821315611b6057600080fd5b611b6b878284611a48565b965050509183019190830190600101611ad4565b50929998505050505050505050565b805169ffffffffffffffffffff8116811461179e57600080fd5b600080600080600060a08688031215611bc057600080fd5b611bc986611b8e565b9450602086015193506040860151925060608601519150611bec60808701611b8e565b90509295509295909350565b8082028115828204841417611270576112706119d6565b600082611c45577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000825160005b81811015611c9a5760208186018101518583015201611c80565b506000920191825250919050565b600060208284031215611cba57600080fd5b81516117be81611902565b600060208284031215611cd757600080fd5b815160ff811681146117be57600080fd5b600181815b80851115611d4157817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611d2757611d276119d6565b80851615611d3457918102915b93841c9390800290611ced565b509250929050565b600082611d5857506001611270565b81611d6557506000611270565b8160018114611d7b5760028114611d8557611da1565b6001915050611270565b60ff841115611d9657611d966119d6565b50506001821b611270565b5060208310610133831016604e8410600b8410161715611dc4575081810a611270565b611dce8383611ce8565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611e0057611e006119d6565b029392505050565b60006117be8383611d4956fea2646970667358221220584f9cfe62043e59cd4eac50b828851b20679e4c7760c8bcfa6c882876f0c5b064736f6c63430008180033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.