Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xdE69eB5ECfc7f2a8025069f9Dc2A3d14bFDA24BF
Balance 0 ETH
Nonce 1
Code Size 6942 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6942 bytes
0x6080604052600436106101c5575f3560e01c80638b190376116100f2578063c086381e11610092578063f2fde38b11610062578063f2fde38b14610542578063f44f024014610561578063f5b2cad714610580578063fc0c546a1461059f575f80fd5b8063c086381e146104e7578063d3f7836e14610506578063db2e21bc1461051a578063e08d41141461052e575f80fd5b80639134709e116100cd5780639134709e1461047757806392de21c61461048a578063a12df12e146104a9578063a3e09210146104c8575f80fd5b80638b190376146104275780638da5cb5b146104465780639106d7ba14610462575f80fd5b806361f6230211610168578063741bef1a11610138578063741bef1a14610360578063773110491461037f578063845ddcb2146103935780638603566f14610408575f80fd5b806361f62302146102ef578063633423be1461030e578063715018a61461032d578063724e78da14610341575f80fd5b80633d9b2ae6116101a35780633d9b2ae6146102465780634571a7f11461027d57806353135ca0146102a05780635e1e1004146102d0575f80fd5b8063144fa6d7146101c957806324600fc3146101ea5780632fa5ee3f146101fe575b5f80fd5b3480156101d4575f80fd5b506101e86101e3366004611752565b6105be565b005b3480156101f5575f80fd5b506101e8610646565b348015610209575f80fd5b5061021d610218366004611772565b6106a9565b6040805193845260208401929092526001600160a01b0316908201526060015b60405180910390f35b348015610251575f80fd5b50600454610265906001600160a01b031681565b6040516001600160a01b03909116815260200161023d565b348015610288575f80fd5b50610292600a5481565b60405190815260200161023d565b3480156102ab575f80fd5b506006546102c090600160a01b900460ff1681565b604051901515815260200161023d565b3480156102db575f80fd5b506101e86102ea366004611752565b6106f0565b3480156102fa575f80fd5b50600654610265906001600160a01b031681565b348015610319575f80fd5b50600554610265906001600160a01b031681565b348015610338575f80fd5b506101e861071a565b34801561034c575f80fd5b506101e861035b366004611752565b61072b565b34801561036b575f80fd5b50600354610265906001600160a01b031681565b34801561038a575f80fd5b506101e86107a4565b34801561039e575f80fd5b506103de6103ad36600461179a565b60096020525f9081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161023d565b348015610413575f80fd5b5061029261042236600461179a565b6107cd565b348015610432575f80fd5b506101e861044136600461179a565b6108e8565b348015610451575f80fd5b505f546001600160a01b0316610265565b34801561046d575f80fd5b5061029260075481565b6101e86104853660046117b1565b6108f5565b348015610495575f80fd5b506101e86104a43660046117b1565b610ce9565b3480156104b4575f80fd5b506101e86104c3366004611752565b6111f2565b3480156104d3575f80fd5b506101e86104e23660046117e8565b61121c565b3480156104f2575f80fd5b5061029261050136600461179a565b6112a3565b348015610511575f80fd5b5061029261134b565b348015610525575f80fd5b506101e86113cc565b348015610539575f80fd5b50610292611554565b34801561054d575f80fd5b506101e861055c366004611752565b61159b565b34801561056c575f80fd5b506101e861057b366004611826565b6115d8565b34801561058b575f80fd5b50600254610265906001600160a01b031681565b3480156105aa575f80fd5b50600154610265906001600160a01b031681565b6105c66116bc565b6001600160a01b03811661061a5760405162461bcd60e51b8152602060048201526016602482015275546f6b656e206973207a65726f20616464726573732160501b60448201526064015b60405180910390fd5b600180546001600160a01b039092166001600160a01b0319928316811790915560028054909216179055565b61064e6116bc565b60405133904780156108fc02915f818181858888f193505050506106a75760405162461bcd60e51b815260206004820152601060248201526f4661696c65642077697468647261772160801b6044820152606401610611565b565b6008602052815f5260405f2081815481106106c2575f80fd5b5f9182526020909120600390910201805460018201546002909201549093509091506001600160a01b031683565b6106f86116bc565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6107226116bc565b6106a75f6116e8565b6107336116bc565b6001600160a01b0381166107825760405162461bcd60e51b8152602060048201526016602482015275546f6b656e206973207a65726f20616464726573732160501b6044820152606401610611565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6107ac6116bc565b6006805460ff60a01b198116600160a01b9182900460ff1615909102179055565b6006545f90600160a01b900460ff166107f85760405162461bcd60e51b81526004016106119061185c565b5f610801611554565b90505f81116108525760405162461bcd60e51b815260206004820152601a60248201527f4e6f2061637469766520737461676520617661696c61626c65210000000000006044820152606401610611565b5f818152600960209081526040808320815160a081018352815481526001820154938101849052600282015492810192909252600381015460608301526004015460ff161515608082015291906108a990866118a0565b90505f6108bd670de0b6b3a76400006112a3565b90505f816108d384670de0b6b3a76400006118a0565b6108dd91906118bd565b979650505050505050565b6108f06116bc565b600a55565b600654600160a01b900460ff1661091e5760405162461bcd60e51b81526004016106119061185c565b5f610927611554565b90505f81116109745760405162461bcd60e51b8152602060048201526019602482015278537461676520696e666f206e6f7420617661696c61626c652160381b6044820152606401610611565b5f8181526009602052604081209061098b856107cd565b9050803410156109d35760405162461bcd60e51b81526020600482015260136024820152724e6f7420656e6f756768207061796d656e742160681b6044820152606401610611565b5f6109e686670de0b6b3a76400006118a0565b90505f60025f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a39573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a5d91906118dc565b60ff1690505f610a6e8260126118fc565b90505f610a7c82600a6119f2565b610a8690856118bd565b90508560020154818760030154610a9d91906119fd565b1115610aeb5760405162461bcd60e51b815260206004820152601b60248201527f537461676520746f6b656e206c696d69742065786365656465642100000000006044820152606401610611565b6005546040516001600160a01b03909116903480156108fc02915f818181858888f19350505050610b5e5760405162461bcd60e51b815260206004820152601f60248201527f4661696c656420746f207472616e7366657220455448207061796d656e7421006044820152606401610611565b600154600480546040516323b872dd60e01b81526001600160a01b0391821692810192909252336024830152604482018490525f9216906323b872dd906064016020604051808303815f875af1158015610bba573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bde9190611a10565b905081876003015f828254610bf391906119fd565b90915550819050610c465760405162461bcd60e51b815260206004820152601960248201527f4661696c656420746f207472616e7366657220746f6b656e21000000000000006044820152606401610611565b6001600160a01b03891615610cc7576001600160a01b038981165f90815260086020908152604080832081516060810183528d8152808401888152339382019384528254600180820185559387529490952090516003909402019283559251928201929092559051600290910180546001600160a01b031916919092161790555b8160075f828254610cd891906119fd565b909155505050505050505050505050565b600654600160a01b900460ff16610d125760405162461bcd60e51b81526004016106119061185c565b5f8211610d6c5760405162461bcd60e51b815260206004820152602260248201527f506c6561736520656e746572206d696e696d756d20746f6b656e20616d6f756e604482015261742160f01b6064820152608401610611565b5f610d75611554565b90505f8111610dc25760405162461bcd60e51b8152602060048201526019602482015278537461676520696e666f206e6f7420617661696c61626c652160381b6044820152606401610611565b5f8181526009602052604081206001810154909190610de190866118a0565b90505f60065f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e34573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e5891906118dc565b60ff1690505f670de0b6b3a7640000610e7283600a6119f2565b610e7c90856118a0565b610e8691906118bd565b600654604051636eb1769f60e11b815233600482015230602482015291925082916001600160a01b039091169063dd62ed3e90604401602060405180830381865afa158015610ed7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610efb9190611a2b565b1015610f495760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74205553445420616c6c6f77616e636521000000006044820152606401610611565b6006546005546040516323b872dd60e01b81523360048201526001600160a01b039182166024820152604481018490525f9291909116906323b872dd906064016020604051808303815f875af1158015610fa5573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fc99190611a10565b90508061100f5760405162461bcd60e51b815260206004820152601460248201527355534454207061796d656e74206661696c65642160601b6044820152606401610611565b6002546040805163313ce56760e01b815290515f926001600160a01b03169163313ce5679160048083019260209291908290030181865afa158015611056573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061107a91906118dc565b611085906012611a42565b61109090600a611a5b565b6110a28a670de0b6b3a76400006118a0565b6110ac91906118bd565b905085600201548187600301546110c391906119fd565b11156111115760405162461bcd60e51b815260206004820152601b60248201527f537461676520746f6b656e206c696d69742065786365656465642100000000006044820152606401610611565b600154600480546040516323b872dd60e01b81526001600160a01b0391821692810192909252336024830152604482018490525f9216906323b872dd906064016020604051808303815f875af115801561116d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111919190611a10565b905081876003015f8282546111a691906119fd565b90915550819050610c465760405162461bcd60e51b8152602060048201526016602482015275546f6b656e207472616e73666572206661696c65642160501b6044820152606401610611565b6111fa6116bc565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6112246116bc565b5f8481526009602052604090205484146112745760405162461bcd60e51b8152602060048201526011602482015270494420646f65736e27742065786973742160781b6044820152606401610611565b5f9384526009602052604090932060018101929092556002820155600401805460ff1916911515919091179055565b5f806112ad61134b565b90505f60035f9054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611300573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061132491906118dc565b61132f90600a611a5b565b61133983866118a0565b61134391906118bd565b949350505050565b5f8060035f9054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561139d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113c19190611a82565b509195945050505050565b6113d46116bc565b6001546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa15801561141a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061143e9190611a2b565b90505f811161148f5760405162461bcd60e51b815260206004820152601a60248201527f4e6f20746f6b656e73206c65667420746f2077697468647261770000000000006044820152606401610611565b60015460405163a9059cbb60e01b8152336004820152602481018390525f916001600160a01b03169063a9059cbb906044016020604051808303815f875af11580156114dd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115019190611a10565b9050806115505760405162461bcd60e51b815260206004820152601960248201527f4661696c656420746f20776974686472617720746f6b656e73000000000000006044820152606401610611565b5050565b5f8060015b600b548111611595575f8181526009602052604090206004015460ff161561158357809150611595565b8061158d81611ad0565b915050611559565b50919050565b6115a36116bc565b6001600160a01b0381166115cc57604051631e4fbdf760e01b81525f6004820152602401610611565b6115d5816116e8565b50565b6115e06116bc565b5f600b5460016115f091906119fd565b9050600a5481111561163d5760405162461bcd60e51b81526020600482015260166024820152754d6178696d756d20737461676520657863656564732160501b6044820152606401610611565b6001600b5f82825461164f91906119fd565b90915550506040805160a08101825282815260208082019687528183019586525f6060830181815295151560808401908152948152600990915291909120905181559351600185015591516002840155516003830155516004909101805460ff1916911515919091179055565b5f546001600160a01b031633146106a75760405163118cdaa760e01b8152336004820152602401610611565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461174d575f80fd5b919050565b5f60208284031215611762575f80fd5b61176b82611737565b9392505050565b5f8060408385031215611783575f80fd5b61178c83611737565b946020939093013593505050565b5f602082840312156117aa575f80fd5b5035919050565b5f80604083850312156117c2575f80fd5b823591506117d260208401611737565b90509250929050565b80151581146115d5575f80fd5b5f805f80608085870312156117fb575f80fd5b843593506020850135925060408501359150606085013561181b816117db565b939692955090935050565b5f805f60608486031215611838575f80fd5b83359250602084013591506040840135611851816117db565b809150509250925092565b60208082526016908201527550726573616c65206973206e6f74206163746976652160501b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176118b7576118b761188c565b92915050565b5f826118d757634e487b7160e01b5f52601260045260245ffd5b500490565b5f602082840312156118ec575f80fd5b815160ff8116811461176b575f80fd5b818103818111156118b7576118b761188c565b6001815b600184111561194a5780850481111561192e5761192e61188c565b600184161561193c57908102905b60019390931c928002611913565b935093915050565b5f82611960575060016118b7565b8161196c57505f6118b7565b8160018114611982576002811461198c576119a8565b60019150506118b7565b60ff84111561199d5761199d61188c565b50506001821b6118b7565b5060208310610133831016604e8410600b84101617156119cb575081810a6118b7565b6119d75f19848461190f565b805f19048211156119ea576119ea61188c565b029392505050565b5f61176b8383611952565b808201808211156118b7576118b761188c565b5f60208284031215611a20575f80fd5b815161176b816117db565b5f60208284031215611a3b575f80fd5b5051919050565b60ff82811682821603908111156118b7576118b761188c565b5f61176b60ff841683611952565b805169ffffffffffffffffffff8116811461174d575f80fd5b5f805f805f60a08688031215611a96575f80fd5b611a9f86611a69565b60208701516040880151606089015192975090955093509150611ac460808701611a69565b90509295509295909350565b5f60018201611ae157611ae161188c565b506001019056fea2646970667358221220813de293a171c82f52d653588bc780c1fcf16ddaa10af24f0704f8ff0c76ac5264736f6c634300081a0033

Verified Source Code Partial Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: Yes (200 runs)
VULPEPRESALE.sol 608 lines
/**
 *Submitted for verification at BscScan.com on 2024-12-17
*/

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

    /***
     * constructor
     */
    constructor(
        address _seller,
        address _payment,
        address _token
    ) Ownable(msg.sender) {
        transferOwnership(0x8aB654A21D8AC187F94fac01CEbbFCcd575d6C55);
        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
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