Sponsored Link:   SHIFT.cash - 1st ever car title loan platform on blockchain. Join NOW.
Contract Overview
ETH Balance: 0 Ether
ETH USD Value: $0
No Of Transactions: 11 txns
  Latest 11 txns

TxHash Age From To Value [TxFee]
0x1411ff3e00d3a57ff528dea4d83131720d1410f00bfa7bb13db0f925ab9047688 days 19 hrs ago0x076739de679fbac82fe5efcbc1a5af9545b66439  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440 Ether0.00101115
0x85a18e2e778757aefa36508fba5640ca00d043ed6837ddec06ba8f32eeed6fb28 days 19 hrs ago0x076739de679fbac82fe5efcbc1a5af9545b66439  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf445 Ether0.00316925
0x0bb6ad27a80ac1a4f78cd90068478d1e2c48f1759a254ec43cdbf843ef881d948 days 19 hrs ago0x076739de679fbac82fe5efcbc1a5af9545b66439  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440 Ether0.00101115
0x528ccb2ec873fe75938a6320bb7b078b399edc76ab25199c54523d96182f75d68 days 19 hrs ago0xee06bddaffa56a303718de53a5bc347efbe4c68f  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440 Ether0.0015267
0x6ab2c2947495639840c5ebaadfcaa04bdffb8c3a9568549b74c2501829f344ca8 days 19 hrs ago0xee06bddaffa56a303718de53a5bc347efbe4c68f  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440.5 Ether0.00241925
0x5ed460668a5f95180d853d4fc388f0863664329189730d71157f9778f93b1bcd8 days 19 hrs ago0x076739de679fbac82fe5efcbc1a5af9545b66439  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf445 Ether0.00316925
0xcdd0d8080d1a0e63303dda773853b227e011c05aa666a686e8e8e705dd2030f48 days 20 hrs ago0xee06bddaffa56a303718de53a5bc347efbe4c68f  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440 Ether0.0065737
0x80b13fd0e962fa33c980a0f49d8df25bb1e8967e322d7cd827f982dce84f835e8 days 21 hrs ago0x009dce52431d04c8b73a254f9eb246d080e7411b  IN   0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440.007905825 Ether0.001575
0x2016565b7314fd50cd816fc038d8f73c6581f01e51b631df591ea04644e22e678 days 21 hrs ago0xee06bddaffa56a303718de53a5bc347efbe4c68f  IN    Contract Creation0 Ether0.089858400001
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
  Latest 3 Internal Transactions

ParentTxHash Block Age From To Value
0x1411ff3e00d3a57ff528dea4d83131720d1410f00bfa7bb13db0f925ab90476846924828 days 19 hrs ago0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440x076739de679fbac82fe5efcbc1a5af9545b664395 Ether
0x0bb6ad27a80ac1a4f78cd90068478d1e2c48f1759a254ec43cdbf843ef881d9446923838 days 19 hrs ago0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440x076739de679fbac82fe5efcbc1a5af9545b664395 Ether
0x528ccb2ec873fe75938a6320bb7b078b399edc76ab25199c54523d96182f75d646923778 days 19 hrs ago0x51e4e00e3e019e58fc0b8cc8c6490a2d28efbf440xee06bddaffa56a303718de53a5bc347efbe4c68f0.5 Ether
[ Download CSV Export  ] 
Contract Source Code Verified
Contract Name: SanityPools
Compiler Version: v0.4.19-nightly.2017.11.11+commit.284c3839
Optimization Enabled: No
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts
pragma solidity ^0.4.15;

/*
author : dungeon

A contract for doing pools with only one contract.
*/

// ERC20 Interface: https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
  function transfer(address _to, uint256 _value) returns (bool success);
  function balanceOf(address _owner) constant returns (uint256 balance);
}

contract Controller {
    //The addy of the developer
    address public developer = 0xEE06BdDafFA56a303718DE53A5bc347EfbE4C68f;

    modifier onlyOwner {
        require(msg.sender == developer);
        _;
    }
}

contract SanityPools is Controller {

    //mapping of the pool's index with the corresponding balances
    mapping (uint256 => mapping (address => uint256)) balances;
    //Array of 100 pools max
    Pool[100] pools;
    //Index of the active pool
    uint256 index_active = 0;
    //Allows an emergency withdraw after 1 week after the buy : 7*24*60*60 / 15.3 (mean time for mining a block)
    uint256 public week_in_blocs = 39529;

    modifier validIndex(uint256 _index){
        require(_index <= index_active);
        _;
    }

    struct Pool {
        string name;
        //0 means there is no min/max amount
        uint256 min_amount;
        uint256 max_amount;
        //
        address sale;
        ERC20 token;
        // Record ETH value of tokens currently held by contract for the pool.
        uint256 pool_eth_value;
        // Track whether the pool has bought the tokens yet.
        bool bought_tokens;
        uint256 buy_block;
    }

    //Functions reserved for the owner
    function createPool(string _name, uint256 _min, uint256 _max) onlyOwner {
        require(index_active < 100);
        //Creates a new struct and saves in storage
        pools[index_active] = Pool(_name, _min, _max, 0x0, ERC20(0x0), 0, false, 0);
        //updates the active index
        index_active += 1;
    }

    function setSale(uint256 _index, address _sale) onlyOwner validIndex(_index) {
        Pool storage pool = pools[_index];
        require(pool.sale == 0x0);
        pool.sale = _sale;
    }

    function setToken(uint256 _index, address _token) onlyOwner validIndex(_index) {
        Pool storage pool = pools[_index];
        pool.token = ERC20(_token);
    }

    function buyTokens(uint256 _index) onlyOwner validIndex(_index) {
        Pool storage pool = pools[_index];
        require(pool.pool_eth_value >= pool.min_amount);
        require(pool.pool_eth_value <= pool.max_amount || pool.max_amount == 0);
        require(!pool.bought_tokens);
        //Prevent burning of ETH by mistake
        require(pool.sale != 0x0);
        //Registers the buy block number
        pool.buy_block = block.number;
        // Record that the contract has bought the tokens.
        pool.bought_tokens = true;
        // Transfer all the funds to the crowdsale address.
        pool.sale.transfer(pool.pool_eth_value);
    }

    function emergency_withdraw(uint256 _index, address _token) onlyOwner validIndex(_index) {
        //Allows to withdraw all the tokens after a certain amount of time, in the case
        //of an unplanned situation
        Pool storage pool = pools[_index];
        require(block.number >= (pool.buy_block + week_in_blocs));
        ERC20 token = ERC20(_token);
        uint256 contract_token_balance = token.balanceOf(address(this));
        require (contract_token_balance != 0);
        // Send the funds.  Throws on failure to prevent loss of funds.
        require(token.transfer(msg.sender, contract_token_balance));
    }

    function change_delay(uint256 _delay) onlyOwner {
        week_in_blocs = _delay;
    }

    //Functions accessible to everyone
    function getPoolName(uint256 _index) validIndex(_index) constant returns (string) {
        Pool storage pool = pools[_index];
        return pool.name;
    }

    function refund(uint256 _index) validIndex(_index) {
        Pool storage pool = pools[_index];
        //Can't refund if tokens were bought
        require(!pool.bought_tokens);
        uint256 eth_to_withdraw = balances[_index][msg.sender];
        //Updates the user's balance prior to sending ETH to prevent recursive call.
        balances[_index][msg.sender] = 0;
        //Updates the pool ETH value
        pool.pool_eth_value -= eth_to_withdraw;
        msg.sender.transfer(eth_to_withdraw);
    }

    function withdraw(uint256 _index) validIndex(_index) {
        Pool storage pool = pools[_index];
        // Disallow withdraw if tokens haven't been bought yet.
        require(pool.bought_tokens);
        uint256 contract_token_balance = pool.token.balanceOf(address(this));
        // Disallow token withdrawals if there are no tokens to withdraw.
        require(contract_token_balance != 0);
        // Store the user's token balance in a temporary variable.
        uint256 tokens_to_withdraw = (balances[_index][msg.sender] * contract_token_balance) / pool.pool_eth_value;
        // Update the value of tokens currently held by the contract.
        pool.pool_eth_value -= balances[_index][msg.sender];
        // Update the user's balance prior to sending to prevent recursive call.
        balances[_index][msg.sender] = 0;
        //The 1% fee
        uint256 fee = tokens_to_withdraw / 100;
        // Send the funds.  Throws on failure to prevent loss of funds.
        require(pool.token.transfer(msg.sender, tokens_to_withdraw - fee));
        // Send the fee to the developer.
        require(pool.token.transfer(developer, fee));
    }

    function contribute(uint256 _index) validIndex(_index) payable {
        Pool storage pool = pools[_index];
        require(!pool.bought_tokens);
        //Check if the contribution is within the limits or if there is no max amount
        require(pool.pool_eth_value+msg.value <= pool.max_amount || pool.max_amount == 0);
        //Update the eth held by the pool
        pool.pool_eth_value += msg.value;
        //Updates the user's balance
        balances[_index][msg.sender] += msg.value;
    }
}

    Contract ABI  
[{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"getPoolName","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"}],"name":"refund","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"}],"name":"buyTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_delay","type":"uint256"}],"name":"change_delay","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_min","type":"uint256"},{"name":"_max","type":"uint256"}],"name":"createPool","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"},{"name":"_token","type":"address"}],"name":"setToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"},{"name":"_token","type":"address"}],"name":"emergency_withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"}],"name":"contribute","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"developer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"week_in_blocs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"},{"name":"_sale","type":"address"}],"name":"setSale","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

  Contract Creation Code Switch To Opcodes View
606060405273ee06bddaffa56a303718de53a5bc347efbe4c68f6000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600061032255619a6961032355341561007057600080fd5b61149b8061007f6000396000f3006060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630f76f489146100bf578063278ecde11461015b5780632e1a7d4d1461017e5780633610724e146101a15780636e4f33b0146101c45780639b6c5283146101e7578063af906cf314610256578063b78be80214610298578063c1cbbca7146102da578063ca4b208b146102f2578063e8d375fe14610347578063ff02615814610370575b600080fd5b34156100ca57600080fd5b6100e060048080359060200190919050506103b2565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610120578082015181840152602081019050610105565b50505050905090810190601f16801561014d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016657600080fd5b61017c600480803590602001909190505061048a565b005b341561018957600080fd5b61019f60048080359060200190919050506105d4565b005b34156101ac57600080fd5b6101c26004808035906020019091905050610a53565b005b34156101cf57600080fd5b6101e56004808035906020019091905050610c10565b005b34156101f257600080fd5b610254600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091908035906020019091908035906020019091905050610c76565b005b341561026157600080fd5b610296600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e74565b005b34156102a357600080fd5b6102d8600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610f42565b005b6102f0600480803590602001909190505061118e565b005b34156102fd57600080fd5b610305611273565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561035257600080fd5b61035a611298565b6040518082815260200191505060405180910390f35b341561037b57600080fd5b6103b0600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061129f565b005b6103ba6113b6565b6000826103225481111515156103cf57600080fd5b6002846064811015156103de57fe5b600802019150816000018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561047c5780601f106104515761010080835404028352916020019161047c565b820191906000526020600020905b81548152906001019060200180831161045f57829003601f168201915b505050505092505050919050565b600080826103225481111515156104a057600080fd5b6002846064811015156104af57fe5b6008020192508260060160009054906101000a900460ff161515156104d357600080fd5b6001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054915060006001600086815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508183600501600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015156105ce57600080fd5b50505050565b600080600080846103225481111515156105ed57600080fd5b6002866064811015156105fc57fe5b6008020194508460060160009054906101000a900460ff16151561061f57600080fd5b8460040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15156106e657600080fd5b6102c65a03f115156106f757600080fd5b5050506040518051905093506000841415151561071357600080fd5b8460050154846001600089815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540281151561077457fe5b0492506001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054856005016000828254039250508190555060006001600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060648381151561083b57fe5b0491508460040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb338486036000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561090f57600080fd5b6102c65a03f1151561092057600080fd5b50505060405180519050151561093557600080fd5b8460040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515610a2557600080fd5b6102c65a03f11515610a3657600080fd5b505050604051805190501515610a4b57600080fd5b505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ab057600080fd5b81610322548111151515610ac357600080fd5b600283606481101515610ad257fe5b6008020191508160010154826005015410151515610aef57600080fd5b81600201548260050154111580610b0a575060008260020154145b1515610b1557600080fd5b8160060160009054906101000a900460ff16151515610b3357600080fd5b60008260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515610b7d57600080fd5b43826007018190555060018260060160006101000a81548160ff0219169083151502179055508160030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc83600501549081150290604051600060405180830381858888f193505050501515610c0b57600080fd5b505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c6b57600080fd5b806103238190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cd157600080fd5b606461032254101515610ce357600080fd5b61010060405190810160405280848152602001838152602001828152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000151581526020016000815250600261032254606481101515610d6357fe5b600802016000820151816000019080519060200190610d839291906113ca565b50602082015181600101556040820151816002015560608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060808201518160040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555060e08201518160070155905050600161032260008282540192505081905550505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ed157600080fd5b82610322548111151515610ee457600080fd5b600284606481101515610ef357fe5b600802019150828260040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fa257600080fd5b84610322548111151515610fb557600080fd5b600286606481101515610fc457fe5b600802019350610323548460070154014310151515610fe257600080fd5b8492508273ffffffffffffffffffffffffffffffffffffffff166370a08231306000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561108857600080fd5b6102c65a03f1151561109957600080fd5b505050604051805190509150600082141515156110b557600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561116057600080fd5b6102c65a03f1151561117157600080fd5b50505060405180519050151561118657600080fd5b505050505050565b6000816103225481111515156111a357600080fd5b6002836064811015156111b257fe5b6008020191508160060160009054906101000a900460ff161515156111d657600080fd5b8160020154348360050154011115806111f3575060008260020154145b15156111fe57600080fd5b348260050160008282540192505081905550346001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6103235481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156112fc57600080fd5b8261032254811115151561130f57600080fd5b60028460648110151561131e57fe5b60080201915060008260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561136d57600080fd5b828260030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061140b57805160ff1916838001178555611439565b82800160010185558215611439579182015b8281111561143857825182559160200191906001019061141d565b5b509050611446919061144a565b5090565b61146c91905b80821115611468576000816000905550600101611450565b5090565b905600a165627a7a723058205e9e092434dd28a1097c11a844c27c7443db1d8966545b6dd439fcaecc42e7130029

   Swarm Source:
bzzr://5e9e092434dd28a1097c11a844c27c7443db1d8966545b6dd439fcaecc42e713

 

View All
Block Age txn Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "downvote" button for any spammy posts, and the "upvote" for interesting conversations.