Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x6bDC201CF27A34833C3A7d7dF5ebcd519883ab89
Balance 0 ETH
Nonce 1
Code Size 6984 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6984 bytes
0x6080604052600436106101d0575f3560e01c80638b190376116100fd578063c2d53eb411610092578063f2fde38b11610062578063f2fde38b1461056c578063f44f02401461058b578063f5b2cad7146105aa578063fc0c546a146105c9575f80fd5b8063c2d53eb414610511578063d3f7836e14610530578063db2e21bc14610544578063e08d411414610558575f80fd5b806392de21c6116100cd57806392de21c614610495578063a12df12e146104b4578063a3e09210146104d3578063c086381e146104f2575f80fd5b80638b190376146104325780638da5cb5b146104515780639106d7ba1461046d5780639134709e14610482575f80fd5b806361f6230211610173578063741bef1a11610143578063741bef1a1461036b578063773110491461038a578063845ddcb21461039e5780638603566f14610413575f80fd5b806361f62302146102fa578063633423be14610319578063715018a614610338578063724e78da1461034c575f80fd5b80633d9b2ae6116101ae5780633d9b2ae6146102515780634571a7f11461028857806353135ca0146102ab5780635e1e1004146102db575f80fd5b8063144fa6d7146101d457806324600fc3146101f55780632fa5ee3f14610209575b5f80fd5b3480156101df575f80fd5b506101f36101ee36600461177c565b6105e8565b005b348015610200575f80fd5b506101f3610670565b348015610214575f80fd5b5061022861022336600461179c565b6106d3565b6040805193845260208401929092526001600160a01b0316908201526060015b60405180910390f35b34801561025c575f80fd5b50600454610270906001600160a01b031681565b6040516001600160a01b039091168152602001610248565b348015610293575f80fd5b5061029d600a5481565b604051908152602001610248565b3480156102b6575f80fd5b506006546102cb90600160a01b900460ff1681565b6040519015158152602001610248565b3480156102e6575f80fd5b506101f36102f536600461177c565b61071a565b348015610305575f80fd5b50600654610270906001600160a01b031681565b348015610324575f80fd5b50600554610270906001600160a01b031681565b348015610343575f80fd5b506101f3610744565b348015610357575f80fd5b506101f361036636600461177c565b610755565b348015610376575f80fd5b50600354610270906001600160a01b031681565b348015610395575f80fd5b506101f36107ce565b3480156103a9575f80fd5b506103e96103b83660046117c4565b60096020525f9081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a001610248565b34801561041e575f80fd5b5061029d61042d3660046117c4565b6107f7565b34801561043d575f80fd5b506101f361044c3660046117c4565b610912565b34801561045c575f80fd5b505f546001600160a01b0316610270565b348015610478575f80fd5b5061029d60075481565b6101f36104903660046117db565b61091f565b3480156104a0575f80fd5b506101f36104af3660046117db565b610d13565b3480156104bf575f80fd5b506101f36104ce36600461177c565b61121c565b3480156104de575f80fd5b506101f36104ed366004611812565b611246565b3480156104fd575f80fd5b5061029d61050c3660046117c4565b6112cd565b34801561051c575f80fd5b50600c54610270906001600160a01b031681565b34801561053b575f80fd5b5061029d611375565b34801561054f575f80fd5b506101f36113f6565b348015610563575f80fd5b5061029d61157e565b348015610577575f80fd5b506101f361058636600461177c565b6115c5565b348015610596575f80fd5b506101f36105a5366004611850565b611602565b3480156105b5575f80fd5b50600254610270906001600160a01b031681565b3480156105d4575f80fd5b50600154610270906001600160a01b031681565b6105f06116e6565b6001600160a01b0381166106445760405162461bcd60e51b8152602060048201526016602482015275546f6b656e206973207a65726f20616464726573732160501b60448201526064015b60405180910390fd5b600180546001600160a01b039092166001600160a01b0319928316811790915560028054909216179055565b6106786116e6565b60405133904780156108fc02915f818181858888f193505050506106d15760405162461bcd60e51b815260206004820152601060248201526f4661696c65642077697468647261772160801b604482015260640161063b565b565b6008602052815f5260405f2081815481106106ec575f80fd5b5f9182526020909120600390910201805460018201546002909201549093509091506001600160a01b031683565b6107226116e6565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b61074c6116e6565b6106d15f611712565b61075d6116e6565b6001600160a01b0381166107ac5760405162461bcd60e51b8152602060048201526016602482015275546f6b656e206973207a65726f20616464726573732160501b604482015260640161063b565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6107d66116e6565b6006805460ff60a01b198116600160a01b9182900460ff1615909102179055565b6006545f90600160a01b900460ff166108225760405162461bcd60e51b815260040161063b90611886565b5f61082b61157e565b90505f811161087c5760405162461bcd60e51b815260206004820152601a60248201527f4e6f2061637469766520737461676520617661696c61626c6521000000000000604482015260640161063b565b5f818152600960209081526040808320815160a081018352815481526001820154938101849052600282015492810192909252600381015460608301526004015460ff161515608082015291906108d390866118ca565b90505f6108e7670de0b6b3a76400006112cd565b90505f816108fd84670de0b6b3a76400006118ca565b61090791906118e7565b979650505050505050565b61091a6116e6565b600a55565b600654600160a01b900460ff166109485760405162461bcd60e51b815260040161063b90611886565b5f61095161157e565b90505f811161099e5760405162461bcd60e51b8152602060048201526019602482015278537461676520696e666f206e6f7420617661696c61626c652160381b604482015260640161063b565b5f818152600960205260408120906109b5856107f7565b9050803410156109fd5760405162461bcd60e51b81526020600482015260136024820152724e6f7420656e6f756768207061796d656e742160681b604482015260640161063b565b5f610a1086670de0b6b3a76400006118ca565b90505f60025f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a63573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a879190611906565b60ff1690505f610a98826012611926565b90505f610aa682600a611a1c565b610ab090856118e7565b90508560020154818760030154610ac79190611a27565b1115610b155760405162461bcd60e51b815260206004820152601b60248201527f537461676520746f6b656e206c696d6974206578636565646564210000000000604482015260640161063b565b6005546040516001600160a01b03909116903480156108fc02915f818181858888f19350505050610b885760405162461bcd60e51b815260206004820152601f60248201527f4661696c656420746f207472616e7366657220455448207061796d656e742100604482015260640161063b565b600154600480546040516323b872dd60e01b81526001600160a01b0391821692810192909252336024830152604482018490525f9216906323b872dd906064016020604051808303815f875af1158015610be4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c089190611a3a565b905081876003015f828254610c1d9190611a27565b90915550819050610c705760405162461bcd60e51b815260206004820152601960248201527f4661696c656420746f207472616e7366657220746f6b656e2100000000000000604482015260640161063b565b6001600160a01b03891615610cf1576001600160a01b038981165f90815260086020908152604080832081516060810183528d8152808401888152339382019384528254600180820185559387529490952090516003909402019283559251928201929092559051600290910180546001600160a01b031916919092161790555b8160075f828254610d029190611a27565b909155505050505050505050505050565b600654600160a01b900460ff16610d3c5760405162461bcd60e51b815260040161063b90611886565b5f8211610d965760405162461bcd60e51b815260206004820152602260248201527f506c6561736520656e746572206d696e696d756d20746f6b656e20616d6f756e604482015261742160f01b606482015260840161063b565b5f610d9f61157e565b90505f8111610dec5760405162461bcd60e51b8152602060048201526019602482015278537461676520696e666f206e6f7420617661696c61626c652160381b604482015260640161063b565b5f8181526009602052604081206001810154909190610e0b90866118ca565b90505f60065f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e5e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e829190611906565b60ff1690505f670de0b6b3a7640000610e9c83600a611a1c565b610ea690856118ca565b610eb091906118e7565b600654604051636eb1769f60e11b815233600482015230602482015291925082916001600160a01b039091169063dd62ed3e90604401602060405180830381865afa158015610f01573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f259190611a55565b1015610f735760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74205553445420616c6c6f77616e63652100000000604482015260640161063b565b6006546005546040516323b872dd60e01b81523360048201526001600160a01b039182166024820152604481018490525f9291909116906323b872dd906064016020604051808303815f875af1158015610fcf573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ff39190611a3a565b9050806110395760405162461bcd60e51b815260206004820152601460248201527355534454207061796d656e74206661696c65642160601b604482015260640161063b565b6002546040805163313ce56760e01b815290515f926001600160a01b03169163313ce5679160048083019260209291908290030181865afa158015611080573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110a49190611906565b6110af906012611a6c565b6110ba90600a611a85565b6110cc8a670de0b6b3a76400006118ca565b6110d691906118e7565b905085600201548187600301546110ed9190611a27565b111561113b5760405162461bcd60e51b815260206004820152601b60248201527f537461676520746f6b656e206c696d6974206578636565646564210000000000604482015260640161063b565b600154600480546040516323b872dd60e01b81526001600160a01b0391821692810192909252336024830152604482018490525f9216906323b872dd906064016020604051808303815f875af1158015611197573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111bb9190611a3a565b905081876003015f8282546111d09190611a27565b90915550819050610c705760405162461bcd60e51b8152602060048201526016602482015275546f6b656e207472616e73666572206661696c65642160501b604482015260640161063b565b6112246116e6565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b61124e6116e6565b5f84815260096020526040902054841461129e5760405162461bcd60e51b8152602060048201526011602482015270494420646f65736e27742065786973742160781b604482015260640161063b565b5f9384526009602052604090932060018101929092556002820155600401805460ff1916911515919091179055565b5f806112d7611375565b90505f60035f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561132a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061134e9190611906565b61135990600a611a85565b61136383866118ca565b61136d91906118e7565b949350505050565b5f8060035f9054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156113c7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113eb9190611aac565b509195945050505050565b6113fe6116e6565b6001546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015611444573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114689190611a55565b90505f81116114b95760405162461bcd60e51b815260206004820152601a60248201527f4e6f20746f6b656e73206c65667420746f207769746864726177000000000000604482015260640161063b565b60015460405163a9059cbb60e01b8152336004820152602481018390525f916001600160a01b03169063a9059cbb906044016020604051808303815f875af1158015611507573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061152b9190611a3a565b90508061157a5760405162461bcd60e51b815260206004820152601960248201527f4661696c656420746f20776974686472617720746f6b656e7300000000000000604482015260640161063b565b5050565b5f8060015b600b5481116115bf575f8181526009602052604090206004015460ff16156115ad578091506115bf565b806115b781611afa565b915050611583565b50919050565b6115cd6116e6565b6001600160a01b0381166115f657604051631e4fbdf760e01b81525f600482015260240161063b565b6115ff81611712565b50565b61160a6116e6565b5f600b54600161161a9190611a27565b9050600a548111156116675760405162461bcd60e51b81526020600482015260166024820152754d6178696d756d20737461676520657863656564732160501b604482015260640161063b565b6001600b5f8282546116799190611a27565b90915550506040805160a08101825282815260208082019687528183019586525f6060830181815295151560808401908152948152600990915291909120905181559351600185015591516002840155516003830155516004909101805460ff1916911515919091179055565b5f546001600160a01b031633146106d15760405163118cdaa760e01b815233600482015260240161063b565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b0381168114611777575f80fd5b919050565b5f6020828403121561178c575f80fd5b61179582611761565b9392505050565b5f80604083850312156117ad575f80fd5b6117b683611761565b946020939093013593505050565b5f602082840312156117d4575f80fd5b5035919050565b5f80604083850312156117ec575f80fd5b823591506117fc60208401611761565b90509250929050565b80151581146115ff575f80fd5b5f805f8060808587031215611825575f80fd5b843593506020850135925060408501359150606085013561184581611805565b939692955090935050565b5f805f60608486031215611862575f80fd5b8335925060208401359150604084013561187b81611805565b809150509250925092565b60208082526016908201527550726573616c65206973206e6f74206163746976652160501b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176118e1576118e16118b6565b92915050565b5f8261190157634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215611916575f80fd5b815160ff81168114611795575f80fd5b818103818111156118e1576118e16118b6565b6001815b600184111561197457808504811115611958576119586118b6565b600184161561196657908102905b60019390931c92800261193d565b935093915050565b5f8261198a575060016118e1565b8161199657505f6118e1565b81600181146119ac57600281146119b6576119d2565b60019150506118e1565b60ff8411156119c7576119c76118b6565b50506001821b6118e1565b5060208310610133831016604e8410600b84101617156119f5575081810a6118e1565b611a015f198484611939565b805f1904821115611a1457611a146118b6565b029392505050565b5f611795838361197c565b808201808211156118e1576118e16118b6565b5f60208284031215611a4a575f80fd5b815161179581611805565b5f60208284031215611a65575f80fd5b5051919050565b60ff82811682821603908111156118e1576118e16118b6565b5f61179560ff84168361197c565b805169ffffffffffffffffffff81168114611777575f80fd5b5f805f805f60a08688031215611ac0575f80fd5b611ac986611a93565b60208701516040880151606089015192975090955093509150611aee60808701611a93565b90509295509295909350565b5f60018201611b0b57611b0b6118b6565b506001019056fea2646970667358221220e332f45593e1488ce7a7b2c3cc22646f5d5baa94539e894c5c005c4527cc4d8464736f6c634300081a0033

Verified Source Code Partial Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: Yes (200 runs)
VULPEPRESALE.sol 605 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Context.sol


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

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

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


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

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/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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/token/ERC20/extensions/IERC20Metadata.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;


/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// File: @chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol


pragma solidity ^0.8.0;

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: presale.sol


pragma solidity ^0.8.20;





contract VULPEPRESALE is Ownable {
    IERC20 public token;
    IERC20Metadata public tokenMetadata;
    AggregatorV3Interface public priceFeed;
    address public sellerAddress;
    address public paymentAddress;
    address public UsdtAddress;
    bool public presaleActive = true;
    uint256 public totalSold = 0;

    struct Stage {
        uint256 id;
        uint256 price;
        uint256 maxTokens;
        uint256 tokensSold;
        bool active;
    }

    struct SaleRecord {
        uint256 stageId;
        uint256 tokensSold;
        address buyer;
    }

    mapping(address => SaleRecord[]) public referallSalesRecords;

    mapping(uint256 => Stage) public stages;
    uint256 public maxStage = 10;
    uint256 currentStageId = 0;
    address public initOwner = 0x8aB654A21D8AC187F94fac01CEbbFCcd575d6C55;

    /***
     * constructor
     */
    constructor(
        address _seller,
        address _payment,
        address _token
    ) Ownable(msg.sender) {
        transferOwnership(initOwner);
        token = IERC20(_token);
        tokenMetadata = IERC20Metadata(_token);
        sellerAddress = _seller;
        paymentAddress = _payment;
        if (block.chainid == 56) {
            UsdtAddress = 0x55d398326f99059fF775485246999027B3197955; // USDT na BSC
            priceFeed = AggregatorV3Interface(
                0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE
            ); // ETH/USD na BSC
        } else if (block.chainid == 1) {
            UsdtAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7; // USDT na Ethereum
            priceFeed = AggregatorV3Interface(
                0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
            ); // ETH/USD na Ethereum
        } else {
            revert("Unsupported network!");
        }
    }

    /***
     * Get the latest ETH/USD price from the Aggregator
     */
    function getEthToUsdPrice() public view returns (int256) {
        (, int256 price, , , ) = priceFeed.latestRoundData();

        return price;
    }

    /***
     * Convert ETH to USD based on the latest price from the Aggregator
     */
    function convertEthToUsd(uint256 ethAmount) public view returns (uint256) {
        int256 ethToUsdPrice = getEthToUsdPrice();

        uint256 usdAmount = (ethAmount * uint256(ethToUsdPrice)) /
            (10**priceFeed.decimals());
        return usdAmount;
    }

    function calculateWeiRequired(uint256 tokenAmount)
        public
        view
        returns (uint256)
    {
        require(presaleActive, "Presale is not active!");
        uint256 _id = getCurrentStageIdActive();
        require(_id > 0, "No active stage available!");

        Stage memory currentStage = stages[_id];

        uint256 totalPayUsd = tokenAmount * currentStage.price; // Calculate total USD needed
        uint256 ethToUsd = convertEthToUsd(1e18); // Get current ETH to USD conversion rate for 1 ETH

        uint256 totalPayInWei = (totalPayUsd * 1e18) / ethToUsd;

        return totalPayInWei;
    }

    function buyTokenWithUsdt(uint256 _amount, address _referallAddress)
        public
    {
        require(presaleActive, "Presale is not active!");
        require(_amount > 0, "Please enter minimum token amount!");

        uint256 _id = getCurrentStageIdActive();
        require(_id > 0, "Stage info not available!");

        Stage storage currentStage = stages[_id];

        uint256 totalPayInUsd = _amount * currentStage.price; // Total payment in USD
        uint256 usdtDecimals = IERC20Metadata(UsdtAddress).decimals();
        uint256 totalPayInUsdt = (totalPayInUsd * (10**usdtDecimals)) / 1e18;

        require(
            IERC20(UsdtAddress).allowance(msg.sender, address(this)) >=
                totalPayInUsdt,
            "Insufficient USDT allowance!"
        );

        // Transfer USDT to seller
        bool paymentSuccess = IERC20(UsdtAddress).transferFrom(
            msg.sender,
            paymentAddress,
            totalPayInUsdt
        );

        require(paymentSuccess, "USDT payment failed!");

        uint256 totalTokenAmount = (_amount * 1e18) /
            (10**(18 - tokenMetadata.decimals()));

        require(
            currentStage.tokensSold + totalTokenAmount <=
                currentStage.maxTokens,
            "Stage token limit exceeded!"
        );

        // Transfer tokens to buyer
        bool tokenTransferSuccess = token.transferFrom(
            sellerAddress,
            msg.sender,
            totalTokenAmount
        );

        currentStage.tokensSold += totalTokenAmount;

        require(tokenTransferSuccess, "Token transfer failed!");

        if (_referallAddress != address(0)) {
            referallSalesRecords[_referallAddress].push(
                SaleRecord({
                    stageId: _id,
                    tokensSold: totalTokenAmount,
                    buyer: msg.sender
                })
            );
        }

        totalSold += totalTokenAmount;
    }

    function buyToken(uint256 _amount, address _referallAddress)
        public
        payable
    {
        require(presaleActive, "Presale is not active!");
        require(_amount >= 0, "Please enter minimum token!");
        uint256 _id = getCurrentStageIdActive();
        require(_id > 0, "Stage info not available!");
        Stage storage currentStage = stages[_id];

        uint256 _totalPayInEther = calculateWeiRequired(_amount);
        require(msg.value >= _totalPayInEther, "Not enough payment!");

        uint256 _totalAmount = _amount * 1e18;
        uint256 _tokenDecimals = tokenMetadata.decimals();
        uint256 _subDecimals = 18 - _tokenDecimals;
        uint256 _totalTokenAmount = _totalAmount / (10**_subDecimals);

        require(
            currentStage.tokensSold + _totalTokenAmount <=
                currentStage.maxTokens,
            "Stage token limit exceeded!"
        );

        // Payment price transfer to seller address
        require(
            payable(paymentAddress).send(msg.value),
            "Failed to transfer ETH payment!"
        );

        // Purchased tokens transfer from seller address to buyer address
        bool success = token.transferFrom(
            sellerAddress,
            msg.sender,
            _totalTokenAmount
        );

        currentStage.tokensSold += _totalTokenAmount;

        require(success, "Failed to transfer token!");

        if (_referallAddress != address(0)) {
            referallSalesRecords[_referallAddress].push(
                SaleRecord({
                    stageId: _id,
                    tokensSold: _totalTokenAmount,
                    buyer: msg.sender
                })
            );
        }

        totalSold += _totalTokenAmount;
    }

    /***
     * @dev update token address
     */
    function setToken(address _token) public onlyOwner {
        require(_token != address(0), "Token is zero address!");
        token = IERC20(_token);
        tokenMetadata = IERC20Metadata(_token);
    }

    /***
     * @dev update price feed address
     */
    function setPriceFeed(address _priceFeed) public onlyOwner {
        require(_priceFeed != address(0), "Token is zero address!");
        priceFeed = AggregatorV3Interface(_priceFeed);
    }

    /***
     * @dev update sellerAddress
     */
    function setSellerAddress(address _seller) public onlyOwner {
        sellerAddress = _seller;
    }

    /***
     * @dev update paementAddress
     */
    function setPaymentAddress(address _payment) public onlyOwner {
        paymentAddress = _payment;
    }

    /***
     * @dev flip presaleActive as true/false
     */
    function flipPresaleActive() public onlyOwner {
        presaleActive = !presaleActive;
    }

    /**
     * @dev Emergency function to withdraw all presale tokens from the contract to the owner's address
     */
    function emergencyWithdraw() public onlyOwner {
        uint256 remainingTokens = token.balanceOf(address(this));
        require(remainingTokens > 0, "No tokens left to withdraw");

        bool success = token.transfer(msg.sender, remainingTokens);
        require(success, "Failed to withdraw tokens");
    }

    /***
     * @dev update maximum stage
     */
    function setMaxStage(uint256 _maxStage) public onlyOwner {
        maxStage = _maxStage;
    }

    /***
     * @dev ading stage info
     */

    function addStage(
        uint256 _price,
        uint256 _maxTokens,
        bool _active
    ) public onlyOwner {
        uint256 _id = currentStageId + 1;
        require(_id <= maxStage, "Maximum stage exceeds!");
        currentStageId += 1;

        stages[_id] = Stage({
            id: _id,
            price: _price,
            maxTokens: _maxTokens,
            tokensSold: 0,
            active: _active
        });
    }

    function setStage(
        uint256 _id,
        uint256 _price,
        uint256 _maxTokens,
        bool _active
    ) public onlyOwner {
        require(stages[_id].id == _id, "ID doesn't exist!");
        stages[_id].price = _price;
        stages[_id].maxTokens = _maxTokens;
        stages[_id].active = _active;
    }

    /***
     * @dev get current stage id active
     */

    function getCurrentStageIdActive() public view returns (uint256) {
        uint256 _id = 0;
        for (uint256 i = 1; i <= currentStageId; i++) {
            if (stages[i].active) {
                _id = i;
                break;
            }
        }
        return _id;
    }

    /***
     * @dev withdrawFunds functions to get remaining funds transfer to seller address
     */
    function withdrawFunds() public onlyOwner {
        require(
            payable(msg.sender).send(address(this).balance),
            "Failed withdraw!"
        );
    }
}

Read Contract

UsdtAddress 0x61f62302 → address
calculateWeiRequired 0x8603566f → uint256
convertEthToUsd 0xc086381e → uint256
getCurrentStageIdActive 0xe08d4114 → uint256
getEthToUsdPrice 0xd3f7836e → int256
initOwner 0xc2d53eb4 → address
maxStage 0x4571a7f1 → uint256
owner 0x8da5cb5b → address
paymentAddress 0x633423be → address
presaleActive 0x53135ca0 → bool
priceFeed 0x741bef1a → address
referallSalesRecords 0x2fa5ee3f → uint256, uint256, address
sellerAddress 0x3d9b2ae6 → address
stages 0x845ddcb2 → uint256, uint256, uint256, uint256, bool
token 0xfc0c546a → address
tokenMetadata 0xf5b2cad7 → address
totalSold 0x9106d7ba → uint256

Write Contract 14 functions

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

addStage 0xf44f0240
uint256 _price
uint256 _maxTokens
bool _active
buyToken 0x9134709e
uint256 _amount
address _referallAddress
buyTokenWithUsdt 0x92de21c6
uint256 _amount
address _referallAddress
emergencyWithdraw 0xdb2e21bc
No parameters
flipPresaleActive 0x77311049
No parameters
renounceOwnership 0x715018a6
No parameters
setMaxStage 0x8b190376
uint256 _maxStage
setPaymentAddress 0x5e1e1004
address _payment
setPriceFeed 0x724e78da
address _priceFeed
setSellerAddress 0xa12df12e
address _seller
setStage 0xa3e09210
uint256 _id
uint256 _price
uint256 _maxTokens
bool _active
setToken 0x144fa6d7
address _token
transferOwnership 0xf2fde38b
address newOwner
withdrawFunds 0x24600fc3
No parameters

Recent Transactions

No transactions found for this address