*
Sponsored Link:  Up to 2% Cryptocurrency Cashback - Reserve your card - Monaco App - www.mona.co
Contract Overview | JavvyCrowdsale
ETH Balance: 0 Ether
ETH USD Value: $0
No Of Transactions: 77 txns
Token Tracker 0x6dC896e52DeF34fF23Ab0B07250e12B9Fd9fe9E7
  Latest 25 txns from a total Of 77 transactions View All

TxHash Age From To Value [TxFee]
0x83ff1f21d9e80af57ff84119253584d8c399841d25216f3e0f45c7f3415f4b1c1 day 9 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.00122441
0x7993b260f7edceb4d3c71cd35fc9087444d7c0ca1df1efc4cd68ff7ce94887d88 days 10 hrs ago0xa82385b4e2a635311cae63685ad9ab208e0bd0f2  IN   JavvyCrowdsale0.1 Ether0.001365
0xc72281211747341902d91f3b32ac523a63ca312d374f71e678c6b260628c422722 days 13 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.001836615
0x4bfc01593f2c0cf3b5e06bd0f8e73f91f0b7f7f07aeb7315695f3f01e8e661a727 days 1 hr ago0x8d646a66bce937abbf0118fd18ccd378f48d2553  IN   JavvyCrowdsale0.021 Ether0.003569832
0x489cdbb123b4ba2455b1eda194757d2f6537b5a695d13173f8034951e5d0abf028 days 8 hrs ago0x8d646a66bce937abbf0118fd18ccd378f48d2553  IN   JavvyCrowdsale0.02 Ether0.000441924
0x52c5e6aed1f24e489969025ac151f40260a3f6fd0daace0da438a2f13bd4715828 days 19 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.000728706
0x0423facc4c88478af341b333f15e2a8655b3cc8d2c39215902860ba9a52f237e28 days 19 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.001168755
0x314a51a1f0c4ec06f17e60e5332cad58cb5e40a5a1346ad85a532c03421c085c28 days 19 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.001168083
0xae84cc4ffeb6041acf3788b563114e30f75743a8b6a239ceea5aa9ce10a0936828 days 20 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.001334952
0xd4a31dbf34272a9808c257e7799456ba4e578a82d5f7a8607f5ffbe466e77af628 days 22 hrs ago0x00b933dfc7f69533979e54d0f9f52e617621abe6  IN   JavvyCrowdsale0 Ether0.00032813
0x42d174757ad590a58f384cbd033513dcd8aadfa6218ce8c71f410728baff5c1629 days 6 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000580021
0xf7655037c2770b4e91324b726ab2e503ddfc270e52a0e99e332fdf68eb40c66b30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0xc4c4505cdcec0af7427ef46156675264f2fae1d5b5b46ff147b6304b31e7c50030 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00026524
0x35afa29ee07c9d1fbd2dfd4e6274bd7ceeef1fdba5162a4ac258367365a9619930 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0xa4c4058aed151ee53eb116c6f2a0d84929b672e8615da2fd8eab157cc77e953630 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000445496
0xbb8c51a9884b461722112b34fc4c1d26d6274f30c8806b6dd5e68987819091e330 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0x9d0f2c47e5508110af69cb5c09ffbf7ec8aa4ff003cbd4be01b5f66b8a2a836230 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0xf4aef8bb4e142f4ea32273001b375d8744177bae7f08fa25adc8d5335471911e30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0x0ae57807d0dc00b770507afa3045da0a17ab08fd04873899fc5bd54f850d3c4130 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00026524
0x64480df39bbae9344267c74887393a2da295f3b9049d31eb05a5c9a9bf0167ca30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0xa51c3d5b1709f755310fced86670c5de75089b97e46b27ddc1820c8ed8f0215a30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000264984
0x66a0feb244ca512d3381f422fe4658e6821f07d2abb71f3c3c4184e0a424000730 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000444984
0x583f8970e09fe04f87d8bd963e8f7e0e86fe786134f9ca6c20342d913c8823a030 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000444984
0x0995eea828491c624e930cd4601864310aa02221327a7a24705a0421711a6dcf30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.00044524
0xd7332c9aa072c4db96b89b7d20fbb003533ce0860dfd22bb56548b1d364a0aaa30 days 10 hrs ago0x00613174dd1c94892a2ca3b4d7038724899b5069  IN   JavvyCrowdsale0 Ether0.000445935687
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
  Latest 1 Internal Transaction

ParentTxHash Block Age From To Value
0x4bfc01593f2c0cf3b5e06bd0f8e73f91f0b7f7f07aeb7315695f3f01e8e661a7458340427 days 1 hr ago0x74f536cbcfb9cae062135384bfa2cd5de2f8a4470x3f7a447b057b510d171eb403f0cdd5b73f25e5670.021 Ether
[ Download CSV Export  ] 
Warning: The compiled contract might be susceptible to ZeroFunctionSelector (very low-severity) Solidity compiler bugs.

Contract Source Code Verified
Note: Displaying matching verified source code at contract 0x882da60a19c67e481481bace4c0aa93080cde3d7
Contract Name: MintedEthCappedCrowdsale
Compiler Version: v0.4.16+commit.d7661dd9
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts
pragma solidity ^0.4.11;
// Thanks to OpenZeppeline & TokenMarket for the awesome Libraries.
contract SafeMathLib {
  function safeMul(uint a, uint b) returns (uint) {
    uint c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

  function safeSub(uint a, uint b) returns (uint) {
    assert(b <= a);
    return a - b;
  }

  function safeAdd(uint a, uint b) returns (uint) {
    uint c = a + b;
    assert(c>=a);
    return c;
  }
}

contract Ownable {
  address public owner;
  address public newOwner;
  event OwnershipTransferred(address indexed _from, address indexed _to);
  function Ownable() {
    owner = msg.sender;
  }
  modifier onlyOwner {
    require(msg.sender == owner);
    _;
  }
  function transferOwnership(address _newOwner) onlyOwner {
    newOwner = _newOwner;
  }

  function acceptOwnership() {
    require(msg.sender == newOwner);
    OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }
  
}

contract ERC20Basic {
  uint public totalSupply;
  function balanceOf(address who) constant returns (uint);
  function transfer(address _to, uint _value) returns (bool success);
  event Transfer(address indexed from, address indexed to, uint value);
}

contract ERC20 is ERC20Basic {
  function allowance(address owner, address spender) constant returns (uint);
  function transferFrom(address _from, address _to, uint _value) returns (bool success);
  function approve(address _spender, uint _value) returns (bool success);
  event Approval(address indexed owner, address indexed spender, uint value);
}

contract FractionalERC20 is ERC20 {
  uint8 public decimals;
}

contract StandardToken is ERC20, SafeMathLib {
  /* Token supply got increased and a new owner received these tokens */
  event Minted(address receiver, uint amount);

  /* Actual balances of token holders */
  mapping(address => uint) balances;

  /* approve() allowances */
  mapping (address => mapping (address => uint)) allowed;

  function transfer(address _to, uint _value) returns (bool success) {
    if (balances[msg.sender] >= _value 
        && _value > 0 
        && balances[_to] + _value > balances[_to]
        ) {
      balances[msg.sender] = safeSub(balances[msg.sender],_value);
      balances[_to] = safeAdd(balances[_to],_value);
      Transfer(msg.sender, _to, _value);
      return true;
    }
    else{
      return false;
    }
    
  }

  function transferFrom(address _from, address _to, uint _value) returns (bool success) {
    uint _allowance = allowed[_from][msg.sender];

    if (balances[_from] >= _value   // From a/c has balance
        && _allowance >= _value    // Transfer approved
        && _value > 0              // Non-zero transfer
        && balances[_to] + _value > balances[_to]  // Overflow check
        ){
    balances[_to] = safeAdd(balances[_to],_value);
    balances[_from] = safeSub(balances[_from],_value);
    allowed[_from][msg.sender] = safeSub(_allowance,_value);
    Transfer(_from, _to, _value);
    return true;
        }
    else {
      return false;
    }
  }

  function balanceOf(address _owner) constant returns (uint balance) {
    return balances[_owner];
  }

  function approve(address _spender, uint _value) returns (bool success) {

    // To change the approve amount you first have to reduce the addresses`
    //  allowance to zero by calling `approve(_spender, 0)` if it is not
    //  already 0 to mitigate the race condition described here:
    //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
    //if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;

    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
  }

  function allowance(address _owner, address _spender) constant returns (uint remaining) {
    return allowed[_owner][_spender];
  }

}

/**
 * Upgrade agent interface inspired by Lunyr.
 *
 * Upgrade agent transfers tokens to a new contract.
 * Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting.
 */
contract UpgradeAgent {
  uint public originalSupply;
  /** Interface marker */
  function isUpgradeAgent() public constant returns (bool) {
    return true;
  }
  function upgradeFrom(address _from, uint256 _value) public;
}

/**
 * A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
 *
 * First envisioned by Golem and Lunyr projects.
 */
contract UpgradeableToken is StandardToken {

  /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
  address public upgradeMaster;

  /** The next contract where the tokens will be migrated. */
  UpgradeAgent public upgradeAgent;

  /** How many tokens we have upgraded by now. */
  uint256 public totalUpgraded;

  /**
   * Upgrade states.
   *
   * - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
   * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
   * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
   * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
   *
   */
  enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}

  /**
   * Somebody has upgraded some of his tokens.
   */
  event Upgrade(address indexed _from, address indexed _to, uint256 _value);

  /**
   * New upgrade agent available.
   */
  event UpgradeAgentSet(address agent);

  /**
   * Do not allow construction without upgrade master set.
   */
  function UpgradeableToken(address _upgradeMaster) {
    upgradeMaster = _upgradeMaster;
  }

  /**
   * Allow the token holder to upgrade some of their tokens to a new contract.
   */
  function upgrade(uint256 value) public {
    UpgradeState state = getUpgradeState();
    require((state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading));
    // if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) {
    //   // Called in a bad state
    //   throw;
    // }

    // Validate input value.
    require(value != 0);

    balances[msg.sender] = safeSub(balances[msg.sender],value);

    // Take tokens out from circulation
    totalSupply = safeSub(totalSupply,value);
    totalUpgraded = safeAdd(totalUpgraded,value);

    // Upgrade agent reissues the tokens
    upgradeAgent.upgradeFrom(msg.sender, value);
    Upgrade(msg.sender, upgradeAgent, value);
  }

  /**
   * Set an upgrade agent that handles
   */
  function setUpgradeAgent(address agent) external {
    require(canUpgrade());
    // if(!canUpgrade()) {
    //   // The token is not yet in a state that we could think upgrading
    //   throw;
    // }

    require(agent != 0x0);
    //if (agent == 0x0) throw;
    // Only a master can designate the next agent
    require(msg.sender == upgradeMaster);
    //if (msg.sender != upgradeMaster) throw;
    // Upgrade has already begun for an agent
    require(getUpgradeState() != UpgradeState.Upgrading);
    //if (getUpgradeState() == UpgradeState.Upgrading) throw;

    upgradeAgent = UpgradeAgent(agent);

    // Bad interface
    require(upgradeAgent.isUpgradeAgent());
    //if(!upgradeAgent.isUpgradeAgent()) throw;
    // Make sure that token supplies match in source and target
    require(upgradeAgent.originalSupply() == totalSupply);
    //if (upgradeAgent.originalSupply() != totalSupply) throw;

    UpgradeAgentSet(upgradeAgent);
  }

  /**
   * Get the state of the token upgrade.
   */
  function getUpgradeState() public constant returns(UpgradeState) {
    if(!canUpgrade()) return UpgradeState.NotAllowed;
    else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
    else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
    else return UpgradeState.Upgrading;
  }

  /**
   * Change the upgrade master.
   *
   * This allows us to set a new owner for the upgrade mechanism.
   */
  function setUpgradeMaster(address master) public {
    require(master != 0x0);
    //if (master == 0x0) throw;
    require(msg.sender == upgradeMaster);
    //if (msg.sender != upgradeMaster) throw;
    upgradeMaster = master;
  }

  /**
   * Child contract can enable to provide the condition when the upgrade can begun.
   */
  function canUpgrade() public constant returns(bool) {
     return true;
  }

}

/**
 * Define interface for releasing the token transfer after a successful crowdsale.
 */
contract ReleasableToken is ERC20, Ownable {

  /* The finalizer contract that allows unlift the transfer limits on this token */
  address public releaseAgent;

  /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
  bool public released = false;

  /** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
  mapping (address => bool) public transferAgents;

  /**
   * Limit token transfer until the crowdsale is over.
   *
   */
  modifier canTransfer(address _sender) {

    if(!released) {
        require(transferAgents[_sender]);
        // if(!transferAgents[_sender]) {
        //     throw;
        // }
    }

    _;
  }

  /**
   * Set the contract that can call release and make the token transferable.
   *
   * Design choice. Allow reset the release agent to fix fat finger mistakes.
   */
  function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {

    // We don't do interface check here as we might want to a normal wallet address to act as a release agent
    releaseAgent = addr;
  }

  /**
   * Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
   */
  function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
    transferAgents[addr] = state;
  }

  /**
   * One way function to release the tokens to the wild.
   *
   * Can be called only from the release agent that is the final ICO contract. It is only called if the crowdsale has been success (first milestone reached).
   */
  function releaseTokenTransfer() public onlyReleaseAgent {
    released = true;
  }

  /** The function can be called only before or after the tokens have been releasesd */
  modifier inReleaseState(bool releaseState) {
    require(releaseState == released);
    // if(releaseState != released) {
    //     throw;
    // }
    _;
  }

  /** The function can be called only by a whitelisted release agent. */
  modifier onlyReleaseAgent() {
    require(msg.sender == releaseAgent);
    // if(msg.sender != releaseAgent) {
    //     throw;
    // }
    _;
  }

  function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) {
    // Call StandardToken.transfer()
   return super.transfer(_to, _value);
  }

  function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) {
    // Call StandardToken.transferForm()
    return super.transferFrom(_from, _to, _value);
  }

}

/**
 * A token that can increase its supply by another contract.
 *
 * This allows uncapped crowdsale by dynamically increasing the supply when money pours in.
 * Only mint agents, contracts whitelisted by owner, can mint new tokens.
 *
 */
contract MintableToken is StandardToken, Ownable {

  bool public mintingFinished = false;

  /** List of agents that are allowed to create new tokens */
  mapping (address => bool) public mintAgents;

  event MintingAgentChanged(address addr, bool state  );

  /**
   * Create new tokens and allocate them to an address..
   *
   * Only callably by a crowdsale contract (mint agent).
   */
  function mint(address receiver, uint amount) onlyMintAgent canMint public {
    totalSupply = safeAdd(totalSupply, amount);
    balances[receiver] = safeAdd(balances[receiver], amount);

    // This will make the mint transaction apper in EtherScan.io
    // We can remove this after there is a standardized minting event
    Transfer(0, receiver, amount);
  }

  /**
   * Owner can allow a crowdsale contract to mint new tokens.
   */
  function setMintAgent(address addr, bool state) onlyOwner canMint public {
    mintAgents[addr] = state;
    MintingAgentChanged(addr, state);
  }

  modifier onlyMintAgent() {
    // Only crowdsale contracts are allowed to mint new tokens
    require(mintAgents[msg.sender]);
    // if(!mintAgents[msg.sender]) {
    //     throw;
    // }
    _;
  }

  /** Make sure we are not done yet. */
  modifier canMint() {
    require(!mintingFinished);
    //if(mintingFinished) throw;
    _;
  }
}

/**
 * A crowdsaled token.
 *
 * An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
 *
 * - The token transfer() is disabled until the crowdsale is over
 * - The token contract gives an opt-in upgrade path to a new contract
 * - The same token can be part of several crowdsales through approve() mechanism
 * - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
 *
 */
contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken {

  event UpdatedTokenInformation(string newName, string newSymbol);
  event ProfitDelivered(address fetcher, uint profit);
  event ProfitLoaded(address owner, uint profit);
  string public name;

  string public symbol;

  uint8 public decimals;
  uint loadedProfit;
  bool ditributingProfit;
  uint profitDistributed;
  uint loadedProfitAvailable;

  /** Whether an addresses has fetched profit of not*/
  mapping (address => bool) public hasFetchedProfit;

  /**
   * Construct the token.
   *
   * This token must be created through a team multisig wallet, so that it is owned by that wallet.
   *
   * @param _name Token name
   * @param _symbol Token symbol - should be all caps
   * @param _initialSupply How many tokens we start with
   * @param _decimals Number of decimal places
   * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
   */
  function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, bool _mintable)
    UpgradeableToken(msg.sender) {

    // Create any address, can be transferred
    // to team multisig via changeOwner(),
    // also remember to call setUpgradeMaster()
    owner = msg.sender;

    name = _name;
    symbol = _symbol;

    totalSupply = _initialSupply;

    decimals = _decimals;

    // Create initially all balance on the team multisig
    balances[owner] = totalSupply;

    if(totalSupply > 0) {
      Minted(owner, totalSupply);
    }

    // No more new supply allowed after the token creation
    if(!_mintable) {
      mintingFinished = true;
      require(totalSupply != 0);
      // if(totalSupply == 0) {
      //   throw; // Cannot create a token without supply and no minting
      // }
    }
  }

  /**
   * When token is released to be transferable, enforce no new tokens can be created.
   */
  function releaseTokenTransfer() public onlyReleaseAgent {
    mintingFinished = true;
    super.releaseTokenTransfer();
  }

  /**
   * Allow upgrade agent functionality kick in only if the crowdsale was success.
   */
  function canUpgrade() public constant returns(bool) {
    return released && super.canUpgrade();
  }

  /**
   * Owner can update token information here
   */
  function setTokenInformation(string _name, string _symbol) onlyOwner {
    name = _name;
    symbol = _symbol;
    UpdatedTokenInformation(name, symbol);
  }

  /**
   * Allow load profit on the contract for the payout.
   *
   * 
   */
  function loadProfit() public payable onlyOwner {
    require(released);
    require(!ditributingProfit);
    require(msg.value != 0);
    loadedProfit = msg.value;
    loadedProfitAvailable = loadedProfit;
    ditributingProfit = true;
    ProfitLoaded(msg.sender, loadedProfit);
  }

  /**
   * Investors can claim profit if loaded.
   */
  function fetchProfit() public returns(bool) {
    require(ditributingProfit);
    require(!hasFetchedProfit[msg.sender]);
    uint NBCBalanceOfFetcher = balanceOf(msg.sender);
    require(NBCBalanceOfFetcher != 0);

    uint weiValue = safeMul(loadedProfit,NBCBalanceOfFetcher)/totalSupply;
    require(weiValue >= msg.gas);

    loadedProfitAvailable = safeSub(loadedProfitAvailable, weiValue);
    hasFetchedProfit[msg.sender] = true;

    profitDistributed = safeAdd(profitDistributed, weiValue);

      if(loadedProfitAvailable <= 0) { 
       ditributingProfit = false;
        loadedProfit = 0;
    }

    require(msg.sender.send(weiValue)); 
    // require(msg.sender.call.value(weiValue) == true);
    ProfitDelivered(msg.sender, weiValue);
    
  }

  /**
   * Allow owner to unload the loaded profit which could not be claimed.
   * Owner must be responsible to call it at the right time.
   * 
   */
  function fetchUndistributedProfit() public onlyOwner {
    require(loadedProfitAvailable != 0);
    require(msg.sender.send(loadedProfitAvailable));
    loadedProfitAvailable = 0;
    ditributingProfit = false;
    loadedProfit = 0;
  }

}

/**
 * Finalize agent defines what happens at the end of succeseful crowdsale.
 *
 * - Allocate tokens for founders, bounties and community
 * - Make tokens transferable
 * - etc.
 */
contract FinalizeAgent {

  function isFinalizeAgent() public constant returns(bool) {
    return true;
  }

  /** Return true if we can run finalizeCrowdsale() properly.
   *
   * This is a safety check function that doesn't allow crowdsale to begin
   * unless the finalizer has been set up properly.
   */
  function isSane() public constant returns (bool);

  /** Called once by crowdsale finalize() if the sale was success. */
  function finalizeCrowdsale();

}

/**
 * Interface for defining crowdsale pricing.
 */
contract PricingStrategy {

  /** Interface declaration. */
  function isPricingStrategy() public constant returns (bool) {
    return true;
  }

  /** Self check if all references are correctly set.
   *
   * Checks that pricing strategy matches crowdsale parameters.
   */
  function isSane(address crowdsale) public constant returns (bool) {
    return true;
  }

  /**
   * When somebody tries to buy tokens for X eth, calculate how many tokens they get.
   *
   *
   * @param value - What is the value of the transaction send in as wei
   * @param tokensSold - how much tokens have been sold this far
   * @param weiRaised - how much money has been raised this far
   * @param msgSender - who is the investor of this transaction
   * @param decimals - how many decimal units the token has
   * @return Amount of tokens the investor receives
   */
  function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
}

/*
 * Haltable
 *
 * Abstract contract that allows children to implement an
 * emergency stop mechanism. Differs from Pausable by causing a throw when in halt mode.
 *
 *
 * Originally envisioned in FirstBlood ICO contract.
 */
contract Haltable is Ownable {
  bool public halted;

  modifier stopInEmergency {
    require(!halted);
    //if (halted) throw;
    _;
  }

  modifier onlyInEmergency {
    require(halted);
    //if (!halted) throw;
    _;
  }

  // called by the owner on emergency, triggers stopped state
  function halt() external onlyOwner {
    halted = true;
  }

  // called by the owner on end of emergency, returns to normal state
  function unhalt() external onlyOwner onlyInEmergency {
    halted = false;
  }

}

/**
 * Abstract base contract for token sales.
 *
 * Handle
 * - start and end dates
 * - accepting investments
 * - minimum funding goal and refund
 * - various statistics during the crowdfund
 * - different pricing strategies
 * - different investment policies (require server side customer id, allow only whitelisted addresses)
 *
 */
contract Crowdsale is Haltable, SafeMathLib {

  /* Max investment count when we are still allowed to change the multisig address */
  uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5;

  /* The token we are selling */
  FractionalERC20 public token;

  /* How we are going to price our offering */
  PricingStrategy public pricingStrategy;

  /* Post-success callback */
  FinalizeAgent public finalizeAgent;

  /* tokens will be transfered from this address */
  address public multisigWallet;

  /* if the funding goal is not reached, investors may withdraw their funds */
  uint public minimumFundingGoal;

  /* the UNIX timestamp start date of the crowdsale */
  uint public startsAt;

  /* the UNIX timestamp end date of the crowdsale */
  uint public endsAt;

  /* the number of tokens already sold through this contract*/
  uint public tokensSold = 0;

  /* How many wei of funding we have raised */
  uint public weiRaised = 0;

  /* How many distinct addresses have invested */
  uint public investorCount = 0;

  /* How much wei we have returned back to the contract after a failed crowdfund. */
  uint public loadedRefund = 0;

  /* How much wei we have given back to investors.*/
  uint public weiRefunded = 0;

  /* Has this crowdsale been finalized */
  bool public finalized;

  /* Do we need to have unique contributor id for each customer */
  bool public requireCustomerId;

  /**
    * Do we verify that contributor has been cleared on the server side (accredited investors only).
    * This method was first used in FirstBlood crowdsale to ensure all contributors have accepted terms on sale (on the web).
    */
  bool public requiredSignedAddress;

  /* Server side address that signed allowed contributors (Ethereum addresses) that can participate the crowdsale */
  address public signerAddress;

  /** How much ETH each address has invested to this crowdsale */
  mapping (address => uint256) public investedAmountOf;

  /** How much tokens this crowdsale has credited for each investor address */
  mapping (address => uint256) public tokenAmountOf;

  /** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
  mapping (address => bool) public earlyParticipantWhitelist;

  /** This is for manul testing for the interaction from owner wallet. You can set it to any value and inspect this in blockchain explorer to see that crowdsale interaction works. */
  uint public ownerTestValue;

  /** State machine
   *
   * - Preparing: All contract initialization calls and variables have not been set yet
   * - Prefunding: We have not passed start time yet
   * - Funding: Active crowdsale
   * - Success: Minimum funding goal reached
   * - Failure: Minimum funding goal not reached before ending time
   * - Finalized: The finalized has been called and succesfully executed
   * - Refunding: Refunds are loaded on the contract for reclaim.
   */
  enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding}

  // A new investment was made
  event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);

  // Refund was processed for a contributor
  event Refund(address investor, uint weiAmount);

  // The rules were changed what kind of investments we accept
  event InvestmentPolicyChanged(bool requireCustomerId, bool requiredSignedAddress, address signerAddress);

  // Address early participation whitelist status changed
  event Whitelisted(address addr, bool status);

  // Crowdsale end time has been changed
  event EndsAtChanged(uint endsAt);

  function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) {

    owner = msg.sender;

    token = FractionalERC20(_token);

    setPricingStrategy(_pricingStrategy);

    multisigWallet = _multisigWallet;
    require(multisigWallet != 0);
    // if(multisigWallet == 0) {
    //     throw;
    // }

    require(_start != 0);
    // if(_start == 0) {
    //     throw;
    // }

    startsAt = _start;

    require(_end != 0);
    // if(_end == 0) {
    //     throw;
    // }

    endsAt = _end;

    // Don't mess the dates
    require(startsAt < endsAt);
    // if(startsAt >= endsAt) {
    //     throw;
    // }

    // Minimum funding goal can be zero
    minimumFundingGoal = _minimumFundingGoal;
  }

  /**
   * Don't expect to just send in money and get tokens.
   */
  function() payable {
    require(false);
  }

  /**
   * Make an investment.
   *
   * Crowdsale must be running for one to invest.
   * We must have not pressed the emergency brake.
   *
   * @param receiver The Ethereum address who receives the tokens
   * @param customerId (optional) UUID v4 to track the successful payments on the server side
   *
   */
  function investInternal(address receiver, uint128 customerId) stopInEmergency private {

    // Determine if it's a good time to accept investment from this participant
    if(getState() == State.PreFunding) {
      // Are we whitelisted for early deposit
      require(earlyParticipantWhitelist[receiver]);
      // if(!earlyParticipantWhitelist[receiver]) {
      //   throw;
      // }
    } else if(getState() == State.Funding) {
      // Retail participants can only come in when the crowdsale is running
      // pass
    } else {
      // Unwanted state
      require(false);
    }

    uint weiAmount = msg.value;
    uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());

    require(tokenAmount != 0);
    // if(tokenAmount == 0) {
    //   // Dust transaction
    //   throw;
    // }

    if(investedAmountOf[receiver] == 0) {
       // A new investor
       investorCount++;
    }

    // Update investor
    investedAmountOf[receiver] = safeAdd(investedAmountOf[receiver],weiAmount);
    tokenAmountOf[receiver] = safeAdd(tokenAmountOf[receiver],tokenAmount);

    // Update totals
    weiRaised = safeAdd(weiRaised,weiAmount);
    tokensSold = safeAdd(tokensSold,tokenAmount);

    // Check that we did not bust the cap
    require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold));
    // if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) {
    //   throw;
    // }

    assignTokens(receiver, tokenAmount);

    // Pocket the money
    require(multisigWallet.send(weiAmount));

    // Tell us invest was success
    Invested(receiver, weiAmount, tokenAmount, customerId);
  }

  /**
   * Preallocate tokens for the early investors.
   *
   * Preallocated tokens have been sold before the actual crowdsale opens.
   * This function mints the tokens and moves the crowdsale needle.
   *
   * Investor count is not handled; it is assumed this goes for multiple investors
   * and the token distribution happens outside the smart contract flow.
   *
   * No money is exchanged, as the crowdsale team already have received the payment.
   *
   * @param fullTokens tokens as full tokens - decimal places added internally
   * @param weiPrice Price of a single full token in wei
   *
   */
  function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {

    uint tokenAmount = fullTokens * 10**uint(token.decimals());
    uint weiAmount = weiPrice * fullTokens; // This can be also 0, we give out tokens for free

    weiRaised = safeAdd(weiRaised,weiAmount);
    tokensSold = safeAdd(tokensSold,tokenAmount);

    investedAmountOf[receiver] = safeAdd(investedAmountOf[receiver],weiAmount);
    tokenAmountOf[receiver] = safeAdd(tokenAmountOf[receiver],tokenAmount);

    assignTokens(receiver, tokenAmount);

    // Tell us invest was success
    Invested(receiver, weiAmount, tokenAmount, 0);
  }

  /**
   * Allow anonymous contributions to this crowdsale.
   */
  // function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
  //    bytes32 hash = sha256(addr);
  //    if (ecrecover(hash, v, r, s) != signerAddress) throw;
  //    require(customerId != 0);
  //    //if(customerId == 0) throw;  // UUIDv4 sanity check
  //    investInternal(addr, customerId);
  // }

  /**
   * Track who is the customer making the payment so we can send thank you email.
   */
  function investWithCustomerId(address addr, uint128 customerId) public payable {
    require(!requiredSignedAddress);
    //if(requiredSignedAddress) throw; // Crowdsale allows only server-side signed participants
    
    require(customerId != 0);
    //if(customerId == 0) throw;  // UUIDv4 sanity check
    investInternal(addr, customerId);
  }

  /**
   * Allow anonymous contributions to this crowdsale.
   */
  function invest(address addr) public payable {
    require(!requireCustomerId);
    //if(requireCustomerId) throw; // Crowdsale needs to track partipants for thank you email
    
    require(!requiredSignedAddress);
    //if(requiredSignedAddress) throw; // Crowdsale allows only server-side signed participants
    investInternal(addr, 0);
  }

  /**
   * Invest to tokens, recognize the payer and clear his address.
   *
   */
  
  // function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
  //   investWithSignedAddress(msg.sender, customerId, v, r, s);
  // }

  /**
   * Invest to tokens, recognize the payer.
   *
   */
  function buyWithCustomerId(uint128 customerId) public payable {
    investWithCustomerId(msg.sender, customerId);
  }

  /**
   * The basic entry point to participate the crowdsale process.
   *
   * Pay for funding, get invested tokens back in the sender address.
   */
  function buy() public payable {
    invest(msg.sender);
  }

  /**
   * Finalize a succcesful crowdsale.
   *
   * The owner can triggre a call the contract that provides post-crowdsale actions, like releasing the tokens.
   */
  function finalize() public inState(State.Success) onlyOwner stopInEmergency {

    // Already finalized
    require(!finalized);
    // if(finalized) {
    //   throw;
    // }

    // Finalizing is optional. We only call it if we are given a finalizing agent.
    if(address(finalizeAgent) != 0) {
      finalizeAgent.finalizeCrowdsale();
    }

    finalized = true;
  }

  /**
   * Allow to (re)set finalize agent.
   *
   * Design choice: no state restrictions on setting this, so that we can fix fat finger mistakes.
   */
  function setFinalizeAgent(FinalizeAgent addr) onlyOwner {
    finalizeAgent = addr;

    // Don't allow setting bad agent
    require(finalizeAgent.isFinalizeAgent());
    // if(!finalizeAgent.isFinalizeAgent()) {
    //   throw;
    // }
  }

  /**
   * Set policy do we need to have server-side customer ids for the investments.
   *
   */
  function setRequireCustomerId(bool value) onlyOwner {
    requireCustomerId = value;
    InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
  }

  /**
   * Set policy if all investors must be cleared on the server side first.
   *
   * This is e.g. for the accredited investor clearing.
   *
   */
  // function setRequireSignedAddress(bool value, address _signerAddress) onlyOwner {
  //   requiredSignedAddress = value;
  //   signerAddress = _signerAddress;
  //   InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
  // }

  /**
   * Allow addresses to do early participation.
   *
   * TODO: Fix spelling error in the name
   */
  function setEarlyParicipantWhitelist(address addr, bool status) onlyOwner {
    earlyParticipantWhitelist[addr] = status;
    Whitelisted(addr, status);
  }

  /**
   * Allow crowdsale owner to close early or extend the crowdsale.
   *
   * This is useful e.g. for a manual soft cap implementation:
   * - after X amount is reached determine manual closing
   *
   * This may put the crowdsale to an invalid state,
   * but we trust owners know what they are doing.
   *
   */
  function setEndsAt(uint time) onlyOwner {

    require(now <= time);

    endsAt = time;
    EndsAtChanged(endsAt);
  }

  /**
   * Allow to (re)set pricing strategy.
   *
   * Design choice: no state restrictions on the set, so that we can fix fat finger mistakes.
   */
  function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner {
    pricingStrategy = _pricingStrategy;

    // Don't allow setting bad agent
    require(pricingStrategy.isPricingStrategy());
    // if(!pricingStrategy.isPricingStrategy()) {
    //   throw;
    // }
  }

  /**
   * Allow to change the team multisig address in the case of emergency.
   *
   * This allows to save a deployed crowdsale wallet in the case the crowdsale has not yet begun
   * (we have done only few test transactions). After the crowdsale is going
   * then multisig address stays locked for the safety reasons.
   */
  function setMultisig(address addr) public onlyOwner {

    // Change
    require(investorCount <= MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE);

    multisigWallet = addr;
  }

  /**
   * Allow load refunds back on the contract for the refunding.
   *
   * The team can transfer the funds back on the smart contract in the case the minimum goal was not reached..
   */
  function loadRefund() public payable inState(State.Failure) {
    require(msg.value != 0);
    //if(msg.value == 0) throw;
    loadedRefund = safeAdd(loadedRefund,msg.value);
  }

  /**
   * Investors can claim refund.
   */
  function refund() public inState(State.Refunding) {
    uint256 weiValue = investedAmountOf[msg.sender];
    require(weiValue != 0);
    //if (weiValue == 0) throw;
    investedAmountOf[msg.sender] = 0;
    weiRefunded = safeAdd(weiRefunded,weiValue);
    Refund(msg.sender, weiValue);
    require(msg.sender.send(weiValue));
  }

  /**
   * @return true if the crowdsale has raised enough money to be a succes
   */
  function isMinimumGoalReached() public constant returns (bool reached) {
    return weiRaised >= minimumFundingGoal;
  }

  /**
   * Check if the contract relationship looks good.
   */
  function isFinalizerSane() public constant returns (bool sane) {
    return finalizeAgent.isSane();
  }

  /**
   * Check if the contract relationship looks good.
   */
  function isPricingSane() public constant returns (bool sane) {
    return pricingStrategy.isSane(address(this));
  }

  /**
   * Crowdfund state machine management.
   *
   * We make it a function and do not assign the result to a variable, so there is no chance of the variable being stale.
   */
  function getState() public constant returns (State) {
    if(finalized) return State.Finalized;
    else if (address(finalizeAgent) == 0) return State.Preparing;
    else if (!finalizeAgent.isSane()) return State.Preparing;
    else if (!pricingStrategy.isSane(address(this))) return State.Preparing;
    else if (block.timestamp < startsAt) return State.PreFunding;
    else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding;
    else if (isMinimumGoalReached()) return State.Success;
    else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
    else return State.Failure;
  }

  /** This is for manual testing of multisig wallet interaction */
  function setOwnerTestValue(uint val) onlyOwner {
    ownerTestValue = val;
  }

  /** Interface marker. */
  function isCrowdsale() public constant returns (bool) {
    return true;
  }

  //
  // Modifiers
  //

  /** Modified allowing execution only if the crowdsale is currently running.  */
  modifier inState(State state) {
    require(getState() == state);
    //if(getState() != state) throw;
    _;
  }


  //
  // Abstract functions
  //

  /**
   * Check if the current invested breaks our cap rules.
   *
   *
   * The child contract must define their own cap setting rules.
   * We allow a lot of flexibility through different capping strategies (ETH, token count)
   * Called from invest().
   *
   * @param weiAmount The amount of wei the investor tries to invest in the current transaction
   * @param tokenAmount The amount of tokens we try to give to the investor in the current transaction
   * @param weiRaisedTotal What would be our total raised balance after this transaction
   * @param tokensSoldTotal What would be our total sold tokens count after this transaction
   *
   * @return true if taking this investment would break our cap rules
   */
  function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken);
  /**
   * Check if the current crowdsale is full and we can no longer sell any tokens.
   */
  function isCrowdsaleFull() public constant returns (bool);

  /**
   * Create new tokens or transfer issued tokens to the investor depending on the cap model.
   */
  function assignTokens(address receiver, uint tokenAmount) private;
}

/**
 * At the end of the successful crowdsale allocate % bonus of tokens to the team.
 *
 * Unlock tokens.
 *
 * BonusAllocationFinal must be set as the minting agent for the MintableToken.
 *
 */
contract BonusFinalizeAgent is FinalizeAgent, SafeMathLib {

  CrowdsaleToken public token;
  Crowdsale public crowdsale;

  /** Total percent of tokens minted to the team at the end of the sale as base points (0.0001) */
  uint public totalMembers;
  // Per address % of total token raised to be assigned to the member Ex 1% is passed as 100
  uint public allocatedBonus;
  mapping (address=>uint) bonusOf;
  /** Where we move the tokens at the end of the sale. */
  address[] public teamAddresses;


  function BonusFinalizeAgent(CrowdsaleToken _token, Crowdsale _crowdsale, uint[] _bonusBasePoints, address[] _teamAddresses) {
    token = _token;
    crowdsale = _crowdsale;

    //crowdsale address must not be 0
    require(address(crowdsale) != 0);

    //bonus & team address array size must match
    require(_bonusBasePoints.length == _teamAddresses.length);

    totalMembers = _teamAddresses.length;
    teamAddresses = _teamAddresses;
    
    //if any of the bonus is 0 throw
    // otherwise sum it up in totalAllocatedBonus
    for (uint i=0;i<totalMembers;i++){
      require(_bonusBasePoints[i] != 0);
      //if(_bonusBasePoints[i] == 0) throw;
    }

    //if any of the address is 0 or invalid throw
    //otherwise initialize the bonusOf array
    for (uint j=0;j<totalMembers;j++){
      require(_teamAddresses[j] != 0);
      //if(_teamAddresses[j] == 0) throw;
      bonusOf[_teamAddresses[j]] = _bonusBasePoints[j];
    }
  }

  /* Can we run finalize properly */
  function isSane() public constant returns (bool) {
    return (token.mintAgents(address(this)) == true) && (token.releaseAgent() == address(this));
  }

  /** Called once by crowdsale finalize() if the sale was success. */
  function finalizeCrowdsale() {

    // if finalized is not being called from the crowdsale 
    // contract then throw
    require(msg.sender == address(crowdsale));

    // if(msg.sender != address(crowdsale)) {
    //   throw;
    // }

    // get the total sold tokens count.
    uint tokensSold = crowdsale.tokensSold();

    for (uint i=0;i<totalMembers;i++) {
      allocatedBonus = safeMul(tokensSold, bonusOf[teamAddresses[i]]) / 10000;
      // move tokens to the team multisig wallet
      
      // Give min bonus to advisor as committed
      // the last address is the advisor address
      uint minBonus = 1000000 * 1000000000000000000;
      if (i == totalMembers-1 && allocatedBonus < minBonus)
        allocatedBonus = minBonus;

      token.mint(teamAddresses[i], allocatedBonus);
    }

    // Make token transferable
    // realease them in the wild
    // Hell yeah!!! we did it.
    token.releaseTokenTransfer();
  }

}


/**
 * ICO crowdsale contract that is capped by amout of ETH.
 *
 * - Tokens are dynamically created during the crowdsale
 *
 *
 */
contract MintedEthCappedCrowdsale is Crowdsale {

  /* Maximum amount of wei this crowdsale can raise. */
  uint public weiCap;

  function MintedEthCappedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _weiCap) Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) {
    weiCap = _weiCap;
  }

  /**
   * Called from invest() to confirm if the curret investment does not break our cap rule.
   */
  function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) {
    return weiRaisedTotal > weiCap;
  }

  function isCrowdsaleFull() public constant returns (bool) {
    return weiRaised >= weiCap;
  }

  /**
   * Dynamically create tokens and assign them to the investor.
   */
  function assignTokens(address receiver, uint tokenAmount) private {
    MintableToken mintableToken = MintableToken(token);
    mintableToken.mint(receiver, tokenAmount);
  }
}

/** Tranche based pricing with special support for pre-ico deals.
 *      Implementing "first price" tranches, meaning, that if byers order is
 *      covering more than one tranche, the price of the lowest tranche will apply
 *      to the whole order.
 */
contract EthTranchePricing is PricingStrategy, Ownable, SafeMathLib {

  uint public constant MAX_TRANCHES = 10;
 
 
  // This contains all pre-ICO addresses, and their prices (weis per token)
  mapping (address => uint) public preicoAddresses;

  /**
  * Define pricing schedule using tranches.
  */

  struct Tranche {
      // Amount in weis when this tranche becomes active
      uint amount;
      // How many tokens per wei you will get while this tranche is active
      uint price;
  }

  // Store tranches in a fixed array, so that it can be seen in a blockchain explorer
  // Tranche 0 is always (0, 0)
  // (TODO: change this when we confirm dynamic arrays are explorable)
  Tranche[10] public tranches;

  // How many active tranches we have
  uint public trancheCount;

  /// @dev Contruction, creating a list of tranches
  /// @param _tranches uint[] tranches Pairs of (start amount, price)
  function EthTranchePricing(uint[] _tranches) {
    // [ 0, 666666666666666,
    //   3000000000000000000000, 769230769230769,
    //   5000000000000000000000, 909090909090909,
    //   8000000000000000000000, 952380952380952,
    //   2000000000000000000000, 1000000000000000 ]
    // Need to have tuples, length check
    require(!(_tranches.length % 2 == 1 || _tranches.length >= MAX_TRANCHES*2));
    // if(_tranches.length % 2 == 1 || _tranches.length >= MAX_TRANCHES*2) {
    //   throw;
    // }
    trancheCount = _tranches.length / 2;
    uint highestAmount = 0;
    for(uint i=0; i<_tranches.length/2; i++) {
      tranches[i].amount = _tranches[i*2];
      tranches[i].price = _tranches[i*2+1];
      // No invalid steps
      require(!((highestAmount != 0) && (tranches[i].amount <= highestAmount)));
      // if((highestAmount != 0) && (tranches[i].amount <= highestAmount)) {
      //   throw;
      // }
      highestAmount = tranches[i].amount;
    }

    // We need to start from zero, otherwise we blow up our deployment
    require(tranches[0].amount == 0);
    // if(tranches[0].amount != 0) {
    //   throw;
    // }

    // Last tranche price must be zero, terminating the crowdale
    require(tranches[trancheCount-1].price == 0);
    // if(tranches[trancheCount-1].price != 0) {
    //   throw;
    // }
  }

  /// @dev This is invoked once for every pre-ICO address, set pricePerToken
  ///      to 0 to disable
  /// @param preicoAddress PresaleFundCollector address
  /// @param pricePerToken How many weis one token cost for pre-ico investors
  function setPreicoAddress(address preicoAddress, uint pricePerToken)
    public
    onlyOwner
  {
    preicoAddresses[preicoAddress] = pricePerToken;
  }

  /// @dev Iterate through tranches. You reach end of tranches when price = 0
  /// @return tuple (time, price)
  function getTranche(uint n) public constant returns (uint, uint) {
    return (tranches[n].amount, tranches[n].price);
  }

  function getFirstTranche() private constant returns (Tranche) {
    return tranches[0];
  }

  function getLastTranche() private constant returns (Tranche) {
    return tranches[trancheCount-1];
  }

  function getPricingStartsAt() public constant returns (uint) {
    return getFirstTranche().amount;
  }

  function getPricingEndsAt() public constant returns (uint) {
    return getLastTranche().amount;
  }

  function isSane(address _crowdsale) public constant returns(bool) {
    // Our tranches are not bound by time, so we can't really check are we sane
    // so we presume we are ;)
    // In the future we could save and track raised tokens, and compare it to
    // the Crowdsale contract.
    return true;
  }

  /// @dev Get the current tranche or bail out if we are not in the tranche periods.
  /// @param weiRaised total amount of weis raised, for calculating the current tranche
  /// @return {[type]} [description]
  function getCurrentTranche(uint weiRaised) private constant returns (Tranche) {
    uint i;
    for(i=0; i < tranches.length; i++) {
      if(weiRaised < tranches[i].amount) {
        return tranches[i-1];
      }
    }
  }

  /// @dev Get the current price.
  /// @param weiRaised total amount of weis raised, for calculating the current tranche
  /// @return The current price or 0 if we are outside trache ranges
  function getCurrentPrice(uint weiRaised) public constant returns (uint result) {
    return getCurrentTranche(weiRaised).price;
  }

  /// @dev Calculate the current price for buy in amount.
  function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint) {

    uint multiplier = 10 ** decimals;

    // This investor is coming through pre-ico
    if(preicoAddresses[msgSender] > 0) {
      return safeMul(value, multiplier) / preicoAddresses[msgSender];
    }

    uint price = getCurrentPrice(weiRaised);
    
    return safeMul(value, multiplier) / price;
  }

  function() payable {
    require(false); // No money on this contract
  }

}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"ownerTestValue","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"requireCustomerId","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"invest","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"isPricingSane","outputs":[{"name":"sane","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"endsAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minimumFundingGoal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getState","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"setFinalizeAgent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"investedAmountOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"finalizeAgent","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"receiver","type":"address"},{"name":"fullTokens","type":"uint256"},{"name":"weiPrice","type":"uint256"}],"name":"preallocate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"weiRaised","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCrowdsale","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finalize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_pricingStrategy","type":"address"}],"name":"setPricingStrategy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tokensSold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"refund","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"signerAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"weiRefunded","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"halt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"time","type":"uint256"}],"name":"setEndsAt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"pricingStrategy","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"loadedRefund","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isMinimumGoalReached","outputs":[{"name":"reached","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"bool"}],"name":"setRequireCustomerId","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"weiCap","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"loadRefund","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"val","type":"uint256"}],"name":"setOwnerTestValue","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"multisigWallet","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"tokenAmountOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"customerId","type":"uint128"}],"name":"buyWithCustomerId","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"weiAmount","type":"uint256"},{"name":"tokenAmount","type":"uint256"},{"name":"weiRaisedTotal","type":"uint256"},{"name":"tokensSoldTotal","type":"uint256"}],"name":"isBreakingCap","outputs":[{"name":"limitBroken","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"buy","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"isFinalizerSane","outputs":[{"name":"sane","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"startsAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"finalized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"halted","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"earlyParticipantWhitelist","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unhalt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"requiredSignedAddress","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCrowdsaleFull","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"investorCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"},{"name":"status","type":"bool"}],"name":"setEarlyParicipantWhitelist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"},{"name":"customerId","type":"uint128"}],"name":"investWithCustomerId","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"setMultisig","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_token","type":"address"},{"name":"_pricingStrategy","type":"address"},{"name":"_multisigWallet","type":"address"},{"name":"_start","type":"uint256"},{"name":"_end","type":"uint256"},{"name":"_minimumFundingGoal","type":"uint256"},{"name":"_weiCap","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"investor","type":"address"},{"indexed":false,"name":"weiAmount","type":"uint256"},{"indexed":false,"name":"tokenAmount","type":"uint256"},{"indexed":false,"name":"customerId","type":"uint128"}],"name":"Invested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"investor","type":"address"},{"indexed":false,"name":"weiAmount","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"requireCustomerId","type":"bool"},{"indexed":false,"name":"requiredSignedAddress","type":"bool"},{"indexed":false,"name":"signerAddress","type":"address"}],"name":"InvestmentPolicyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"addr","type":"address"},{"indexed":false,"name":"status","type":"bool"}],"name":"Whitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"endsAt","type":"uint256"}],"name":"EndsAtChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

  Contract Creation Code Switch To Opcodes View
606060405260056002556000600a556000600b556000600c556000600d556000600e5534156200002e57600080fd5b60405160e08062001d87833981016040528080519190602001805191906020018051919060200180519190602001805191906020018051919060200180519150505b8686868686865b5b60008054600160a060020a03191633600160a060020a03161790555b60008054600160a060020a03338116600160a060020a0319928316179092556003805492891692909116919091179055620000dd85640100000000620010116200015e82021704565b60068054600160a060020a031916600160a060020a0386811691909117918290551615156200010b57600080fd5b8215156200011857600080fd5b60088390558115156200012a57600080fd5b60098290556008548290106200013f57600080fd5b60078190555b50505060148490555050505b505050505050506200021f565b60005433600160a060020a039081169116146200017a57600080fd5b60048054600160a060020a031916600160a060020a038381169190911791829055166304bbc2556000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1515620001f257600080fd5b6102c65a03f115156200020457600080fd5b5050506040518051905015156200021a57600080fd5b5b5b50565b611b58806200022f6000396000f3006060604052361561026c5763ffffffff60e060020a6000350416630226401d811461027557806303ca0eed1461029a57806303f9c793146102c1578063062b01ce146102d75780630a09284a146102fe57806313f4e977146103235780631865c57d1461034857806319b667da1461037f5780631aae3460146103a057806321d5c0f6146103d157806332013ac3146104005780634042b66f146104275780634551dd591461044c5780634bb278f31461047357806350c6773414610488578063518ab2a8146104a9578063590e1ae3146104ce5780635b7633d0146104e35780635da89ac0146105125780635ed7ca5b146105375780636203f09f1461054c5780636e50eb3f1461057157806378b99c2414610589578063797d9437146105b857806379ba5097146105dd5780637c2e08a3146105f25780637f7d711e1461061957806384fe50291461063357806387612102146106585780638d51faec146106625780638da5cb5b1461067a5780639075becf146106a957806397b150ca146106d857806399e9376c146107095780639d3c663f14610728578063a293d1e81461075b578063a6f2ae3a14610786578063a7ba44c314610790578063af468682146107b7578063b3f05b97146107dc578063b9b8af0b14610803578063cb16e6d01461082a578063cb3e64fd1461085d578063d05c78da14610872578063d222dc041461089d578063d4ee1d90146108c4578063d5d09021146108f3578063d7e64c001461091a578063e6cb90131461093f578063eac249321461096a578063ef86944314610990578063f2fde38b146109bb578063f3283fba146109dc578063fc0c546a146109fd575b5b600080fd5b5b005b341561028057600080fd5b610288610a2c565b60405190815260200160405180910390f35b34156102a557600080fd5b6102ad610a32565b604051901515815260200160405180910390f35b610272600160a060020a0360043516610a40565b005b34156102e257600080fd5b6102ad610a7a565b604051901515815260200160405180910390f35b341561030957600080fd5b610288610af5565b60405190815260200160405180910390f35b341561032e57600080fd5b610288610afb565b60405190815260200160405180910390f35b341561035357600080fd5b61035b610b01565b6040518082600781111561036b57fe5b60ff16815260200191505060405180910390f35b341561038a57600080fd5b610272600160a060020a0360043516610cb6565b005b34156103ab57600080fd5b610288600160a060020a0360043516610d67565b60405190815260200160405180910390f35b34156103dc57600080fd5b6103e4610d79565b604051600160a060020a03909116815260200160405180910390f35b341561040b57600080fd5b610272600160a060020a0360043516602435604435610d88565b005b341561043257600080fd5b610288610f29565b60405190815260200160405180910390f35b341561045757600080fd5b6102ad610f2f565b604051901515815260200160405180910390f35b341561047e57600080fd5b610272610f35565b005b341561049357600080fd5b610272600160a060020a0360043516611011565b005b34156104b457600080fd5b6102886110c2565b60405190815260200160405180910390f35b34156104d957600080fd5b6102726110c8565b005b34156104ee57600080fd5b6103e46111b6565b604051600160a060020a03909116815260200160405180910390f35b341561051d57600080fd5b6102886111cc565b60405190815260200160405180910390f35b341561054257600080fd5b6102726111d2565b005b341561055757600080fd5b610288611215565b60405190815260200160405180910390f35b341561057c57600080fd5b61027260043561121b565b005b341561059457600080fd5b6103e4611281565b604051600160a060020a03909116815260200160405180910390f35b34156105c357600080fd5b610288611290565b60405190815260200160405180910390f35b34156105e857600080fd5b610272611296565b005b34156105fd57600080fd5b6102ad611322565b604051901515815260200160405180910390f35b341561062457600080fd5b610272600435151561132e565b005b341561063e57600080fd5b6102886113d7565b60405190815260200160405180910390f35b6102726113dd565b005b341561066d57600080fd5b61027260043561141e565b005b341561068557600080fd5b6103e4611443565b604051600160a060020a03909116815260200160405180910390f35b34156106b457600080fd5b6103e4611452565b604051600160a060020a03909116815260200160405180910390f35b34156106e357600080fd5b610288600160a060020a0360043516611461565b60405190815260200160405180910390f35b6102726fffffffffffffffffffffffffffffffff60043516611473565b005b341561073357600080fd5b6102ad600435602435604435606435611481565b604051901515815260200160405180910390f35b341561076657600080fd5b61028860043560243561148f565b60405190815260200160405180910390f35b6102726114a6565b005b341561079b57600080fd5b6102ad6114b2565b604051901515815260200160405180910390f35b34156107c257600080fd5b61028861151c565b60405190815260200160405180910390f35b34156107e757600080fd5b6102ad611522565b604051901515815260200160405180910390f35b341561080e57600080fd5b6102ad61152b565b604051901515815260200160405180910390f35b341561083557600080fd5b6102ad600160a060020a036004351661153b565b604051901515815260200160405180910390f35b341561086857600080fd5b610272611550565b005b341561087d57600080fd5b6102886004356024356115a6565b60405190815260200160405180910390f35b34156108a857600080fd5b6102ad6115d5565b604051901515815260200160405180910390f35b34156108cf57600080fd5b6103e46115e4565b604051600160a060020a03909116815260200160405180910390f35b34156108fe57600080fd5b6102ad6115f3565b604051901515815260200160405180910390f35b341561092557600080fd5b6102886115ff565b60405190815260200160405180910390f35b341561094a57600080fd5b610288600435602435611605565b60405190815260200160405180910390f35b341561097557600080fd5b610272600160a060020a0360043516602435151561161f565b005b610272600160a060020a03600435166fffffffffffffffffffffffffffffffff602435166116ad565b005b34156109c657600080fd5b610272600160a060020a03600435166116f0565b005b34156109e757600080fd5b610272600160a060020a0360043516611738565b005b3415610a0857600080fd5b6103e4611791565b604051600160a060020a03909116815260200160405180910390f35b60135481565b600f54610100900460ff1681565b600f54610100900460ff1615610a5557600080fd5b600f5462010000900460ff1615610a6b57600080fd5b610a768160006117a0565b5b50565b600454600090600160a060020a0316638e76828830836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610ad557600080fd5b6102c65a03f11515610ae657600080fd5b50505060405180519150505b90565b60095481565b60075481565b600f5460009060ff1615610b1757506006610af2565b600554600160a060020a03161515610b3157506001610af2565b600554600160a060020a03166382771c8e6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610b7957600080fd5b6102c65a03f11515610b8a57600080fd5b505050604051805190501515610ba257506001610af2565b600454600160a060020a0316638e7682883060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610bfb57600080fd5b6102c65a03f11515610c0c57600080fd5b505050604051805190501515610c2457506001610af2565b600854421015610c3657506002610af2565b6009544211158015610c4d5750610c4b6115f3565b155b15610c5a57506003610af2565b610c62611322565b15610c6f57506004610af2565b610c77611322565b158015610c8657506000600b54115b8015610c965750600b54600d5410155b15610ca357506007610af2565b506005610af2565b5b5b5b5b5b5b5b5b90565b60005433600160a060020a03908116911614610cd157600080fd5b6005805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290551663614cb9046000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610d3c57600080fd5b6102c65a03f11515610d4d57600080fd5b505050604051805190501515610a7657600080fd5b5b5b50565b60106020526000908152604090205481565b600554600160a060020a031681565b60008054819033600160a060020a03908116911614610da657600080fd5b600354600160a060020a031663313ce5676000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610dee57600080fd5b6102c65a03f11515610dff57600080fd5b5050506040518051905060ff16600a0a840291508383029050610e24600b5482611605565b600b55600a54610e349083611605565b600a55600160a060020a038516600090815260106020526040902054610e5a9082611605565b600160a060020a038616600090815260106020908152604080832093909355601190522054610e899083611605565b600160a060020a038616600090815260116020526040902055610eac8583611abb565b7f0396f60aaad038749091d273dc13aaabc63db6e2271c7bad442d5cf25cc4335085828460006040518085600160a060020a0316600160a060020a03168152602001848152602001838152602001826fffffffffffffffffffffffffffffffff16815260200194505050505060405180910390a15b5b5050505050565b600b5481565b60015b90565b6004805b610f41610b01565b6007811115610f4c57fe5b14610f5657600080fd5b60005433600160a060020a03908116911614610f7157600080fd5b60015460a060020a900460ff1615610f8857600080fd5b600f5460ff1615610f9857600080fd5b600554600160a060020a031615610ffd57600554600160a060020a0316630bf318a36040518163ffffffff1660e060020a028152600401600060405180830381600087803b1515610fe857600080fd5b6102c65a03f11515610ff957600080fd5b5050505b600f805460ff191660011790555b5b5b5b50565b60005433600160a060020a0390811691161461102c57600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911791829055166304bbc2556000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610d3c57600080fd5b6102c65a03f11515610d4d57600080fd5b505050604051805190501515610a7657600080fd5b5b5b50565b600a5481565b60006007805b6110d6610b01565b60078111156110e157fe5b146110eb57600080fd5b600160a060020a033316600090815260106020526040902054915081151561111257600080fd5b600160a060020a033316600090815260106020526040812055600e546111389083611605565b600e557fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d3383604051600160a060020a03909216825260208201526040908101905180910390a1600160a060020a03331682156108fc0283604051600060405180830381858888f1935050505015156111b057600080fd5b5b5b5050565b600f5463010000009004600160a060020a031681565b600e5481565b60005433600160a060020a039081169116146111ed57600080fd5b6001805474ff0000000000000000000000000000000000000000191660a060020a1790555b5b565b60025481565b60005433600160a060020a0390811691161461123657600080fd5b428190111561124457600080fd5b60098190557fd34bb772c4ae9baa99db852f622773b31c7827e8ee818449fef20d30980bd3108160405190815260200160405180910390a15b5b50565b600454600160a060020a031681565b600d5481565b60015433600160a060020a039081169116146112b157600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001546000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555b565b600754600b5410155b90565b60005433600160a060020a0390811691161461134957600080fd5b600f805461ff001916610100831515810291909117918290557f48d826081348f5f00e8a33c9ae8ce89ed4c6e88400b585a478bc203d9e8177d39160ff918104821691620100008204169063010000009004600160a060020a031660405192151583529015156020830152600160a060020a03166040808301919091526060909101905180910390a15b5b50565b60145481565b6005805b6113e9610b01565b60078111156113f457fe5b146113fe57600080fd5b34151561140a57600080fd5b611416600d5434611605565b600d555b5b50565b60005433600160a060020a0390811691161461143957600080fd5b60138190555b5b50565b600054600160a060020a031681565b600654600160a060020a031681565b60116020526000908152604090205481565b610a7633826116ad565b5b50565b60145482115b949350505050565b60008282111561149b57fe5b508082035b92915050565b61121233610a40565b5b565b600554600090600160a060020a03166382771c8e82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610ad557600080fd5b6102c65a03f11515610ae657600080fd5b50505060405180519150505b90565b60085481565b600f5460ff1681565b60015460a060020a900460ff1681565b60126020526000908152604090205460ff1681565b60005433600160a060020a0390811691161461156b57600080fd5b60015460a060020a900460ff16151561158357600080fd5b6001805474ff0000000000000000000000000000000000000000191690555b5b5b565b60008282028315806115c257508284828115156115bf57fe5b04145b15156115ca57fe5b8091505b5092915050565b600f5462010000900460ff1681565b600154600160a060020a031681565b601454600b5410155b90565b600c5481565b6000828201838110156115ca57fe5b8091505b5092915050565b60005433600160a060020a0390811691161461163a57600080fd5b600160a060020a03821660009081526012602052604090819020805460ff19168315151790557fa54714518c5d275fdcd3d2a461e4858e4e8cb04fb93cd0bca9d6d34115f26440908390839051600160a060020a039092168252151560208201526040908101905180910390a15b5b5050565b600f5462010000900460ff16156116c357600080fd5b6fffffffffffffffffffffffffffffffff811615156116e157600080fd5b6111b082826117a0565b5b5050565b60005433600160a060020a0390811691161461170b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b50565b60005433600160a060020a0390811691161461175357600080fd5b600254600c54111561176457600080fd5b6006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b50565b600354600160a060020a031681565b600154600090819060a060020a900460ff16156117bc57600080fd5b60025b6117c7610b01565b60078111156117d257fe5b141561180457600160a060020a03841660009081526012602052604090205460ff1615156117ff57600080fd5b61182a565b60035b61180f610b01565b600781111561181a57fe5b141561026c5761182a565b600080fd5b5b5b600454600b54600a54600354349550600160a060020a03938416936318a4155e9387939092909133911663313ce5676000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561189257600080fd5b6102c65a03f115156118a357600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8816028152600481019590955260248501939093526044840191909152600160a060020a0316606483015260ff16608482015260a401602060405180830381600087803b151561191257600080fd5b6102c65a03f1151561192357600080fd5b505050604051805191505080151561193a57600080fd5b600160a060020a038416600090815260106020526040902054151561196357600c805460010190555b600160a060020a0384166000908152601060205260409020546119869083611605565b600160a060020a0385166000908152601060209081526040808320939093556011905220546119b59082611605565b600160a060020a038516600090815260116020526040902055600b546119db9083611605565b600b55600a546119eb9082611605565b600a81905550611a018282600b54600a54611481565b15611a0b57600080fd5b611a158482611abb565b600654600160a060020a031682156108fc0283604051600060405180830381858888f193505050501515611a4857600080fd5b7f0396f60aaad038749091d273dc13aaabc63db6e2271c7bad442d5cf25cc4335084838386604051600160a060020a03909416845260208401929092526040808401919091526fffffffffffffffffffffffffffffffff90911660608301526080909101905180910390a15b5b50505050565b600354600160a060020a0316806340c10f19848460405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b1515611b1257600080fd5b6102c65a03f11515611b2357600080fd5b5050505b5050505600a165627a7a7230582055391fc74bd68ee0632c0a2ee15b7c4c60c936bcfb0201bb6d5fd4f2003474050029000000000000000000000000b54c1e0cb74be65749a61bc262750c04e3d283e9000000000000000000000000f2dbd11ef28fc3f02162be2b94e4ee920b9db9f000000000000000000000000083b7eeb4d6ec1289578186f1da64a876dc71fcbb000000000000000000000000000000000000000000000000000000005a05a2d0000000000000000000000000000000000000000000000000000000005a497a000000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000776e8052d7ee78800000

   Swarm Source:
bzzr://55391fc74bd68ee0632c0a2ee15b7c4c60c936bcfb0201bb6d5fd4f200347405

 

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.