Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xF4f7DF69b803a1890f3EAf99bF94585C93bcdc9A
Balance 0 ETH
Nonce 1
Code Size 8407 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8407 bytes
0x60806040526004361061023e5760003560e01c806389a302711161012e578063c54e44eb116100ab578063f0d3a9df1161006f578063f0d3a9df14610804578063f0f4426014610819578063f178a4fd14610839578063f2aa821814610869578063f2fde38b1461088957600080fd5b8063c54e44eb14610758578063d095362f1461078c578063da0239a6146107ac578063db74559b146107c2578063eb91d37e146107ef57600080fd5b80639d104770116100f25780639d10477014610614578063b187bd2614610634578063b469487614610649578063b920ade214610676578063bb889c2b1461073857600080fd5b806389a302711461056c5780638c28c31a146105a05780638da5cb5b146105c05780638ea98117146105de5780639106d7ba146105fe57600080fd5b806338abc158116101bc57806361d027b31161018057806361d027b3146104c757806362d4f29a146104e75780636ff1c9bc146104fc578063715018a61461051c578063845ddcb21461053157600080fd5b806338abc158146103af578063444aa92f146103cf57806352a9039c146103e25780635bf5d54c146104775780635c975abb146104a357600080fd5b80631aae8491116102035780631aae8491146103455780632cea94421461035a5780632de8f450146103705780632f6ee6951461038557806335162cea1461039a57600080fd5b80629f92621461028857806302329a29146102aa57806302fde854146102ca5780630a009097146102f257806316061dbf1461032f57600080fd5b366102835760405162461bcd60e51b815260206004820152601060248201526f5573652062757957697468455448282960801b60448201526064015b60405180910390fd5b600080fd5b34801561029457600080fd5b506102a86102a3366004611ce0565b6108a9565b005b3480156102b657600080fd5b506102a86102c5366004611cf9565b610977565b3480156102d657600080fd5b506102df600981565b6040519081526020015b60405180910390f35b3480156102fe57600080fd5b506002546103179061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016102e9565b34801561033b57600080fd5b506102df60265481565b34801561035157600080fd5b506102df610a29565b34801561036657600080fd5b506102df60245481565b34801561037c57600080fd5b506102df610a43565b34801561039157600080fd5b506102df600681565b3480156103a657600080fd5b506102df610a5b565b3480156103bb57600080fd5b506102df6103ca366004611ce0565b610a74565b6102a86103dd366004611d37565b610aef565b3480156103ee57600080fd5b5061043f6103fd366004611d37565b6027602052600090815260409020805460018201546002830154600384015460048501546005909501549394929391926001600160a01b039091169160ff1686565b604080519687526020870195909552938501929092526001600160a01b031660608401526080830152151560a082015260c0016102e9565b34801561048357600080fd5b506022546104919060ff1681565b60405160ff90911681526020016102e9565b3480156104af57600080fd5b5060025460ff165b60405190151581526020016102e9565b3480156104d357600080fd5b50600354610317906001600160a01b031681565b3480156104f357600080fd5b506102df600a81565b34801561050857600080fd5b506102a8610517366004611d37565b610dcb565b34801561052857600080fd5b506102a8610f0f565b34801561053d57600080fd5b5061055161054c366004611ce0565b610f23565b604080519384526020840192909252908201526060016102e9565b34801561057857600080fd5b506103177f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b3480156105ac57600080fd5b506102a86105bb366004611d52565b610f4a565b3480156105cc57600080fd5b506000546001600160a01b0316610317565b3480156105ea57600080fd5b506102a86105f9366004611d37565b61113e565b34801561060a57600080fd5b506102df60235481565b34801561062057600080fd5b5061055161062f366004611d8f565b6111e4565b34801561064057600080fd5b506104b7611283565b34801561065557600080fd5b506102df610664366004611d37565b60296020526000908152604090205481565b34801561068257600080fd5b50610707610691366004611d37565b6001600160a01b03908116600090815260276020908152604091829020825160c08101845281548082526001830154938201849052600283015494820185905260038301549095166060820181905260048301546080830181905260059093015460ff16151560a0909201919091529394919391565b604080519586526020860194909452928401919091526001600160a01b03166060830152608082015260a0016102e9565b34801561074457600080fd5b506102a8610753366004611daa565b611296565b34801561076457600080fd5b506103177f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b34801561079857600080fd5b506102a86107a7366004611d52565b61139f565b3480156107b857600080fd5b506102df60255481565b3480156107ce57600080fd5b506102df6107dd366004611d37565b602a6020526000908152604090205481565b3480156107fb57600080fd5b506102df611581565b34801561081057600080fd5b506028546102df565b34801561082557600080fd5b506102a8610834366004611d37565b6115a7565b34801561084557600080fd5b506104b7610854366004611d37565b602b6020526000908152604090205460ff1681565b34801561087557600080fd5b50610317610884366004611ce0565b611619565b34801561089557600080fd5b506102a86108a4366004611d37565b611643565b60025461010090046001600160a01b031633146108fb5760405162461bcd60e51b815260206004820152601060248201526f27b7363c9031b7b7b93234b730ba37b960811b604482015260640161027a565b6000811161093b5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b604482015260640161027a565b60268190556040518181527f9193344cc8802d31c4aa2815214e792efa5a9fa7daa8e102ab2ad3576e74b51b906020015b60405180910390a150565b6000546001600160a01b031633148061099f575060025461010090046001600160a01b031633145b6109dc5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b604482015260640161027a565b80156109ef576109ea61167e565b6109f7565b6109f76116d8565b60405181151581527f66006354ac6a35f0f9b001e7cd8a73623bab487be4239f71fb1428656e7de6a69060200161096c565b610a356006600a611edb565b610a40906019611ee7565b81565b610a4f6006600a611edb565b610a409061c350611ee7565b610a676006600a611edb565b610a409062030d40611ee7565b602254600090819060049060ff16600a8110610a9257610a92611efe565b600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905080600001516009600a610ad49190611edb565b610ade9085611ee7565b610ae89190611f14565b9392505050565b610af7611711565b610aff61173b565b60003411610b3f5760405162461bcd60e51b815260206004820152600d60248201526c09aeae6e840e6cadcc8408aa89609b1b604482015260640161027a565b6000670de0b6b3a764000060265434610b589190611ee7565b610b629190611f14565b9050610b706006600a611edb565b610b7b906019611ee7565b811015610b9a5760405162461bcd60e51b815260040161027a90611f36565b610ba66006600a611edb565b610bb29061c350611ee7565b811115610bd15760405162461bcd60e51b815260040161027a90611f66565b610bdd6006600a611edb565b610bea9062030d40611ee7565b33600090815260276020526040902060010154610c08908390611f9d565b1115610c265760405162461bcd60e51b815260040161027a90611fb0565b6000610c3182610a74565b905060008111610c535760405162461bcd60e51b815260040161027a90611ff3565b602554811115610c755760405162461bcd60e51b815260040161027a9061201f565b610c813382848661175f565b6003546040516000916001600160a01b03169034908381818185875af1925050503d8060008114610cce576040519150601f19603f3d011682016040523d82523d6000602084013e610cd3565b606091505b5050905080610d1a5760405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b604482015260640161027a565b3360009081526027602052604081206002018054349290610d3c908490611f9d565b90915550506022546040805134815260c0602082018190526003908201526208aa8960eb1b60e08201529081018490526060810185905260ff90911660808201526001600160a01b03851660a082015233907fe06deab6461f25669ab4b12218ee853cffe8cac3d4f9e2b41bc7c7d7c30b28e7906101000160405180910390a2505050610dc860018055565b50565b610dd3611b37565b6001600160a01b038116610e855760035460405147916000916001600160a01b039091169083908381818185875af1925050503d8060008114610e32576040519150601f19603f3d011682016040523d82523d6000602084013e610e37565b606091505b5050905080610e805760405162461bcd60e51b8152602060048201526015602482015274115512081dda5d1a191c985dd85b0819985a5b1959605a1b604482015260640161027a565b505050565b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef29190612056565b600354909150610e80906001600160a01b03848116911683611b64565b610f17611b37565b610f216000611bc3565b565b600481600a8110610f3357600080fd5b600302018054600182015460029092015490925083565b610f52611711565b610f5a61173b565b610f666006600a611edb565b610f71906019611ee7565b821015610f905760405162461bcd60e51b815260040161027a90611f36565b610f9c6006600a611edb565b610fa89061c350611ee7565b821115610fc75760405162461bcd60e51b815260040161027a90611f66565b610fd36006600a611edb565b610fe09062030d40611ee7565b33600090815260276020526040902060010154610ffe908490611f9d565b111561101c5760405162461bcd60e51b815260040161027a90611fb0565b600061102783610a74565b9050600081116110495760405162461bcd60e51b815260040161027a90611ff3565b60255481111561106b5760405162461bcd60e51b815260040161027a9061201f565b6003546110a7906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881169133911686611c13565b6110b33382858561175f565b6022546040805185815260c060208201819052600490820152635553444360e01b60e08201529081018390526060810185905260ff90911660808201526001600160a01b03831660a082015233907fe06deab6461f25669ab4b12218ee853cffe8cac3d4f9e2b41bc7c7d7c30b28e790610100015b60405180910390a25061113a60018055565b5050565b611146611b37565b6001600160a01b03811661118e5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161027a565b60028054610100600160a81b0319166101006001600160a01b038416908102919091179091556040519081527fc258faa9a17ddfdf4130b4acff63a289202e7d5f9e42f366add65368575486bc9060200161096c565b6000806000600a8460ff161061122c5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420737461676560981b604482015260640161027a565b600060048560ff16600a811061124457611244611efe565b60408051606081018252600392909202929092018054808352600182015460208401819052600290920154929093018290529197919650945092505050565b600061129160025460ff1690565b905090565b60025461010090046001600160a01b031633146112e85760405162461bcd60e51b815260206004820152601060248201526f27b7363c9031b7b7b93234b730ba37b960811b604482015260640161027a565b6023839055602582905560225460ff82811691161480159061130d5750600a8160ff16105b15611358576022805460ff191660ff83169081179091556040519081527f087b6fa18a1c8e172c612787dcbe8b401b2e3e144cfd5be67730dfa0a3c18f799060200160405180910390a15b604080518481526020810184905260ff83168183015290517ff4c3debb4cf2f3b0d9f8a6e8a0bd67fa9e23767453d60e46acd6fb64de5ccd8c9181900360600190a1505050565b6113a7611711565b6113af61173b565b6113bb6006600a611edb565b6113c6906019611ee7565b8210156113e55760405162461bcd60e51b815260040161027a90611f36565b6113f16006600a611edb565b6113fd9061c350611ee7565b82111561141c5760405162461bcd60e51b815260040161027a90611f66565b6114286006600a611edb565b6114359062030d40611ee7565b33600090815260276020526040902060010154611453908490611f9d565b11156114715760405162461bcd60e51b815260040161027a90611fb0565b600061147c83610a74565b90506000811161149e5760405162461bcd60e51b815260040161027a90611ff3565b6025548111156114c05760405162461bcd60e51b815260040161027a9061201f565b6003546114fc906001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781169133911686611c13565b6115083382858561175f565b6022546040805185815260c060208201819052600490820152631554d11560e21b60e08201529081018390526060810185905260ff90911660808201526001600160a01b03831660a082015233907fe06deab6461f25669ab4b12218ee853cffe8cac3d4f9e2b41bc7c7d7c30b28e79061010001611128565b60225460009060049060ff16600a811061159d5761159d611efe565b6003020154919050565b6115af611b37565b6001600160a01b0381166115f75760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161027a565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6028818154811061162957600080fd5b6000918252602090912001546001600160a01b0316905081565b61164b611b37565b6001600160a01b03811661167557604051631e4fbdf760e01b81526000600482015260240161027a565b610dc881611bc3565b61168661173b565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116bb3390565b6040516001600160a01b03909116815260200160405180910390a1565b6116e0611c4c565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336116bb565b60026001540361173457604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b60025460ff1615610f215760405163d93c066560e01b815260040160405180910390fd5b6001600160a01b03841660009081526027602052604090206005015460ff166117eb576001600160a01b0384166000818152602760205260408120600501805460ff191660019081179091556028805491820181559091527fe16da923a2d88192e5070f37b4571d58682c0d66212ec634d495f33de3f77ab50180546001600160a01b03191690911790555b6001600160a01b03841660009081526027602052604081208054859290611813908490611f9d565b90915550506001600160a01b03841660009081526027602052604081206001018054849290611843908490611f9d565b90915550506001600160a01b038116158015906118725750836001600160a01b0316816001600160a01b031614155b801561189957506001600160a01b03811660009081526027602052604090206005015460ff165b156119f0576001600160a01b03848116600090815260276020526040902060030154166118f2576001600160a01b03848116600090815260276020526040902060030180546001600160a01b0319169183169190911790555b6001600160a01b0384166000908152602b602052604090205460ff166119f05760006064611921600a86611ee7565b61192b9190611f14565b6001600160a01b038316600090815260296020526040812080549293508392909190611958908490611f9d565b90915550506001600160a01b0382166000908152602a60205260408120805460019290611986908490611f9d565b90915550506001600160a01b038086166000818152602b602052604090819020805460ff191660011790555190918416907f1061337b8edcfbb3d272de00867835b450ff6d827e890cae522f5023284bd2af906119e69085815260200190565b60405180910390a3505b8260236000828254611a029190611f9d565b925050819055508160246000828254611a1b9190611f9d565b925050819055508260256000828254611a34919061206f565b9091555050602254839060049060ff16600a8110611a5457611a54611efe565b600302016002016000828254611a6a9190611f9d565b909155505060225460049060ff16600a8110611a8857611a88611efe565b600302016001015460225460049060ff16600a8110611aa957611aa9611efe565b600302016002015410158015611ac65750602254600960ff909116105b15611b31576022805460ff16906000611ade83612082565b82546101009290920a60ff818102199093169183160217909155602254604051911681527f087b6fa18a1c8e172c612787dcbe8b401b2e3e144cfd5be67730dfa0a3c18f79915060200160405180910390a15b50505050565b6000546001600160a01b03163314610f215760405163118cdaa760e01b815233600482015260240161027a565b6040516001600160a01b03838116602483015260448201839052610e8091859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611c6f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038481166024830152838116604483015260648201839052611b319186918216906323b872dd90608401611b91565b60025460ff16610f2157604051638dfc202b60e01b815260040160405180910390fd5b600080602060008451602086016000885af180611c92576040513d6000823e3d81fd5b50506000513d91508115611caa578060011415611cb7565b6001600160a01b0384163b155b15611b3157604051635274afe760e01b81526001600160a01b038516600482015260240161027a565b600060208284031215611cf257600080fd5b5035919050565b600060208284031215611d0b57600080fd5b81358015158114610ae857600080fd5b80356001600160a01b0381168114611d3257600080fd5b919050565b600060208284031215611d4957600080fd5b610ae882611d1b565b60008060408385031215611d6557600080fd5b82359150611d7560208401611d1b565b90509250929050565b803560ff81168114611d3257600080fd5b600060208284031215611da157600080fd5b610ae882611d7e565b600080600060608486031215611dbf57600080fd5b8335925060208401359150611dd660408501611d7e565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115611e30578160001904821115611e1657611e16611ddf565b80851615611e2357918102915b93841c9390800290611dfa565b509250929050565b600082611e4757506001611ed5565b81611e5457506000611ed5565b8160018114611e6a5760028114611e7457611e90565b6001915050611ed5565b60ff841115611e8557611e85611ddf565b50506001821b611ed5565b5060208310610133831016604e8410600b8410161715611eb3575081810a611ed5565b611ebd8383611df5565b8060001904821115611ed157611ed1611ddf565b0290505b92915050565b6000610ae88383611e38565b8082028115828204841417611ed557611ed5611ddf565b634e487b7160e01b600052603260045260246000fd5b600082611f3157634e487b7160e01b600052601260045260246000fd5b500490565b60208082526016908201527542656c6f77206d696e696d756d20707572636861736560501b604082015260600190565b6020808252601f908201527f45786365656473206d6178696d756d20706572207472616e73616374696f6e00604082015260600190565b80820180821115611ed557611ed5611ddf565b60208082526023908201527f45786365656473206d6178696d756d2070657220757365722028243230302c3060408201526230302960e81b606082015260800190565b602080825260129082015271125b9d985b1a59081393d0c8185b5bdd5b9d60721b604082015260600190565b60208082526018908201527f457863656564732072656d61696e696e6720737570706c790000000000000000604082015260600190565b60006020828403121561206857600080fd5b5051919050565b81810381811115611ed557611ed5611ddf565b600060ff821660ff810361209857612098611ddf565b6001019291505056fea2646970667358221220176d016406290ef65fc8564fce176f9f5635a947d29fd47358ec9f433442fc5364736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: paris Optimization: Yes (200 runs)
NocturaPresale.sol 1226 lines
// Sources flattened with hardhat v2.27.1 https://hardhat.org

// SPDX-License-Identifier: MIT

// File @openzeppelin/contracts/utils/[email protected]

// Original license: 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;
    }
}


// File @openzeppelin/contracts/access/[email protected]

// Original license: SPDX_License_Identifier: MIT
// 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/utils/introspection/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}


// File @openzeppelin/contracts/interfaces/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;


// File @openzeppelin/contracts/token/ERC20/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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 @openzeppelin/contracts/interfaces/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;


// File @openzeppelin/contracts/interfaces/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;


/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}


// File @openzeppelin/contracts/token/ERC20/utils/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;


/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}


// File @openzeppelin/contracts/utils/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

/**
 * @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 {
    bool private _paused;

    /**
     * @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 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 {
        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 {
        _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/utils/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    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
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // 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 ethereum/NocturaPresale.sol

// Original license: SPDX_License_Identifier: MIT
pragma solidity ^0.8.20;





/**
 * @title NocturaPresale
 * @notice Cross-chain presale contract for Noctura (NOC) token on Ethereum
 * @dev This is a proxy contract - actual tokens are on Solana. 
 *      Purchases are recorded here and synced to Solana via the coordinator.
 */
contract NocturaPresale is Ownable, ReentrancyGuard, Pausable {
    using SafeERC20 for IERC20;

    // ==============================================
    // STRUCTS
    // ==============================================

    struct Stage {
        uint256 price;      // Price in USD (6 decimals) per NOC
        uint256 allocation; // NOC allocation for this stage (9 decimals)
        uint256 sold;       // NOC sold in this stage (9 decimals)
    }

    struct UserAllocation {
        uint256 nocAmount;      // Total NOC purchased (9 decimals)
        uint256 usdSpent;       // Total USD spent (6 decimals)
        uint256 ethSpent;       // Total ETH spent (18 decimals)
        address referrer;       // Referrer address
        uint256 referralBonus;  // Referral bonus received (9 decimals)
        bool exists;
    }

    // ==============================================
    // STATE VARIABLES
    // ==============================================

    // Token addresses
    IERC20 public immutable USDT;
    IERC20 public immutable USDC;

    // Coordinator address (for state sync from Solana)
    address public coordinator;

    // Treasury address for receiving funds
    address public treasury;

    // Presale stages (10 stages as per tokenomics)
    Stage[10] public stages;
    uint8 public currentStage;

    // Global tracking
    uint256 public totalSold;        // Total NOC sold (9 decimals)
    uint256 public totalUsdRaised;   // Total USD raised (6 decimals)
    uint256 public remainingSupply;  // Remaining NOC for sale (9 decimals)

    // Price feeds (simplified - in production use Chainlink)
    uint256 public ethPriceUsd;  // ETH price in USD (6 decimals)

    // User allocations
    mapping(address => UserAllocation) public allocations;
    address[] public buyers;

    // Referral tracking
    uint256 public constant REFERRAL_BONUS_PERCENTAGE = 10; // 10%
    mapping(address => uint256) public referralBonuses;
    mapping(address => uint256) public referralCount;
    mapping(address => bool) public hasReceivedReferralBonus; // Track one-time bonus per referrer

    // Constants
    uint256 public constant NOC_DECIMALS = 9;
    uint256 public constant USD_DECIMALS = 6;
    uint256 public constant MIN_PURCHASE_USD = 25 * 10**USD_DECIMALS;  // $25 minimum
    uint256 public constant MAX_PURCHASE_USD = 50000 * 10**USD_DECIMALS; // $50,000 max per transaction
    uint256 public constant MAX_TOTAL_PER_USER_USD = 200000 * 10**USD_DECIMALS; // $200,000 max per user

    // ==============================================
    // EVENTS
    // ==============================================

    event PurchaseRecorded(
        address indexed buyer,
        uint256 paymentAmount,
        string paymentToken,
        uint256 nocAmount,
        uint256 usdValue,
        uint8 stage,
        address referrer
    );

    event ReferralBonusRecorded(
        address indexed referrer,
        address indexed referee,
        uint256 bonusAmount
    );

    event PresalePaused(bool paused);
    event StageAdvanced(uint8 newStage);
    event StateSynced(uint256 totalSold, uint256 remainingSupply, uint8 currentStage);
    event CoordinatorUpdated(address newCoordinator);
    event EthPriceUpdated(uint256 newPrice);

    // ==============================================
    // MODIFIERS
    // ==============================================

    modifier onlyCoordinator() {
        require(msg.sender == coordinator, "Only coordinator");
        _;
    }

    // ==============================================
    // CONSTRUCTOR
    // ==============================================

    constructor(
        address _usdt,
        address _usdc,
        address _coordinator,
        address _treasury,
        uint256 _initialEthPrice
    ) Ownable(msg.sender) {
        require(_usdt != address(0), "Invalid USDT address");
        require(_usdc != address(0), "Invalid USDC address");
        require(_coordinator != address(0), "Invalid coordinator address");
        require(_treasury != address(0), "Invalid treasury address");

        USDT = IERC20(_usdt);
        USDC = IERC20(_usdc);
        coordinator = _coordinator;
        treasury = _treasury;
        ethPriceUsd = _initialEthPrice;

        // Initialize presale stages (prices in USD with 6 decimals)
        // Total allocation: 102,400,000 NOC (40% of 256M)
        stages[0] = Stage(150100, 10240000 * 10**NOC_DECIMALS, 0);   // $0.1501, 10.24M
        stages[1] = Stage(172300, 10240000 * 10**NOC_DECIMALS, 0);   // $0.1723
        stages[2] = Stage(194500, 10240000 * 10**NOC_DECIMALS, 0);   // $0.1945
        stages[3] = Stage(216700, 10240000 * 10**NOC_DECIMALS, 0);   // $0.2167
        stages[4] = Stage(238900, 10240000 * 10**NOC_DECIMALS, 0);   // $0.2389
        stages[5] = Stage(261100, 10240000 * 10**NOC_DECIMALS, 0);   // $0.2611
        stages[6] = Stage(283300, 10240000 * 10**NOC_DECIMALS, 0);   // $0.2833
        stages[7] = Stage(305500, 10240000 * 10**NOC_DECIMALS, 0);   // $0.3055
        stages[8] = Stage(327700, 10240000 * 10**NOC_DECIMALS, 0);   // $0.3277
        stages[9] = Stage(349900, 10240000 * 10**NOC_DECIMALS, 0);   // $0.3499

        remainingSupply = 102400000 * 10**NOC_DECIMALS;
        currentStage = 0;
    }

    // ==============================================
    // PURCHASE FUNCTIONS
    // ==============================================

    /**
     * @notice Purchase NOC tokens with ETH
     * @param referrer Optional referrer address
     */
    function buyWithETH(address referrer) external payable nonReentrant whenNotPaused {
        require(msg.value > 0, "Must send ETH");
        
        // Calculate USD value
        uint256 usdValue = (msg.value * ethPriceUsd) / 10**18;
        require(usdValue >= MIN_PURCHASE_USD, "Below minimum purchase");
        require(usdValue <= MAX_PURCHASE_USD, "Exceeds maximum per transaction");
        
        // Check user total limit ($200,000 max per user)
        require(
            allocations[msg.sender].usdSpent + usdValue <= MAX_TOTAL_PER_USER_USD,
            "Exceeds maximum per user ($200,000)"
        );

        // Calculate NOC amount
        uint256 nocAmount = calculateNocAmount(usdValue);
        require(nocAmount > 0, "Invalid NOC amount");
        require(nocAmount <= remainingSupply, "Exceeds remaining supply");

        // Process purchase
        _processPurchase(msg.sender, nocAmount, usdValue, referrer);

        // Transfer ETH to treasury
        (bool success, ) = treasury.call{value: msg.value}("");
        require(success, "ETH transfer failed");

        // Update user ETH spent
        allocations[msg.sender].ethSpent += msg.value;

        emit PurchaseRecorded(
            msg.sender,
            msg.value,
            "ETH",
            nocAmount,
            usdValue,
            currentStage,
            referrer
        );
    }

    /**
     * @notice Purchase NOC tokens with USDT
     * @param amount USDT amount (6 decimals)
     * @param referrer Optional referrer address
     */
    function buyWithUSDT(uint256 amount, address referrer) external nonReentrant whenNotPaused {
        require(amount >= MIN_PURCHASE_USD, "Below minimum purchase");
        require(amount <= MAX_PURCHASE_USD, "Exceeds maximum per transaction");
        
        // Check user total limit ($200,000 max per user)
        require(
            allocations[msg.sender].usdSpent + amount <= MAX_TOTAL_PER_USER_USD,
            "Exceeds maximum per user ($200,000)"
        );

        // Calculate NOC amount
        uint256 nocAmount = calculateNocAmount(amount);
        require(nocAmount > 0, "Invalid NOC amount");
        require(nocAmount <= remainingSupply, "Exceeds remaining supply");

        // Transfer USDT from user
        USDT.safeTransferFrom(msg.sender, treasury, amount);

        // Process purchase
        _processPurchase(msg.sender, nocAmount, amount, referrer);

        emit PurchaseRecorded(
            msg.sender,
            amount,
            "USDT",
            nocAmount,
            amount,
            currentStage,
            referrer
        );
    }

    /**
     * @notice Purchase NOC tokens with USDC
     * @param amount USDC amount (6 decimals)
     * @param referrer Optional referrer address
     */
    function buyWithUSDC(uint256 amount, address referrer) external nonReentrant whenNotPaused {
        require(amount >= MIN_PURCHASE_USD, "Below minimum purchase");
        require(amount <= MAX_PURCHASE_USD, "Exceeds maximum per transaction");
        
        // Check user total limit ($200,000 max per user)
        require(
            allocations[msg.sender].usdSpent + amount <= MAX_TOTAL_PER_USER_USD,
            "Exceeds maximum per user ($200,000)"
        );

        // Calculate NOC amount
        uint256 nocAmount = calculateNocAmount(amount);
        require(nocAmount > 0, "Invalid NOC amount");
        require(nocAmount <= remainingSupply, "Exceeds remaining supply");

        // Transfer USDC from user
        USDC.safeTransferFrom(msg.sender, treasury, amount);

        // Process purchase
        _processPurchase(msg.sender, nocAmount, amount, referrer);

        emit PurchaseRecorded(
            msg.sender,
            amount,
            "USDC",
            nocAmount,
            amount,
            currentStage,
            referrer
        );
    }

    // ==============================================
    // INTERNAL FUNCTIONS
    // ==============================================

    function _processPurchase(
        address buyer,
        uint256 nocAmount,
        uint256 usdValue,
        address referrer
    ) internal {
        // Initialize user if first purchase
        if (!allocations[buyer].exists) {
            allocations[buyer].exists = true;
            buyers.push(buyer);
        }

        // Update user allocation
        allocations[buyer].nocAmount += nocAmount;
        allocations[buyer].usdSpent += usdValue;

        // Process referral - ONE-TIME ONLY (same as Solana contract)
        // Referral bonus only given on FIRST purchase by the referee
        if (referrer != address(0) && referrer != buyer && allocations[referrer].exists) {
            // Only set referrer if not already set
            if (allocations[buyer].referrer == address(0)) {
                allocations[buyer].referrer = referrer;
            }
            
            // Only award bonus if this is the first purchase (nocAmount was 0 before)
            // Check if buyer has received referral bonus before
            if (!hasReceivedReferralBonus[buyer]) {
                uint256 referralBonus = (nocAmount * REFERRAL_BONUS_PERCENTAGE) / 100;
                referralBonuses[referrer] += referralBonus;
                referralCount[referrer] += 1;
                hasReceivedReferralBonus[buyer] = true;
                
                emit ReferralBonusRecorded(referrer, buyer, referralBonus);
            }
        }

        // Update global state
        totalSold += nocAmount;
        totalUsdRaised += usdValue;
        remainingSupply -= nocAmount;

        // Update stage sold
        stages[currentStage].sold += nocAmount;

        // Auto-advance stage if allocation exhausted
        if (stages[currentStage].sold >= stages[currentStage].allocation && currentStage < 9) {
            currentStage++;
            emit StageAdvanced(currentStage);
        }
    }

    function calculateNocAmount(uint256 usdValue) public view returns (uint256) {
        Stage memory stage = stages[currentStage];
        // nocAmount = usdValue * 10^NOC_DECIMALS / price
        return (usdValue * 10**NOC_DECIMALS) / stage.price;
    }

    // ==============================================
    // VIEW FUNCTIONS
    // ==============================================

    function getUserAllocation(address user) external view returns (
        uint256 nocAmount,
        uint256 usdSpent,
        uint256 ethSpent,
        address referrer,
        uint256 referralBonus
    ) {
        UserAllocation memory alloc = allocations[user];
        return (
            alloc.nocAmount,
            alloc.usdSpent,
            alloc.ethSpent,
            alloc.referrer,
            alloc.referralBonus
        );
    }

    function getStageInfo(uint8 stage) external view returns (
        uint256 price,
        uint256 allocation,
        uint256 sold
    ) {
        require(stage < 10, "Invalid stage");
        Stage memory s = stages[stage];
        return (s.price, s.allocation, s.sold);
    }

    function getCurrentPrice() external view returns (uint256) {
        return stages[currentStage].price;
    }

    function getBuyersCount() external view returns (uint256) {
        return buyers.length;
    }

    function isPaused() external view returns (bool) {
        return paused();
    }

    // ==============================================
    // COORDINATOR FUNCTIONS (State Sync from Solana)
    // ==============================================

    /**
     * @notice Sync state from Solana master chain
     * @dev Called by coordinator to keep EVM contracts in sync
     */
    function syncFromSolana(
        uint256 _totalSold,
        uint256 _remainingSupply,
        uint8 _currentStage
    ) external onlyCoordinator {
        totalSold = _totalSold;
        remainingSupply = _remainingSupply;
        
        if (_currentStage != currentStage && _currentStage < 10) {
            currentStage = _currentStage;
            emit StageAdvanced(_currentStage);
        }

        emit StateSynced(_totalSold, _remainingSupply, _currentStage);
    }

    // ==============================================
    // ADMIN FUNCTIONS
    // ==============================================

    function setCoordinator(address _coordinator) external onlyOwner {
        require(_coordinator != address(0), "Invalid address");
        coordinator = _coordinator;
        emit CoordinatorUpdated(_coordinator);
    }

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

    function setEthPrice(uint256 _price) external onlyCoordinator {
        require(_price > 0, "Invalid price");
        ethPriceUsd = _price;
        emit EthPriceUpdated(_price);
    }

    function pause(bool _paused) external {
        require(msg.sender == owner() || msg.sender == coordinator, "Not authorized");
        if (_paused) {
            _pause();
        } else {
            _unpause();
        }
        emit PresalePaused(_paused);
    }

    // Emergency withdrawal (only owner)
    function emergencyWithdraw(address token) external onlyOwner {
        if (token == address(0)) {
            uint256 balance = address(this).balance;
            (bool success, ) = treasury.call{value: balance}("");
            require(success, "ETH withdrawal failed");
        } else {
            IERC20 erc20 = IERC20(token);
            uint256 balance = erc20.balanceOf(address(this));
            erc20.safeTransfer(treasury, balance);
        }
    }

    // Receive ETH
    receive() external payable {
        revert("Use buyWithETH()");
    }
}

Read Contract

MAX_PURCHASE_USD 0x2de8f450 → uint256
MAX_TOTAL_PER_USER_USD 0x35162cea → uint256
MIN_PURCHASE_USD 0x1aae8491 → uint256
NOC_DECIMALS 0x02fde854 → uint256
REFERRAL_BONUS_PERCENTAGE 0x62d4f29a → uint256
USDC 0x89a30271 → address
USDT 0xc54e44eb → address
USD_DECIMALS 0x2f6ee695 → uint256
allocations 0x52a9039c → uint256, uint256, uint256, address, uint256, bool
buyers 0xf2aa8218 → address
calculateNocAmount 0x38abc158 → uint256
coordinator 0x0a009097 → address
currentStage 0x5bf5d54c → uint8
ethPriceUsd 0x16061dbf → uint256
getBuyersCount 0xf0d3a9df → uint256
getCurrentPrice 0xeb91d37e → uint256
getStageInfo 0x9d104770 → uint256, uint256, uint256
getUserAllocation 0xb920ade2 → uint256, uint256, uint256, address, uint256
hasReceivedReferralBonus 0xf178a4fd → bool
isPaused 0xb187bd26 → bool
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
referralBonuses 0xb4694876 → uint256
referralCount 0xdb74559b → uint256
remainingSupply 0xda0239a6 → uint256
stages 0x845ddcb2 → uint256, uint256, uint256
totalSold 0x9106d7ba → uint256
totalUsdRaised 0x2cea9442 → uint256
treasury 0x61d027b3 → address

Write Contract 11 functions

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

buyWithETH 0x444aa92f
address referrer
buyWithUSDC 0x8c28c31a
uint256 amount
address referrer
buyWithUSDT 0xd095362f
uint256 amount
address referrer
emergencyWithdraw 0x6ff1c9bc
address token
pause 0x02329a29
bool _paused
renounceOwnership 0x715018a6
No parameters
setCoordinator 0x8ea98117
address _coordinator
setEthPrice 0x009f9262
uint256 _price
setTreasury 0xf0f44260
address _treasury
syncFromSolana 0xbb889c2b
uint256 _totalSold
uint256 _remainingSupply
uint8 _currentStage
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address