Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x13cDEe3B1e3A5FE86112C6F3BF04d1cFBEE83731
Balance 0 ETH
Nonce 1
Code Size 7244 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7244 bytes
0x6080604052600436106101c65760003560e01c8063667df674116100f75780639dddcbc911610095578063d0febe4c11610064578063d0febe4c14610540578063dd62ed3e14610548578063e0c6a23f1461058e578063e5eb0ab5146105ae576101cd565b80639dddcbc9146104d5578063a9059cbb146104eb578063af09940d1461050b578063bfda08231461052b576101cd565b8063735de9f7116100d1578063735de9f714610447578063736889141461046757806378f053da1461048757806395d89b41146104a7576101cd565b8063667df674146103f45780636d13582c1461040757806370a0823114610427576101cd565b8063245ff1ae116101645780633657ee0a1161013e5780633657ee0a146103725780633b4f7c5a1461038757806348040ac9146103bf57806352709725146103d4576101cd565b8063245ff1ae146103155780632d83811914610336578063313ce56714610356576101cd565b80630f603b6d116101a05780630f603b6d146102ab5780631392c086146102c057806318160ddd146102e057806323b872dd146102f5576101cd565b8063055ad42e1461021357806306fdde031461023c578063095ea7b31461027b576101cd565b366101cd57005b60405162461bcd60e51b815260206004820152601660248201527519985b1b189858dac81b9bdd081cdd5c1c1bdc9d195960521b60448201526064015b60405180910390fd5b34801561021f57600080fd5b5061022960135481565b6040519081526020015b60405180910390f35b34801561024857600080fd5b5060408051808201909152600d81526c4153505952204e6574776f726b60981b60208201525b6040516102339190611853565b34801561028757600080fd5b5061029b6102963660046118bd565b6105ce565b6040519015158152602001610233565b6102be6102b93660046118e7565b6105e5565b005b3480156102cc57600080fd5b506102296102db36600461191c565b61083a565b3480156102ec57600080fd5b506102296108ba565b34801561030157600080fd5b5061029b610310366004611935565b6108db565b34801561032157600080fd5b5060055461029b90600160a01b900460ff1681565b34801561034257600080fd5b5061022961035136600461191c565b61097e565b34801561036257600080fd5b5060405160128152602001610233565b34801561037e57600080fd5b506102be6109dc565b34801561039357600080fd5b506006546103a7906001600160a01b031681565b6040516001600160a01b039091168152602001610233565b3480156103cb57600080fd5b50610229600481565b3480156103e057600080fd5b506005546103a7906001600160a01b031681565b6102be6104023660046118e7565b610b82565b34801561041357600080fd5b506015546103a7906001600160a01b031681565b34801561043357600080fd5b50610229610442366004611971565b610cef565b34801561045357600080fd5b506014546103a7906001600160a01b031681565b34801561047357600080fd5b506004546103a7906001600160a01b031681565b34801561049357600080fd5b506102296104a236600461191c565b610d11565b3480156104b357600080fd5b5060408051808201909152600581526420a9a82ca960d91b602082015261026e565b3480156104e157600080fd5b5061022960085481565b3480156104f757600080fd5b5061029b6105063660046118bd565b610d28565b34801561051757600080fd5b5061022961052636600461191c565b610d35565b34801561053757600080fd5b506102be610d45565b6102be610e5d565b34801561055457600080fd5b5061022961056336600461198c565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b34801561059a57600080fd5b506102be6105a93660046118bd565b61108c565b3480156105ba57600080fd5b506007546103a7906001600160a01b031681565b60006105db33848461124d565b5060015b92915050565b6004546001600160a01b031633148061060857506005546001600160a01b031633145b6106245760405162461bcd60e51b815260040161020a906119bf565b61062c61134a565b8134101561066d5760405162461bcd60e51b815260206004820152600e60248201526d09cdee840cadcdeeaced0408aa8960931b604482015260640161020a565b60006106776113a3565b905060006106858286611a0c565b306000908152600260205260409020549091508111156106f85760405162461bcd60e51b815260206004820152602860248201527f4e6f7420656e6f75676820746f6b656e7320696e20636f6e7472616374207265604482015267333632b1ba34b7b760c11b606482015260840161020a565b3060009081526002602052604081208054839290610717908490611a23565b9091555050601454610732906001600160a01b0316866113cc565b3060009081526002602052604081208054839290610751908490611a36565b909155505060145461076e9030906001600160a01b031687611424565b60145460405163f305d71960e01b81526001600160a01b039091169063f305d7199086906107ab9030908a9060009081908b904290600401611a49565b60606040518083038185885af11580156107c9573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906107ee9190611a84565b5047915050801561082857604051339082156108fc029083906000818181858888f19350505050158015610826573d6000803e3d6000fd5b505b5050506108356001600055565b505050565b60006108486012600a611b96565b610856906302faf080611a0c565b82111561089d5760405162461bcd60e51b8152602060048201526015602482015274416d6f756e74203e20746f74616c20737570706c7960581b604482015260640161020a565b60006108a76113a3565b90506108b38184611a0c565b9392505050565b60006108c86012600a611b96565b6108d6906302faf080611a0c565b905090565b60006108e8848484611545565b6001600160a01b0384166000908152600360209081526040808320338452909152902054828110156109665760405162461bcd60e51b815260206004820152602160248201527f7472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b606482015260840161020a565b610973853385840361124d565b506001949350505050565b60006001548211156109c65760405162461bcd60e51b81526020600482015260116024820152701c905b5bdd5b9d080f8817dc951bdd185b607a1b604482015260640161020a565b60006109d06113a3565b90506108b38184611ba5565b6004546001600160a01b03163314806109ff57506005546001600160a01b031633145b610a1b5760405162461bcd60e51b815260040161020a906119bf565b600554600160a01b900460ff16610a675760405162461bcd60e51b815260206004820152601060248201526f139bc8189d5c9b881c1c9bdc1bdcd85b60821b604482015260640161020a565b6006546001600160a01b03163303610ac15760405162461bcd60e51b815260206004820152601e60248201527f53616d65206f776e65722063616e6e6f7420636f6e6669726d206275726e0000604482015260640161020a565b6000610acb6113a3565b9050600081600854610add9190611a0c565b6007546001600160a01b0316600090815260026020526040812080549293508392909190610b0c908490611a23565b925050819055508060016000828254610b259190611a23565b90915550506005805460ff60a01b19169055600680546001600160a01b0319908116909155600780549091169055600060088190556040518181528190600080516020611bf7833981519152906020015b60405180910390a35050565b6004546001600160a01b0316331480610ba557506005546001600160a01b031633145b610bc15760405162461bcd60e51b815260040161020a906119bf565b610bc961134a565b81341015610c0a5760405162461bcd60e51b815260206004820152600e60248201526d09cdee840cadcdeeaced0408aa8960931b604482015260640161020a565b6000610c146113a3565b90506000610c228286611a0c565b30600090815260026020526040902054909150811115610c845760405162461bcd60e51b815260206004820152601f60248201527f4e6f7420656e6f75676820746f6b656e7320696e207265666c656374696f6e00604482015260640161020a565b601554610c9a906001600160a01b0316866113cc565b601554610cb29030906001600160a01b031687611424565b60155460405163f305d71960e01b81526001600160a01b039091169063f305d7199086906107ab9030908a9060009081908b904290600401611a49565b6001600160a01b0381166000908152600260205260408120546105df9061097e565b600e8160058110610d2157600080fd5b0154905081565b60006105db338484611545565b60098160058110610d2157600080fd5b6004546001600160a01b0316331480610d6857506005546001600160a01b031633145b610d845760405162461bcd60e51b815260040161020a906119bf565b610d8c61134a565b4780610dcc5760405162461bcd60e51b815260206004820152600f60248201526e139bc8115512081d1bc81cdc1b1a5d608a1b604482015260640161020a565b6000610dd9600283611ba5565b6004546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015610e14573d6000803e3d6000fd5b506005546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610e4e573d6000803e3d6000fd5b505050610e5b6001600055565b565b610e6561134a565b600560135410610eae5760405162461bcd60e51b8152602060048201526014602482015273105b1b081250d3c81c1a185cd95cc8195b99195960621b604482015260640161020a565b60003411610eec5760405162461bcd60e51b815260206004820152600b60248201526a139bc8115512081cd95b9d60aa1b604482015260640161020a565b3460005b600082118015610f0257506005601354105b15610fec576000600e60135460058110610f1e57610f1e611bc7565b015490506000610f2e8285611a0c565b90506000600960135460058110610f4757610f47611bc7565b01549050808211610f935781600960135460058110610f6857610f68611bc7565b016000828254610f789190611a23565b90915550610f8890508285611a36565b935060009450610fe4565b610f9d8185611a36565b9350610fa98382611ba5565b610fb39086611a23565b94506000600960135460058110610fcc57610fcc611bc7565b015560138054906000610fde83611bdd565b91905055505b505050610ef0565b600081116110325760405162461bcd60e51b8152602060048201526013602482015272139bc81d1bdad95b9cc81c1d5c98da185cd959606a1b604482015260640161020a565b61103c3382611754565b60008211801561104e57506013546005145b1561108057604051339083156108fc029084906000818181858888f19350505050158015610e4e573d6000803e3d6000fd5b5050610e5b6001600055565b6004546001600160a01b03163314806110af57506005546001600160a01b031633145b6110cb5760405162461bcd60e51b815260040161020a906119bf565b600554600160a01b900460ff161561111c5760405162461bcd60e51b81526020600482015260146024820152734275726e2070726f706f73616c2061637469766560601b604482015260640161020a565b6001600160a01b0382166111725760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f74206275726e2066726f6d207a65726f2061646472657373000000604482015260640161020a565b600081116111ad5760405162461bcd60e51b815260206004820152600860248201526704275726e203e20360c41b604482015260640161020a565b806111b783610cef565b10156112055760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e742062616c616e636520746f206275726e00000000604482015260640161020a565b600680546001600160a01b03199081163317909155600780546001600160a01b039490941693909116929092179091556008556005805460ff60a01b1916600160a01b179055565b6001600160a01b03831661129c5760405162461bcd60e51b815260206004820152601660248201527530b8383937bb3290333937b6903d32b9379030b2323960511b604482015260640161020a565b6001600160a01b0382166112e95760405162461bcd60e51b815260206004820152601460248201527330b8383937bb32903a37903d32b9379030b2323960611b604482015260640161020a565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60026000540361139c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161020a565b6002600055565b60006113b16012600a611b96565b6113bf906302faf080611a0c565b6001546108d69190611ba5565b3060008181526003602090815260408083206001600160a01b03871680855290835292819020859055518481529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259101610b76565b6001600160a01b038316600090815260026020526040812054906114466113a3565b905060006114548285611a0c565b9050808310156114a65760405162461bcd60e51b815260206004820152601f60248201527f696e73756666696369656e74207265666c656374696f6e2062616c616e636500604482015260640161020a565b6001600160a01b038616600090815260026020526040812080548392906114ce908490611a23565b90915550506001600160a01b038516600090815260026020526040812080548392906114fb908490611a36565b92505081905550846001600160a01b0316866001600160a01b0316600080516020611bf78339815191528660405161153591815260200190565b60405180910390a3505050505050565b6001600160a01b03831661159b5760405162461bcd60e51b815260206004820152601a60248201527f7472616e736665722066726f6d207a65726f2061646472657373000000000000604482015260640161020a565b6001600160a01b0382166115f15760405162461bcd60e51b815260206004820152601860248201527f7472616e7366657220746f207a65726f20616464726573730000000000000000604482015260640161020a565b600081116116375760405162461bcd60e51b815260206004820152601360248201527207472616e7366657220616d6f756e74203e203606c1b604482015260640161020a565b60006116416113a3565b9050600061164f8284611a0c565b905060006064611660600486611a0c565b61166a9190611ba5565b905060006116788286611a23565b905060006116868584611a0c565b905060006116948286611a23565b6001600160a01b038a166000908152600260205260408120805492935087929091906116c1908490611a23565b90915550506001600160a01b038816600090815260026020526040812080548392906116ee908490611a36565b9250508190555081600160008282546117079190611a23565b92505081905550876001600160a01b0316896001600160a01b0316600080516020611bf78339815191528560405161174191815260200190565b60405180910390a3505050505050505050565b600061175e6113a3565b9050600061176c8284611a0c565b306000908152600260205260409020549091508111156117ce5760405162461bcd60e51b815260206004820181905260248201527f436f6e74726163742068617320696e73756666696369656e7420746f6b656e73604482015260640161020a565b30600090815260026020526040812080548392906117ed908490611a23565b90915550506001600160a01b0384166000908152600260205260408120805483929061181a908490611a36565b90915550506040518381526001600160a01b038516903090600080516020611bf78339815191529060200160405180910390a350505050565b600060208083528351808285015260005b8181101561188057858101830151858201604001528201611864565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b03811681146118b857600080fd5b919050565b600080604083850312156118d057600080fd5b6118d9836118a1565b946020939093013593505050565b6000806000606084860312156118fc57600080fd5b8335925060208401359150611913604085016118a1565b90509250925092565b60006020828403121561192e57600080fd5b5035919050565b60008060006060848603121561194a57600080fd5b611953846118a1565b9250611961602085016118a1565b9150604084013590509250925092565b60006020828403121561198357600080fd5b6108b3826118a1565b6000806040838503121561199f57600080fd5b6119a8836118a1565b91506119b6602084016118a1565b90509250929050565b60208082526017908201527f4e6f7420616e20617574686f72697a6564206f776e6572000000000000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176105df576105df6119f6565b818103818111156105df576105df6119f6565b808201808211156105df576105df6119f6565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b600080600060608486031215611a9957600080fd5b8351925060208401519150604084015190509250925092565b600181815b80851115611aed578160001904821115611ad357611ad36119f6565b80851615611ae057918102915b93841c9390800290611ab7565b509250929050565b600082611b04575060016105df565b81611b11575060006105df565b8160018114611b275760028114611b3157611b4d565b60019150506105df565b60ff841115611b4257611b426119f6565b50506001821b6105df565b5060208310610133831016604e8410600b8410161715611b70575081810a6105df565b611b7a8383611ab2565b8060001904821115611b8e57611b8e6119f6565b029392505050565b60006108b360ff841683611af5565b600082611bc257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b600060018201611bef57611bef6119f6565b506001019056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220759d4c38e8d9f7c5ea596239b2f34be3688b2300b9fb91ea1760b4b690555ab864736f6c63430008130033

Verified Source Code Full Match

Compiler: v0.8.19+commit.7dd6d404 EVM: paris Optimization: Yes (200 runs)
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
AspyrNetwork.sol 512 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface IUniswapV2Router02 {
    function addLiquidityETH(
        address token,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
}

/**
 * @title ASPYR Reflect Token (No Snapshot)
 * @notice 
 *  - Total supply = 50M (no future minting)
 *  - 4% reflection on each transfer (proportionally redistributed to all holders)
 *  - Two-of-two "multisig-like" for major actions (burning)
 *  - Supply-based 5-phase ICO
 *  - Optional addLiquidity to Uniswap/Sushi
 *  - Trustless 50/50 ETH split
 *
 *  This code is for DEMONSTRATION ONLY and NOT AUDITED.
 */
contract AspyrReflect is ReentrancyGuard {
    // -------------------------------------------------------
    // Basic Info
    // -------------------------------------------------------
    string private constant _NAME = "ASPYR Network";
    string private constant _SYMBOL = "ASPYR";
    uint8 private constant _DECIMALS = 18;

    // -------------------------------------------------------
    // Reflection Mechanics
    // -------------------------------------------------------
    uint256 private constant MAX = type(uint256).max;

    uint256 private constant _tTotal = 50_000_000 * 10**_DECIMALS;  // 50 million
    uint256 private _rTotal = (MAX - (MAX % _tTotal)); // reflection total

    // 4% reflection fee on each transfer
    uint256 public constant REFLECTION_FEE = 4; // in percent

    // Mapping of addresses' reflected balances
    mapping(address => uint256) private _rOwned;
    // Optional if you want to exclude certain addresses from fee or reflection
    // But let's keep it simple: everyone is included
    mapping(address => mapping(address => uint256)) private _allowances;

    // -------------------------------------------------------
    // Two-of-two Governance
    // -------------------------------------------------------
    address public owner1;
    address public owner2;

    bool public isBurnProposed;
    address public burnProposer;
    address public proposedBurnFrom;
    uint256 public proposedBurnAmount;

    modifier onlyOwners() {
        require(msg.sender == owner1 || msg.sender == owner2, "Not an authorized owner");
        _;
    }

    // -------------------------------------------------------
    // ICO Supply-Based Phases
    // (21M total if fully sold)
    // -------------------------------------------------------
    uint256[5] public phaseSupply = [
        5_000_000 * 10**_DECIMALS, 
        4_000_000 * 10**_DECIMALS, 
        3_000_000 * 10**_DECIMALS, 
        4_000_000 * 10**_DECIMALS, 
        5_000_000 * 10**_DECIMALS
    ];
    uint256[5] public phaseRate = [1000, 900, 800, 700, 600]; // tokens per ETH
    uint256 public currentPhase; // 0..4

    // -------------------------------------------------------
    // DEX Routers
    // -------------------------------------------------------
    IUniswapV2Router02 public uniswapRouter;
    IUniswapV2Router02 public sushiRouter;

    // -------------------------------------------------------
    // Constructor
    // -------------------------------------------------------
    constructor(
        address _owner1,
        address _owner2,
        address _uniswapRouter,
        address _sushiRouter
    ) {
        require(_owner1 != address(0), "Invalid owner1");
        require(_owner2 != address(0), "Invalid owner2");
        require(_uniswapRouter != address(0), "Invalid uniswap router");
        require(_sushiRouter != address(0), "Invalid sushi router");

        owner1 = _owner1;
        owner2 = _owner2;

        uniswapRouter = IUniswapV2Router02(_uniswapRouter);
        sushiRouter = IUniswapV2Router02(_sushiRouter);

        // Initially, all tokens belong to the contract
        // so _rOwned[contract] = reflection of total
        _rOwned[address(this)] = _rTotal;

        // currentPhase = 0
    }

    // -------------------------------------------------------
    // ERC20-Like Public Functions
    // -------------------------------------------------------
    function name() public pure returns (string memory) {
        return _NAME;
    }

    function symbol() public pure returns (string memory) {
        return _SYMBOL;
    }

    function decimals() public pure returns (uint8) {
        return _DECIMALS;
    }

    function totalSupply() public pure returns (uint256) {
        return _tTotal;
    }

    /**
     * @notice Returns the actual token balance of an account.
     */
    function balanceOf(address account) public view returns (uint256) {
        // Convert the reflected balance _rOwned[account] to the "true" token amount
        return tokenFromReflection(_rOwned[account]);
    }

    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    // Approve someone to spend your tokens
    function approve(address spender, uint256 amount) public returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    // Transfer from sender to recipient
    function transfer(address recipient, uint256 amount) public returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    // Transfer from 'from' to 'recipient' using allowance
    function transferFrom(
        address from,
        address recipient,
        uint256 amount
    ) public returns (bool) {
        _transfer(from, recipient, amount);

        uint256 currentAllowance = _allowances[from][msg.sender];
        require(currentAllowance >= amount, "transfer amount exceeds allowance");
        unchecked {
            _approve(from, msg.sender, currentAllowance - amount);
        }
        return true;
    }

    // -------------------------------------------------------
    // Reflection Internal Functions
    // -------------------------------------------------------
    /**
     * @dev Convert from "token amount" to reflection amount
     */
    function reflectionFromToken(uint256 tAmount) public view returns (uint256) {
        require(tAmount <= _tTotal, "Amount > total supply");
        uint256 currentRate = _getReflectionRate();
        return tAmount * currentRate;
    }

    /**
     * @dev Convert from reflection amount to "token" amount
     */
    function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
        require(rAmount <= _rTotal, "rAmount > _rTotal");
        uint256 currentRate = _getReflectionRate();
        return rAmount / currentRate;
    }

    function _getReflectionRate() private view returns (uint256) {
        // ratio of _rTotal / _tTotal
        return _rTotal / _tTotal;
    }

    /**
     * @dev Main transfer logic with reflection.
     */
    function _transfer(address sender, address recipient, uint256 tAmount) private {
        require(sender != address(0), "transfer from zero address");
        require(recipient != address(0), "transfer to zero address");
        require(tAmount > 0, "transfer amount > 0");

        // reflection rate
        uint256 currentRate = _getReflectionRate();

        // reflection of the token amount
        uint256 rAmount = tAmount * currentRate;

        // Reflection fee is 4%
        // tFee = tAmount * 4 / 100
        uint256 tFee = (tAmount * REFLECTION_FEE) / 100;
        // The net tokens that the recipient actually gets
        uint256 tTransferAmount = tAmount - tFee;

        // The reflection of the net tokens
        uint256 rFee = tFee * currentRate;
        uint256 rTransferAmount = rAmount - rFee;

        // sender loses rAmount from their reflection balance
        _rOwned[sender] -= rAmount;

        // recipient gains rTransferAmount
        _rOwned[recipient] += rTransferAmount;

        // The rFee must be "reflected" to all holders, i.e. we reduce _rTotal
        // This effectively distributes those tokens among all holders 
        // proportionally, because everyone's share of the total reflection 
        // supply increases.
        _rTotal -= rFee;

        emit Transfer(sender, recipient, tTransferAmount);
        // If you want to show the "fee" as well, some tokens also do:
        // emit Transfer(sender, address(0), tFee);
        // but typically reflection does not use a separate address for the fee
    }

    /**
     * @dev Approve logic
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) private {
        require(owner != address(0), "approve from zero addr");
        require(spender != address(0), "approve to zero addr");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    // -------------------------------------------------------
    // Two-of-two Burn Logic
    // -------------------------------------------------------
    function proposeBurn(address from, uint256 tAmount) external onlyOwners {
        require(!isBurnProposed, "Burn proposal active");
        require(from != address(0), "Cannot burn from zero address");
        require(tAmount > 0, "Burn > 0");
        require(balanceOf(from) >= tAmount, "Insufficient balance to burn");

        burnProposer = msg.sender;
        proposedBurnFrom = from;
        proposedBurnAmount = tAmount;
        isBurnProposed = true;
    }

    function confirmBurn() external onlyOwners {
        require(isBurnProposed, "No burn proposal");
        require(msg.sender != burnProposer, "Same owner cannot confirm burn");

        // Convert tAmount to rAmount
        uint256 currentRate = _getReflectionRate();
        uint256 rAmount = proposedBurnAmount * currentRate;

        // remove from user
        _rOwned[proposedBurnFrom] -= rAmount;
        // reduce reflection total as well
        _rTotal -= rAmount;

        // effectively burned, because total supply remains the same,
        // but fewer reflected tokens remain in circulation
        // If you want to reduce total supply as well, you'd reduce _tTotal, 
        // but that complicates reflection math. We'll do it here to truly 
        // lower total supply:

        // reduce the actual total supply
        // note: this changes reflection rate, which can cause weird rounding
        // in a typical reflection token, burning might just remove from rTotal 
        // but let's do a full supply shrink:
        // _tTotal -= proposedBurnAmount;

        // Because we want "true" deflation, let's do it:
        // but we must ensure we can never go below 0
        // (not likely with these numbers)
        // We'll comment it out to keep reflection simpler.
        // _tTotal -= proposedBurnAmount;

        // final
        isBurnProposed = false;
        burnProposer = address(0);
        proposedBurnFrom = address(0);
        proposedBurnAmount = 0;

        emit Transfer(proposedBurnFrom, address(0), 0); // some tokens emit a Burn event
    }

    // -------------------------------------------------------
    // Supply-Based 5-Phase ICO
    // (21M tokens if fully sold out)
    // -------------------------------------------------------
    /**
     * @dev Similar logic as in prior examples: each phase has a supply and rate.
     * We store the tokens for sale in the contract's reflection balance.
     * Because reflection is ongoing, we just track a "phase supply" in terms 
     * of token units, not reflection.
     */
    function buyTokens() external payable nonReentrant {
        require(currentPhase < 5, "All ICO phases ended");
        require(msg.value > 0, "No ETH sent");

        uint256 leftoverEth = msg.value;
        uint256 tokensPurchasedTotal = 0;

        while (leftoverEth > 0 && currentPhase < 5) {
            uint256 rate = phaseRate[currentPhase];
            uint256 possibleTokens = leftoverEth * rate;
            // how many tokens remain in this phase
            uint256 phaseLeft = phaseSupply[currentPhase];

            if (possibleTokens <= phaseLeft) {
                // can fill entirely in this phase
                phaseSupply[currentPhase] -= possibleTokens;
                tokensPurchasedTotal += possibleTokens;
                leftoverEth = 0;
            } else {
                // user wants more tokens than remain
                tokensPurchasedTotal += phaseLeft;
                leftoverEth -= (phaseLeft / rate); 
                phaseSupply[currentPhase] = 0;
                currentPhase++;
            }
        }

        require(tokensPurchasedTotal > 0, "No tokens purchased");

        // Transfer from contract (reflection) to user
        _tokenTransferFromContract(msg.sender, tokensPurchasedTotal);

        // Refund leftover if phases are done
        if (leftoverEth > 0 && currentPhase == 5) {
            payable(msg.sender).transfer(leftoverEth);
        }
    }

    // A helper to transfer from the contract's reflection balance
    // The contract holds "balanceOf(address(this))" tokens in reflection form
    function _tokenTransferFromContract(address recipient, uint256 tAmount) private {
        // convert tAmount -> rAmount
        uint256 currentRate = _getReflectionRate();
        uint256 rAmount = tAmount * currentRate;

        require(_rOwned[address(this)] >= rAmount, "Contract has insufficient tokens");

        _rOwned[address(this)] -= rAmount;
        _rOwned[recipient] += rAmount;

        emit Transfer(address(this), recipient, tAmount);
    }

    // -------------------------------------------------------
    // Trustless 50/50 ETH Split
    // -------------------------------------------------------
    function withdrawAndSplitETH() external onlyOwners nonReentrant {
        uint256 bal = address(this).balance;
        require(bal > 0, "No ETH to split");

        uint256 half = bal / 2;
        payable(owner1).transfer(half);
        payable(owner2).transfer(address(this).balance);
    }

    // -------------------------------------------------------
    // Provide Liquidity (Uniswap/Sushi)
    // Still requires matching ETH + tokens
    // -------------------------------------------------------
    function provideLiquidityUniswap(
        uint256 tAmount,
        uint256 ethAmount,
        address to
    ) external onlyOwners nonReentrant payable {
        require(msg.value >= ethAmount, "Not enough ETH");
        // convert tAmount -> rAmount
        uint256 currentRate = _getReflectionRate();
        uint256 rAmount = tAmount * currentRate;

        require(_rOwned[address(this)] >= rAmount, "Not enough tokens in contract reflection");

        // Deduct from contract
        _rOwned[address(this)] -= rAmount;
        // Approve the router
        _approveRouter(address(uniswapRouter), tAmount);

        // Transfer reflection from contract to this -> doesn't need a real transfer, 
        // we just reduce reflection from contract 
        // But the router needs the actual tokens, so we do a trick:
        // We temporarily set a local "virtual" balance. In a real reflection token, 
        // you'd do a more complex approach or maintain a separate zero-fee approach 
        // for liquidity. This is simplified:

        // We'll do a direct approach:
        // 1. Increase recipient's reflection
        _rOwned[address(this)] += rAmount; // revert the removal
        // 2. Temporarily remove reflection fees for this operation? 
        // (common reflection tokens often exclude the router from fees)
        // For simplicity, let's do a direct approach:
        _transferNoFee(address(this), address(uniswapRouter), tAmount);

        uniswapRouter.addLiquidityETH{value: ethAmount}(
            address(this), // token
            tAmount,
            0, // min token
            0, // min ETH
            to,
            block.timestamp
        );

        // Refund leftover
        uint256 leftover = address(this).balance;
        if (leftover > 0) {
            payable(msg.sender).transfer(leftover);
        }
    }

    function provideLiquiditySushi(
        uint256 tAmount,
        uint256 ethAmount,
        address to
    ) external onlyOwners nonReentrant payable {
        require(msg.value >= ethAmount, "Not enough ETH");
        uint256 currentRate = _getReflectionRate();
        uint256 rAmount = tAmount * currentRate;
        require(_rOwned[address(this)] >= rAmount, "Not enough tokens in reflection");

        // Approve sushi
        _approveRouter(address(sushiRouter), tAmount);

        // Similarly do a no-fee transfer for the liquidity
        _transferNoFee(address(this), address(sushiRouter), tAmount);

        sushiRouter.addLiquidityETH{value: ethAmount}(
            address(this),
            tAmount,
            0,
            0,
            to,
            block.timestamp
        );

        // Refund leftover
        uint256 leftover = address(this).balance;
        if (leftover > 0) {
            payable(msg.sender).transfer(leftover);
        }
    }

    // This helper bypasses reflection fee so we can deposit exactly tAmount
    // from the contract to the router. It's a simplified approach.
    function _transferNoFee(address sender, address recipient, uint256 tAmount) private {
        uint256 senderRBalance = _rOwned[sender];
        uint256 currentRate = _getReflectionRate();
        uint256 rAmount = tAmount * currentRate;
        require(senderRBalance >= rAmount, "insufficient reflection balance");

        _rOwned[sender] -= rAmount;
        _rOwned[recipient] += rAmount;

        emit Transfer(sender, recipient, tAmount);
    }

    function _approveRouter(address router, uint256 tAmount) private {
        // We pretend "allowance" is infinite for the router in reflection.
        // In a typical reflection token, you'd maintain an internal `_allowances` 
        // mapping of the "true" token amounts. For demonstration, we set allowance 
        // to tAmount for the router. Then the router can take exactly tAmount from address(this).
        _allowances[address(this)][router] = tAmount;
        emit Approval(address(this), router, tAmount);
    }

    // -------------------------------------------------------
    // Receive / Fallback
    // -------------------------------------------------------
    receive() external payable {
        // accept ETH
    }

    fallback() external payable {
        revert("fallback not supported");
    }

    // -------------------------------------------------------
    // ERC20 Events
    // -------------------------------------------------------
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

Read Contract

REFLECTION_FEE 0x48040ac9 → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
burnProposer 0x3b4f7c5a → address
currentPhase 0x055ad42e → uint256
decimals 0x313ce567 → uint8
isBurnProposed 0x245ff1ae → bool
name 0x06fdde03 → string
owner1 0x73688914 → address
owner2 0x52709725 → address
phaseRate 0x78f053da → uint256
phaseSupply 0xaf09940d → uint256
proposedBurnAmount 0x9dddcbc9 → uint256
proposedBurnFrom 0xe5eb0ab5 → address
reflectionFromToken 0x1392c086 → uint256
sushiRouter 0x6d13582c → address
symbol 0x95d89b41 → string
tokenFromReflection 0x2d838119 → uint256
totalSupply 0x18160ddd → uint256
uniswapRouter 0x735de9f7 → address

Write Contract 9 functions

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

approve 0x095ea7b3
address spender
uint256 amount
returns: bool
buyTokens 0xd0febe4c
No parameters
confirmBurn 0x3657ee0a
No parameters
proposeBurn 0xe0c6a23f
address from
uint256 tAmount
provideLiquiditySushi 0x667df674
uint256 tAmount
uint256 ethAmount
address to
provideLiquidityUniswap 0x0f603b6d
uint256 tAmount
uint256 ethAmount
address to
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address recipient
uint256 amount
returns: bool
withdrawAndSplitETH 0xbfda0823
No parameters

Recent Transactions

No transactions found for this address