ETH Price: $2,426.79 (+7.39%)

Transaction Decoder

Block:
6477158 at Oct-08-2018 02:48:10 PM +UTC
Transaction Fee:
0.00317899 ETH $7.71
Gas Used:
317,899 Gas / 10 Gwei

Emitted Events:

2 DailyDivs.onWithdraw( customerAddress=[Sender] 0x153bc08693246176462e0599eecde10144cb66b4, ethereumWithdrawn=281903285172 )
3 DailyDivs.Transfer( from=[Sender] 0x153bc08693246176462e0599eecde10144cb66b4, to=0x40D9c0C86d59d5c520A7f75220543FaF197A48Ea, tokens=12000000000000000000 )
4 DailyDivs.Transfer( from=0x40D9c0C86d59d5c520A7f75220543FaF197A48Ea, to=0xE7852F4efdE0671bc3AC02f25B3e864054649e0f, tokens=12000000000000000000 )
5 DailyDivs.onTokenPurchase( customerAddress=0xE7852F4efdE0671bc3AC02f25B3e864054649e0f, incomingEthereum=100032636179883, tokensMinted=97489356026814746, referredBy=0x00000000...000000000 )
6 DailyDivs.onReinvestment( customerAddress=0xE7852F4efdE0671bc3AC02f25B3e864054649e0f, ethereumReinvested=100032636179883, tokensMinted=97489356026814746 )
7 Oraclize.0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84( 0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84, 000000000000000000000000e7852f4efde0671bc3ac02f25b3e864054649e0f, afebfa20cded217029761d9a65335abbaeb85203c0ababd512281b0ee25f60d7, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000100, 0000000000000000000000000000000000000000000000000000000000000140, 00000000000000000000000000000000000000000000000000000000000249f0, 0000000000000000000000000000000000000000000000000000000000000000, 00000000000000000000000000000000000000000000000000000003b9aca000, 0000000000000000000000000000000000000000000000000000000000000003, 55524c0000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000049, 6a736f6e2868747470733a2f2f6d696e2d6170692e63727970746f636f6d7061, 72652e636f6d2f646174612f70726963653f6673796d3d585250267473796d73, 3d555344292e5553440000000000000000000000000000000000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
(2Miners: SOLO)
26.835871640753512005 Eth26.839050630753512005 Eth0.00317899
0x153bc086...144cB66b4
0.3866842005 Eth
Nonce: 40
0.383505492403285172 Eth
Nonce: 41
0.003178708096714828
0x3dBDc81a...e395fDcf6 37.12916441420888718 Eth37.13161002216291436 Eth0.00244560795402718
0x41cd7BBA...66f2B1F0e 0.021590585505616808 Eth0.021590303602331636 Eth0.000000281903285172
0xE7852F4e...054649e0f 0.234403314695376359 Eth0.231957706741349179 Eth0.00244560795402718

Execution Trace

DailyDivs.transferAndCall( _to=0x40D9c0C86d59d5c520A7f75220543FaF197A48Ea, _value=12000000000000000000, _data=0x02 ) => ( True )
  • ETH 0.000000281903285172 0x153bc08693246176462e0599eecde10144cb66b4.CALL( )
  • 0x40d9c0c86d59d5c520a7f75220543faf197a48ea.c0ee0b8a( )
    • 0xe7852f4efde0671bc3ac02f25b3e864054649e0f.CALL( )
    • DailyDivs.transfer( _toAddress=0xE7852F4efdE0671bc3AC02f25B3e864054649e0f, _amountOfTokens=12000000000000000000 ) => ( True )
    • 0xe7852f4efde0671bc3ac02f25b3e864054649e0f.2c62c181( )
      • DailyDivs.myDividends( _includeReferralBonus=True ) => ( 100032636179883 )
      • DailyDivs.CALL( )
      • OraclizeAddrResolver.CALL( )
      • Oraclize.2ef3accc( )
      • ETH 0.00244560795402718 Oraclize.c51be90f( )
        File 1 of 3: DailyDivs
        pragma solidity ^0.4.21;
        
        /*
        ******************** DailyDivs.com *********************
        *
        *  ____        _ _       ____  _                                
        * |  _ \  __ _(_) |_   _|  _ \(_)_   _____   ___ ___  _ __ ___  
        * | | | |/ _` | | | | | | | | | \ \ / / __| / __/ _ \| '_ ` _ \ 
        * | |_| | (_| | | | |_| | |_| | |\ V /\__ \| (_| (_) | | | | | |
        * |____/ \__,_|_|_|\__, |____/|_| \_/ |___(_)___\___/|_| |_| |_|
        *                  |___/                                        
        *
        ******************** DailyDivs.com *********************
        *
        *
        * [x] 0% TRANSFER FEES
        * [x] 20% DIVIDENDS AND MASTERNODES
        * [x] Multi-tier Masternode system 50% 1st ref 30% 2nd ref 20% 3rd ref
        * [x] 5% FEE ON EACH BUY AND SELL GO TO Smart Contract Fund 0xF34340Ba65f37320B25F9f6F3978D02DDc13283b
        *     5% Split -> 70% to Earn Game / 30% to Dev Fund For Future Development Costs
        * [x] DailyDivs Token can be used for future games
        *
        * Official Website: https://dailydivs.com/ 
        * Official Discord: https://discord.gg/J4Bvu32
        * Official Telegram: https://t.me/dailydivs
        */
        
        
        /**
         * Definition of contract accepting DailyDivs tokens
         * Games, casinos, anything can reuse this contract to support DailyDivs tokens
         */
        contract AcceptsDailyDivs {
            DailyDivs public tokenContract;
        
            function AcceptsDailyDivs(address _tokenContract) public {
                tokenContract = DailyDivs(_tokenContract);
            }
        
            modifier onlyTokenContract {
                require(msg.sender == address(tokenContract));
                _;
            }
        
            /**
            * @dev Standard ERC677 function that will handle incoming token transfers.
            *
            * @param _from  Token sender address.
            * @param _value Amount of tokens.
            * @param _data  Transaction metadata.
            */
            function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool);
        }
        
        
        contract DailyDivs {
            /*=================================
            =            MODIFIERS            =
            =================================*/
            // only people with tokens
            modifier onlyBagholders() {
                require(myTokens() > 0);
                _;
            }
        
            // only people with profits
            modifier onlyStronghands() {
                require(myDividends(true) > 0);
                _;
            }
        
            modifier notContract() {
              require (msg.sender == tx.origin);
              _;
            }
        
            // administrators can:
            // -> change the name of the contract
            // -> change the name of the token
            // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later)
            // they CANNOT:
            // -> take funds
            // -> disable withdrawals
            // -> kill the contract
            // -> change the price of tokens
            modifier onlyAdministrator(){
                address _customerAddress = msg.sender;
                require(administrators[_customerAddress]);
                _;
            }
            
            uint ACTIVATION_TIME = 1535835600;
        
        
            // ensures that the first tokens in the contract will be equally distributed
            // meaning, no divine dump will be ever possible
            // result: healthy longevity.
            modifier antiEarlyWhale(uint256 _amountOfEthereum){
                address _customerAddress = msg.sender;
                
                if (now >= ACTIVATION_TIME) {
                    onlyAmbassadors = false;
                }
        
                // are we still in the vulnerable phase?
                // if so, enact anti early whale protocol
                if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){
                    require(
                        // is the customer in the ambassador list?
                        ambassadors_[_customerAddress] == true &&
        
                        // does the customer purchase exceed the max ambassador quota?
                        (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_
        
                    );
        
                    // updated the accumulated quota
                    ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum);
        
                    // execute
                    _;
                } else {
                    // in case the ether count drops low, the ambassador phase won't reinitiate
                    onlyAmbassadors = false;
                    _;
                }
        
            }
        
            /*==============================
            =            EVENTS            =
            ==============================*/
            event onTokenPurchase(
                address indexed customerAddress,
                uint256 incomingEthereum,
                uint256 tokensMinted,
                address indexed referredBy
            );
        
            event onTokenSell(
                address indexed customerAddress,
                uint256 tokensBurned,
                uint256 ethereumEarned
            );
        
            event onReinvestment(
                address indexed customerAddress,
                uint256 ethereumReinvested,
                uint256 tokensMinted
            );
        
            event onWithdraw(
                address indexed customerAddress,
                uint256 ethereumWithdrawn
            );
        
            // ERC20
            event Transfer(
                address indexed from,
                address indexed to,
                uint256 tokens
            );
        
        
            /*=====================================
            =            CONFIGURABLES            =
            =====================================*/
            string public name = "DailyDivs";
            string public symbol = "DDT";
            uint8 constant public decimals = 18;
            uint8 constant internal dividendFee_ = 20; // 20% dividend fee on each buy and sell
            uint8 constant internal fundFee_ = 5; // 5% investment fund fee on each buy and sell
            uint256 constant internal tokenPriceInitial_ = 0.00000001 ether;
            uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether;
            uint256 constant internal magnitude = 2**64;
        
            // Address to send the 5% Fee
            //  70% to Earn Game / 30% to Dev Fund
            // https://etherscan.io/address/0xF34340Ba65f37320B25F9f6F3978D02DDc13283b
            address constant public giveEthFundAddress = 0xF34340Ba65f37320B25F9f6F3978D02DDc13283b;
            uint256 public totalEthFundRecieved; // total ETH charity recieved from this contract
            uint256 public totalEthFundCollected; // total ETH charity collected in this contract
        
            // proof of stake (defaults at 100 tokens)
            uint256 public stakingRequirement = 25e18;
        
            // ambassador program
            mapping(address => bool) internal ambassadors_;
            uint256 constant internal ambassadorMaxPurchase_ = 2.5 ether;
            uint256 constant internal ambassadorQuota_ = 2.5 ether;
        
        
        
           /*================================
            =            DATASETS            =
            ================================*/
            // amount of shares for each address (scaled number)
            mapping(address => uint256) internal tokenBalanceLedger_;
            mapping(address => uint256) internal referralBalance_;
            mapping(address => int256) internal payoutsTo_;
            mapping(address => uint256) internal ambassadorAccumulatedQuota_;
            uint256 internal tokenSupply_ = 0;
            uint256 internal profitPerShare_;
        
            // administrator list (see above on what they can do)
            mapping(address => bool) public administrators;
        
            // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid)
            bool public onlyAmbassadors = true;
        
            // Special DailyDivs Platform control from scam game contracts on DailyDivs platform
            mapping(address => bool) public canAcceptTokens_; // contracts, which can accept DailyDivs tokens
        
            mapping(address => address) public stickyRef;
        
            /*=======================================
            =            PUBLIC FUNCTIONS            =
            =======================================*/
            /*
            * -- APPLICATION ENTRY POINTS --
            */
            function DailyDivs()
                public
            {
                // add administrators here
                administrators[0x5e4edd4b711eCe01400067dc3Ec564aed42Ed5b5] = true;
        
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x5e4edd4b711eCe01400067dc3Ec564aed42Ed5b5] = true;
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x12b353d1a2842d2272ab5a18c6814d69f4296873] = true;
               // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x87A7e71D145187eE9aAdc86954d39cf0e9446751] = true;
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x41FE3738B503cBaFD01C1Fd8DD66b7fE6Ec11b01] = true;
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x5632ca98e5788eddb2397757aa82d1ed6171e5ad] = true;
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                ambassadors_[0x0A49857F69919AEcddbA77136364Bb19108B4891] = true;
                // add the ambassadors here - Tokens will be distributed to these addresses from main premine
                    ambassadors_[0xdb59f29f7242989a3eda271483b89e1f74353ffa] = true;
                
            }
        
        
            /**
             * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any)
             */
            function buy(address _referredBy)
                public
                payable
                returns(uint256)
            {
                
                require(tx.gasprice <= 0.05 szabo);
                purchaseTokens(msg.value, _referredBy);
            }
        
            /**
             * Fallback function to handle ethereum that was send straight to the contract
             * Unfortunately we cannot use a referral address this way.
             */
            function()
                payable
                public
            {
                
                require(tx.gasprice <= 0.05 szabo);
                purchaseTokens(msg.value, 0x0);
            }
        
            /**
             * Sends FUND money to the 70/30 Contract
             * The address is here https://etherscan.io/address/0xF34340Ba65f37320B25F9f6F3978D02DDc13283b
             */
            function payFund() payable public {
              uint256 ethToPay = SafeMath.sub(totalEthFundCollected, totalEthFundRecieved);
              require(ethToPay > 1);
              totalEthFundRecieved = SafeMath.add(totalEthFundRecieved, ethToPay);
              if(!giveEthFundAddress.call.value(ethToPay).gas(400000)()) {
                 totalEthFundRecieved = SafeMath.sub(totalEthFundRecieved, ethToPay);
              }
            }
        
            /**
             * Converts all of caller's dividends to tokens.
             */
            function reinvest()
                onlyStronghands()
                public
            {
                // fetch dividends
                uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code
        
                // pay out the dividends virtually
                address _customerAddress = msg.sender;
                payoutsTo_[_customerAddress] +=  (int256) (_dividends * magnitude);
        
                // retrieve ref. bonus
                _dividends += referralBalance_[_customerAddress];
                referralBalance_[_customerAddress] = 0;
        
                // dispatch a buy order with the virtualized "withdrawn dividends"
                uint256 _tokens = purchaseTokens(_dividends, 0x0);
        
                // fire event
                onReinvestment(_customerAddress, _dividends, _tokens);
            }
        
            /**
             * Alias of sell() and withdraw().
             */
            function exit()
                public
            {
                // get token count for caller & sell them all
                address _customerAddress = msg.sender;
                uint256 _tokens = tokenBalanceLedger_[_customerAddress];
                if(_tokens > 0) sell(_tokens);
        
                // lambo delivery service
                withdraw();
            }
        
            /**
             * Withdraws all of the callers earnings.
             */
            function withdraw()
                onlyStronghands()
                public
            {
                // setup data
                address _customerAddress = msg.sender;
                uint256 _dividends = myDividends(false); // get ref. bonus later in the code
        
                // update dividend tracker
                payoutsTo_[_customerAddress] +=  (int256) (_dividends * magnitude);
        
                // add ref. bonus
                _dividends += referralBalance_[_customerAddress];
                referralBalance_[_customerAddress] = 0;
        
                // lambo delivery service
                _customerAddress.transfer(_dividends);
        
                // fire event
                onWithdraw(_customerAddress, _dividends);
            }
        
            /**
             * Liquifies tokens to ethereum.
             */
            function sell(uint256 _amountOfTokens)
                onlyBagholders()
                public
            {
                // setup data
                address _customerAddress = msg.sender;
                // russian hackers BTFO
                require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
                uint256 _tokens = _amountOfTokens;
                uint256 _ethereum = tokensToEthereum_(_tokens);
        
                uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100);
                uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100);
                uint256 _refPayout = _dividends / 3;
                _dividends = SafeMath.sub(_dividends, _refPayout);
                (_dividends,) = handleRef(stickyRef[msg.sender], _refPayout, _dividends, 0);
        
                // Take out dividends and then _fundPayout
                uint256 _taxedEthereum =  SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout);
        
                // Add ethereum to send to fund
                totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout);
        
                // burn the sold tokens
                tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens);
                tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens);
        
                // update dividends tracker
                int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude));
                payoutsTo_[_customerAddress] -= _updatedPayouts;
        
                // dividing by zero is a bad idea
                if (tokenSupply_ > 0) {
                    // update the amount of dividends per token
                    profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
                }
        
                // fire event
                onTokenSell(_customerAddress, _tokens, _taxedEthereum);
            }
        
        
            /**
             * Transfer tokens from the caller to a new holder.
             * REMEMBER THIS IS 0% TRANSFER FEE
             */
            function transfer(address _toAddress, uint256 _amountOfTokens)
                onlyBagholders()
                public
                returns(bool)
            {
                // setup
                address _customerAddress = msg.sender;
        
                // make sure we have the requested tokens
                // also disables transfers until ambassador phase is over
                // ( we dont want whale premines )
                require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
        
                // withdraw all outstanding dividends first
                if(myDividends(true) > 0) withdraw();
        
                // exchange tokens
                tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
                tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens);
        
                // update dividend trackers
                payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
                payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens);
        
        
                // fire event
                Transfer(_customerAddress, _toAddress, _amountOfTokens);
        
                // ERC20
                return true;
            }
        
            /**
            * Transfer token to a specified address and forward the data to recipient
            * ERC-677 standard
            * https://github.com/ethereum/EIPs/issues/677
            * @param _to    Receiver address.
            * @param _value Amount of tokens that will be transferred.
            * @param _data  Transaction metadata.
            */
            function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) {
              require(_to != address(0));
              require(canAcceptTokens_[_to] == true); // security check that contract approved by DailyDivs platform
              require(transfer(_to, _value)); // do a normal token transfer to the contract
        
              if (isContract(_to)) {
                AcceptsDailyDivs receiver = AcceptsDailyDivs(_to);
                require(receiver.tokenFallback(msg.sender, _value, _data));
              }
        
              return true;
            }
        
            /**
             * Additional check that the game address we are sending tokens to is a contract
             * assemble the given address bytecode. If bytecode exists then the _addr is a contract.
             */
             function isContract(address _addr) private constant returns (bool is_contract) {
               // retrieve the size of the code on target address, this needs assembly
               uint length;
               assembly { length := extcodesize(_addr) }
               return length > 0;
             }
        
            /*----------  ADMINISTRATOR ONLY FUNCTIONS  ----------*/
            /**
             * In case the amassador quota is not met, the administrator can manually disable the ambassador phase.
             */
            //function disableInitialStage()
            //    onlyAdministrator()
            //    public
            //{
            //    onlyAmbassadors = false;
            //}
        
            /**
             * In case one of us dies, we need to replace ourselves.
             */
            function setAdministrator(address _identifier, bool _status)
                onlyAdministrator()
                public
            {
                administrators[_identifier] = _status;
            }
        
            /**
             * Precautionary measures in case we need to adjust the masternode rate.
             */
            function setStakingRequirement(uint256 _amountOfTokens)
                onlyAdministrator()
                public
            {
                stakingRequirement = _amountOfTokens;
            }
        
            /**
             * Add or remove game contract, which can accept DailyDivs tokens
             */
            function setCanAcceptTokens(address _address, bool _value)
              onlyAdministrator()
              public
            {
              canAcceptTokens_[_address] = _value;
            }
        
            /**
             * If we want to rebrand, we can.
             */
            function setName(string _name)
                onlyAdministrator()
                public
            {
                name = _name;
            }
        
            /**
             * If we want to rebrand, we can.
             */
            function setSymbol(string _symbol)
                onlyAdministrator()
                public
            {
                symbol = _symbol;
            }
        
        
            /*----------  HELPERS AND CALCULATORS  ----------*/
            /**
             * Method to view the current Ethereum stored in the contract
             * Example: totalEthereumBalance()
             */
            function totalEthereumBalance()
                public
                view
                returns(uint)
            {
                return this.balance;
            }
        
            /**
             * Retrieve the total token supply.
             */
            function totalSupply()
                public
                view
                returns(uint256)
            {
                return tokenSupply_;
            }
        
            /**
             * Retrieve the tokens owned by the caller.
             */
            function myTokens()
                public
                view
                returns(uint256)
            {
                address _customerAddress = msg.sender;
                return balanceOf(_customerAddress);
            }
        
            /**
             * Retrieve the dividends owned by the caller.
             * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations.
             * The reason for this, is that in the frontend, we will want to get the total divs (global + ref)
             * But in the internal calculations, we want them separate.
             */
            function myDividends(bool _includeReferralBonus)
                public
                view
                returns(uint256)
            {
                address _customerAddress = msg.sender;
                return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
            }
        
            /**
             * Retrieve the token balance of any single address.
             */
            function balanceOf(address _customerAddress)
                view
                public
                returns(uint256)
            {
                return tokenBalanceLedger_[_customerAddress];
            }
        
            /**
             * Retrieve the dividend balance of any single address.
             */
            function dividendsOf(address _customerAddress)
                view
                public
                returns(uint256)
            {
                return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
            }
        
            /**
             * Return the buy price of 1 individual token.
             */
            function sellPrice()
                public
                view
                returns(uint256)
            {
                // our calculation relies on the token supply, so we need supply. Doh.
                if(tokenSupply_ == 0){
                    return tokenPriceInitial_ - tokenPriceIncremental_;
                } else {
                    uint256 _ethereum = tokensToEthereum_(1e18);
                    uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100);
                    uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100);
                    uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout);
                    return _taxedEthereum;
                }
            }
        
            /**
             * Return the sell price of 1 individual token.
             */
            function buyPrice()
                public
                view
                returns(uint256)
            {
                // our calculation relies on the token supply, so we need supply. Doh.
                if(tokenSupply_ == 0){
                    return tokenPriceInitial_ + tokenPriceIncremental_;
                } else {
                    uint256 _ethereum = tokensToEthereum_(1e18);
                    uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100);
                    uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100);
                    uint256 _taxedEthereum =  SafeMath.add(SafeMath.add(_ethereum, _dividends), _fundPayout);
                    return _taxedEthereum;
                }
            }
        
            /**
             * Function for the frontend to dynamically retrieve the price scaling of buy orders.
             */
            function calculateTokensReceived(uint256 _ethereumToSpend)
                public
                view
                returns(uint256)
            {
                uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100);
                uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, fundFee_), 100);
                uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _fundPayout);
                uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
                return _amountOfTokens;
            }
        
            /**
             * Function for the frontend to dynamically retrieve the price scaling of sell orders.
             */
            function calculateEthereumReceived(uint256 _tokensToSell)
                public
                view
                returns(uint256)
            {
                require(_tokensToSell <= tokenSupply_);
                uint256 _ethereum = tokensToEthereum_(_tokensToSell);
                uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100);
                uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100);
                uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout);
                return _taxedEthereum;
            }
        
            /**
             * Function for the frontend to show ether waiting to be send to fund in contract
             */
            function etherToSendFund()
                public
                view
                returns(uint256) {
                return SafeMath.sub(totalEthFundCollected, totalEthFundRecieved);
            }
        
        
            /*==========================================
            =            INTERNAL FUNCTIONS            =
            ==========================================*/
        
            // Make sure we will send back excess if user sends more then 5 ether before 100 ETH in contract
            function purchaseInternal(uint256 _incomingEthereum, address _referredBy)
              notContract()// no contracts allowed
              internal
              returns(uint256) {
        
              uint256 purchaseEthereum = _incomingEthereum;
              uint256 excess;
              if(purchaseEthereum > 2.5 ether) { // check if the transaction is over 2.5 ether
                  if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { // if so check the contract is less then 100 ether
                      purchaseEthereum = 2.5 ether;
                      excess = SafeMath.sub(_incomingEthereum, purchaseEthereum);
                  }
              }
        
              purchaseTokens(purchaseEthereum, _referredBy);
        
              if (excess > 0) {
                msg.sender.transfer(excess);
              }
            }
        
            function handleRef(address _ref, uint _referralBonus, uint _currentDividends, uint _currentFee) internal returns (uint, uint){
                uint _dividends = _currentDividends;
                uint _fee = _currentFee;
                address _referredBy = stickyRef[msg.sender];
                if (_referredBy == address(0x0)){
                    _referredBy = _ref;
                }
                // is the user referred by a masternode?
                if(
                    // is this a referred purchase?
                    _referredBy != 0x0000000000000000000000000000000000000000 &&
        
                    // no cheating!
                    _referredBy != msg.sender &&
        
                    // does the referrer have at least X whole tokens?
                    // i.e is the referrer a godly chad masternode
                    tokenBalanceLedger_[_referredBy] >= stakingRequirement
                ){
                    // wealth redistribution
                    if (stickyRef[msg.sender] == address(0x0)){
                        stickyRef[msg.sender] = _referredBy;
                    }
                    referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus/2);
                    address currentRef = stickyRef[_referredBy];
                    if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){
                        referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*3);
                        currentRef = stickyRef[currentRef];
                        if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){
                            referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*2);
                        }
                        else{
                            _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2 - (_referralBonus/10)*3);
                            _fee = _dividends * magnitude;
                        }
                    }
                    else{
                        _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2);
                        _fee = _dividends * magnitude;
                    }
                    
                    
                } else {
                    // no ref purchase
                    // add the referral bonus back to the global dividends cake
                    _dividends = SafeMath.add(_dividends, _referralBonus);
                    _fee = _dividends * magnitude;
                }
                return (_dividends, _fee);
            }
        
        
            function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
                antiEarlyWhale(_incomingEthereum)
                internal
                returns(uint256)
            {
                // data setup
                uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100);
                uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
                uint256 _fundPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, fundFee_), 100);
                uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
                uint256 _fee;
                (_dividends, _fee) = handleRef(_referredBy, _referralBonus, _dividends, _fee);
                uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _dividends), _fundPayout);
                totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout);
        
                uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
        
        
                // no point in continuing execution if OP is a poorfag russian hacker
                // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world
                // (or hackers)
                // and yes we know that the safemath function automatically rules out the "greater then" equasion.
                require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
        
        
        
                // we can't give people infinite ethereum
                if(tokenSupply_ > 0){
         
                    // add tokens to the pool
                    tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
        
                    // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
                    profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
        
                    // calculate the amount of tokens the customer receives over his purchase
                    _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
        
                } else {
                    // add tokens to the pool
                    tokenSupply_ = _amountOfTokens;
                }
        
                // update circulating supply & the ledger address for the customer
                tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens);
        
                // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;
                //really i know you think you do but you don't
                int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
                payoutsTo_[msg.sender] += _updatedPayouts;
        
                // fire event
                onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy);
        
                return _amountOfTokens;
            }
        
            /**
             * Calculate Token price based on an amount of incoming ethereum
             * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
             * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
             */
            function ethereumToTokens_(uint256 _ethereum)
                internal
                view
                returns(uint256)
            {
                uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18;
                uint256 _tokensReceived =
                 (
                    (
                        // underflow attempts BTFO
                        SafeMath.sub(
                            (sqrt
                                (
                                    (_tokenPriceInitial**2)
                                    +
                                    (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18))
                                    +
                                    (((tokenPriceIncremental_)**2)*(tokenSupply_**2))
                                    +
                                    (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_)
                                )
                            ), _tokenPriceInitial
                        )
                    )/(tokenPriceIncremental_)
                )-(tokenSupply_)
                ;
        
                return _tokensReceived;
            }
        
            /**
             * Calculate token sell value.
             * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
             * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
             */
             function tokensToEthereum_(uint256 _tokens)
                internal
                view
                returns(uint256)
            {
        
                uint256 tokens_ = (_tokens + 1e18);
                uint256 _tokenSupply = (tokenSupply_ + 1e18);
                uint256 _etherReceived =
                (
                    // underflow attempts BTFO
                    SafeMath.sub(
                        (
                            (
                                (
                                    tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18))
                                )-tokenPriceIncremental_
                            )*(tokens_ - 1e18)
                        ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2
                    )
                /1e18);
                return _etherReceived;
            }
        
        
            //This is where all your gas goes, sorry
            //Not sorry, you probably only paid 1 gwei
            function sqrt(uint x) internal pure returns (uint y) {
                uint z = (x + 1) / 2;
                y = x;
                while (z < y) {
                    y = z;
                    z = (x / z + z) / 2;
                }
            }
        }
        
        /**
         * @title SafeMath
         * @dev Math operations with safety checks that throw on error
         */
        library SafeMath {
        
            /**
            * @dev Multiplies two numbers, throws on overflow.
            */
            function mul(uint256 a, uint256 b) internal pure returns (uint256) {
                if (a == 0) {
                    return 0;
                }
                uint256 c = a * b;
                assert(c / a == b);
                return c;
            }
        
            /**
            * @dev Integer division of two numbers, truncating the quotient.
            */
            function div(uint256 a, uint256 b) internal pure returns (uint256) {
                // assert(b > 0); // Solidity automatically throws when dividing by 0
                uint256 c = a / b;
                // assert(a == b * c + a % b); // There is no case in which this doesn't hold
                return c;
            }
        
            /**
            * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
            */
            function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                assert(b <= a);
                return a - b;
            }
        
            /**
            * @dev Adds two numbers, throws on overflow.
            */
            function add(uint256 a, uint256 b) internal pure returns (uint256) {
                uint256 c = a + b;
                assert(c >= a);
                return c;
            }
        }

        File 2 of 3: Oraclize
        /*
        Copyright (c) 2015-2016 Oraclize SRL
        Copyright (c) 2016-2017 Oraclize LTD
        */
        
        /*
        Oraclize Connector v1.2.0
        */
        
        // 'compressed' alternative, where all modifiers have been changed to FUNCTIONS
        // which is cheaper for deployment, potentially cheaper execution
        
        pragma solidity ^0.4.11;
        
        contract Oraclize {
            mapping (address => uint) reqc;
        
            mapping (address => byte) public cbAddresses;
        
            mapping (address => bool) public offchainPayment;
        
            event Log1(address sender, bytes32 cid, uint timestamp, string datasource, string arg, uint gaslimit, byte proofType, uint gasPrice);
            event Log2(address sender, bytes32 cid, uint timestamp, string datasource, string arg1, string arg2, uint gaslimit, byte proofType, uint gasPrice);
            event LogN(address sender, bytes32 cid, uint timestamp, string datasource, bytes args, uint gaslimit, byte proofType, uint gasPrice);
            event Log1_fnc(address sender, bytes32 cid, uint timestamp, string datasource, string arg, function() external callback, uint gaslimit, byte proofType, uint gasPrice);
            event Log2_fnc(address sender, bytes32 cid, uint timestamp, string datasource, string arg1, string arg2, function() external callback, uint gaslimit, byte proofType, uint gasPrice);
            event LogN_fnc(address sender, bytes32 cid, uint timestamp, string datasource, bytes args, function() external callback, uint gaslimit, byte proofType, uint gasPrice);
        
            event Emit_OffchainPaymentFlag(address indexed idx_sender, address sender, bool indexed idx_flag, bool flag);
        
            address owner;
            address paymentFlagger;
        
            function changeAdmin(address _newAdmin)
            external
            {
                onlyadmin();
                owner = _newAdmin;
            }
        
            function changePaymentFlagger(address _newFlagger)
            external
            {
                onlyadmin();
                paymentFlagger = _newFlagger;
            }
        
            function addCbAddress(address newCbAddress, byte addressType)
            external
            {
                onlyadmin();
                //bytes memory nil = '';
                addCbAddress(newCbAddress, addressType, hex'');
            }
        
            // proof is currently a placeholder for when associated proof for addressType is added
            function addCbAddress(address newCbAddress, byte addressType, bytes proof)
            public
            {
                onlyadmin();
                cbAddresses[newCbAddress] = addressType;
            }
        
            function removeCbAddress(address newCbAddress)
            external
            {
                onlyadmin();
                delete cbAddresses[newCbAddress];
            }
        
            function cbAddress()
            constant
            returns (address _cbAddress)
            {
                if (cbAddresses[tx.origin] != 0)
                    _cbAddress = tx.origin;
            }
        
            function addDSource(string dsname, uint multiplier)
            external
            {
                addDSource(dsname, 0x00, multiplier);
            }
        
            function addDSource(string dsname, byte proofType, uint multiplier)
            public
            {
                onlyadmin();
                bytes32 dsname_hash = sha3(dsname, proofType);
                dsources[dsources.length++] = dsname_hash;
                price_multiplier[dsname_hash] = multiplier;
            }
        
            // Utilized by bridge
            function multiAddDSource(bytes32[] dsHash, uint256[] multiplier)
            external
            {
                onlyadmin();
                // dsHash -> sha3(DATASOURCE_NAME, PROOF_TYPE);
                for (uint i=0; i<dsHash.length; i++) {
                    dsources[dsources.length++] = dsHash[i];
                    price_multiplier[dsHash[i]] = multiplier[i];
                }
            }
        
            function multisetProofType(uint[] _proofType, address[] _addr)
            external
            {
                onlyadmin();
                for (uint i=0; i<_addr.length; i++) addr_proofType[_addr[i]] = byte(_proofType[i]);
            }
        
            function multisetCustomGasPrice(uint[] _gasPrice, address[] _addr)
            external
            {
                onlyadmin();
                for (uint i=0; i<_addr.length; i++) addr_gasPrice[_addr[i]] = _gasPrice[i];
            }
        
            uint gasprice = 20000000000;
        
            function setGasPrice(uint newgasprice)
            external
            {
                onlyadmin();
                gasprice = newgasprice;
            }
        
            function setBasePrice(uint new_baseprice)
            external
            { //0.001 usd in ether
                onlyadmin();
                baseprice = new_baseprice;
                for (uint i=0; i<dsources.length; i++) price[dsources[i]] = new_baseprice*price_multiplier[dsources[i]];
            }
        
            function setBasePrice(uint new_baseprice, bytes proofID)
            external
            { //0.001 usd in ether
                onlyadmin();
                baseprice = new_baseprice;
                for (uint i=0; i<dsources.length; i++) price[dsources[i]] = new_baseprice*price_multiplier[dsources[i]];
            }
        
            function setOffchainPayment(address _addr, bool _flag)
            external
            {
              if (msg.sender != paymentFlagger) throw;
              offchainPayment[_addr] = _flag;
              Emit_OffchainPaymentFlag(_addr, _addr, _flag, _flag);
            }
        
            function withdrawFunds(address _addr)
            external
            {
                onlyadmin();
                _addr.send(this.balance);
            }
        
            // unnecessary?
            //function() {}
        
            function Oraclize() {
                owner = msg.sender;
            }
        
            // Pesudo-modifiers
        
            function onlyadmin()
            private {
                if (msg.sender != owner) throw;
            }
        
            function costs(string datasource, uint gaslimit)
            private
            returns (uint price) {
                price = getPrice(datasource, gaslimit, msg.sender);
        
                if (msg.value >= price){
                    uint diff = msg.value - price;
                    if (diff > 0) {
                        // added for correct query cost to be returned
                        if(!msg.sender.send(diff)) {
                            throw;
                        }
                    }
                } else throw;
            }
        
            mapping (address => byte) addr_proofType;
            mapping (address => uint) addr_gasPrice;
            uint public baseprice;
            mapping (bytes32 => uint) price;
            mapping (bytes32 => uint) price_multiplier;
            bytes32[] dsources;
        
            bytes32[] public randomDS_sessionPubKeysHash;
        
            function randomDS_updateSessionPubKeysHash(bytes32[] _newSessionPubKeysHash)
            external
            {
                onlyadmin();
                randomDS_sessionPubKeysHash.length = 0;
                for (uint i=0; i<_newSessionPubKeysHash.length; i++) randomDS_sessionPubKeysHash.push(_newSessionPubKeysHash[i]);
            }
        
            function randomDS_getSessionPubKeyHash()
            external
            constant
            returns (bytes32) {
                uint i = uint(sha3(reqc[msg.sender]))%randomDS_sessionPubKeysHash.length;
                return randomDS_sessionPubKeysHash[i];
            }
        
            function setProofType(byte _proofType)
            external
            {
                addr_proofType[msg.sender] = _proofType;
            }
        
            function setCustomGasPrice(uint _gasPrice)
            external
            {
                addr_gasPrice[msg.sender] = _gasPrice;
            }
        
            function getPrice(string _datasource)
            public
            returns (uint _dsprice)
            {
                return getPrice(_datasource, msg.sender);
            }
        
            function getPrice(string _datasource, uint _gaslimit)
            public
            returns (uint _dsprice)
            {
                return getPrice(_datasource, _gaslimit, msg.sender);
            }
        
            function getPrice(string _datasource, address _addr)
            private
            returns (uint _dsprice)
            {
                return getPrice(_datasource, 200000, _addr);
            }
        
            function getPrice(string _datasource, uint _gaslimit, address _addr)
            private
            returns (uint _dsprice)
            {
                uint gasprice_ = addr_gasPrice[_addr];
                if (
                        (offchainPayment[_addr])
                    ||(
                        (_gaslimit <= 200000)&&
                        (reqc[_addr] == 0)&&
                        (gasprice_ <= gasprice)&&
                        (tx.origin != cbAddress())
                    )
                ) return 0;
        
                if (gasprice_ == 0) gasprice_ = gasprice;
                _dsprice = price[sha3(_datasource, addr_proofType[_addr])];
                _dsprice += _gaslimit*gasprice_;
                return _dsprice;
            }
        
            function getCodeSize(address _addr)
            private
            constant
            returns(uint _size)
            {
                assembly {
                    _size := extcodesize(_addr)
                }
            }
        
            function query(string _datasource, string _arg)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(0, _datasource, _arg, 200000);
            }
        
            function query1(string _datasource, string _arg)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(0, _datasource, _arg, 200000);
            }
        
            function query2(string _datasource, string _arg1, string _arg2)
            payable
            external
            returns (bytes32 _id)
            {
                return query2(0, _datasource, _arg1, _arg2, 200000);
            }
        
            function queryN(string _datasource, bytes _args)
            payable
            external
            returns (bytes32 _id)
            {
                return queryN(0, _datasource, _args, 200000);
            }
        
            function query(uint _timestamp, string _datasource, string _arg)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(_timestamp, _datasource, _arg, 200000);
            }
        
            function query1(uint _timestamp, string _datasource, string _arg)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(_timestamp, _datasource, _arg, 200000);
            }
        
            function query2(uint _timestamp, string _datasource, string _arg1, string _arg2)
            payable
            external
            returns (bytes32 _id)
            {
                return query2(_timestamp, _datasource, _arg1, _arg2, 200000);
            }
        
            function queryN(uint _timestamp, string _datasource, bytes _args)
            payable
            external
            returns (bytes32 _id)
            {
                return queryN(_timestamp, _datasource, _args, 200000);
            }
        
        /*  Needless?
            function query(uint _timestamp, string _datasource, string _arg, uint _gaslimit)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(_timestamp, _datasource, _arg, _gaslimit);
            }
        */
            function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(_timestamp, _datasource, _arg, _gaslimit);
            }
        
            function query1_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit)
            payable
            external
            returns (bytes32 _id)
            {
                return query1(_timestamp, _datasource, _arg, _gaslimit);
            }
        
            function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit)
            payable
            external
            returns (bytes32 _id)
            {
                return query2(_timestamp, _datasource, _arg1, _arg2, _gaslimit);
            }
        
            function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _args, uint _gaslimit)
            payable
            external
            returns (bytes32 _id)
            {
                return queryN(_timestamp, _datasource, _args, _gaslimit);
            }
        
            function query1(uint _timestamp, string _datasource, string _arg, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
            	if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                Log1(msg.sender, _id, _timestamp, _datasource, _arg, _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        
            function query2(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
            	if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                Log2(msg.sender, _id, _timestamp, _datasource, _arg1, _arg2, _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        
            function queryN(uint _timestamp, string _datasource, bytes _args, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
            	if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                LogN(msg.sender, _id, _timestamp, _datasource, _args, _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        
            function query1_fnc(uint _timestamp, string _datasource, string _arg, function() external _fnc, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
                if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)||address(_fnc) != msg.sender) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                Log1_fnc(msg.sender, _id, _timestamp, _datasource, _arg, _fnc, _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        
            function query2_fnc(uint _timestamp, string _datasource, string _arg1, string _arg2, function() external _fnc, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
                if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)||address(_fnc) != msg.sender) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                Log2_fnc(msg.sender, _id, _timestamp, _datasource, _arg1, _arg2, _fnc,  _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        
            function queryN_fnc(uint _timestamp, string _datasource, bytes _args, function() external _fnc, uint _gaslimit)
            payable
            public
            returns (bytes32 _id)
            {
                costs(_datasource, _gaslimit);
                if ((_timestamp > now+3600*24*60)||(_gaslimit > block.gaslimit)||address(_fnc) != msg.sender) throw;
        
                _id = sha3(this, msg.sender, reqc[msg.sender]);
                reqc[msg.sender]++;
                LogN_fnc(msg.sender, _id, _timestamp, _datasource, _args, _fnc, _gaslimit, addr_proofType[msg.sender], addr_gasPrice[msg.sender]);
                return _id;
            }
        }

        File 3 of 3: OraclizeAddrResolver
        /*
          Copyright (c) 2015-2016 Oraclize SRL
          Copyright (c) 2016 Oraclize LTD
        */
        
        contract OraclizeAddrResolver {
        
            address public addr;
        
            address owner;
        
            function OraclizeAddrResolver(){
                owner = msg.sender;
            }
        
            function changeOwner(address newowner){
                if (msg.sender != owner) throw;
                owner = newowner;
            }
        
            function getAddress() returns (address oaddr){
                return addr;
            }
        
            function setAddr(address newaddr){
                if (msg.sender != owner) throw;
                addr = newaddr;
            }
        
        }