Contract 0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb

Contract Overview

Balance:
0 Ether

Latest 25 internal transaction, Click here to view more Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xd5f170f8fd3eb783ead02c54978a28eff87ac1d90xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0xcbbc239894cb236f28f1920d3e467a2fe9898a7d0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0xcbbc239894cb236f28f1920d3e467a2fe9898a7d0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb  Contract Creation0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0xb347b9f5b56b431b2cf4e1d90a5995f7519ca7920 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xd5f170f8fd3eb783ead02c54978a28eff87ac1d90xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xd5f170f8fd3eb783ead02c54978a28eff87ac1d90xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xd5f170f8fd3eb783ead02c54978a28eff87ac1d90xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xde6d19d7a68d453244227b6ccc5d8e6c2314627a0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xeb0234e6df157252763900c9e84d45480db44a9b7ed530728140288532d2f22e1057297714 hrs 6 mins ago0xde6d19d7a68d453244227b6ccc5d8e6c2314627a0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0x25eca1b38b39f393a7ec5e29288ddc929fa992050xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0x8e1263927e1b872fc5082bf8426b09b5bc20627f0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0x8e1263927e1b872fc5082bf8426b09b5bc20627f0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb  Contract Creation0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0xb347b9f5b56b431b2cf4e1d90a5995f7519ca7920 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0x25eca1b38b39f393a7ec5e29288ddc929fa992050xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0x25eca1b38b39f393a7ec5e29288ddc929fa992050xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0x25eca1b38b39f393a7ec5e29288ddc929fa992050xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xde6d19d7a68d453244227b6ccc5d8e6c2314627a0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0x01fdc9cda995e65cf051f499cac11a5a4ec01301bd2c2cb9447f04327f27c65c105661832 days 22 mins ago0xde6d19d7a68d453244227b6ccc5d8e6c2314627a0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xbe42d491c3fb902c343a8a434cc6babe132e2a0edef4711080da50536af30f47105498304 days 19 hrs ago0xc58410147721721521edde6f6f9d361eaa17b45e0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0 Ether
0xbe42d491c3fb902c343a8a434cc6babe132e2a0edef4711080da50536af30f47105498304 days 19 hrs ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0x88d2f4e0d96fc983558b03ab18ad5a49b50095260 Ether
0xbe42d491c3fb902c343a8a434cc6babe132e2a0edef4711080da50536af30f47105498304 days 19 hrs ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0x88d2f4e0d96fc983558b03ab18ad5a49b50095260 Ether
0xbe42d491c3fb902c343a8a434cc6babe132e2a0edef4711080da50536af30f47105498304 days 19 hrs ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb  Contract Creation0 Ether
0xbe42d491c3fb902c343a8a434cc6babe132e2a0edef4711080da50536af30f47105498304 days 19 hrs ago0xa4a24780b93a378eb25ec4bfbf93bc8e79d7eeeb0xb347b9f5b56b431b2cf4e1d90a5995f7519ca7920 Ether
[ Download CSV Export 
Warning: The compiled contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) Solidity Compiler Bugs.

Contract Source Code Verified (Similar Match)
Note: This contract matches the deployed ByteCode of the Verified Source Code for Contract 0xfde869904bbc1e881601b2ebde4a77ba3808dfad
Contract Name: CappedSTOFactory
Compiler Version: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimizer):  200


Contract Source Code
pragma solidity ^0.4.24;

/**
 * @title Utility contract to allow pausing and unpausing of certain functions
 */
contract Pausable {

    event Pause(uint256 _timestammp);
    event Unpause(uint256 _timestamp);

    bool public paused = false;

    /**
    * @notice Modifier to make a function callable only when the contract is not paused.
    */
    modifier whenNotPaused() {
        require(!paused, "Contract is paused");
        _;
    }

    /**
    * @notice Modifier to make a function callable only when the contract is paused.
    */
    modifier whenPaused() {
        require(paused, "Contract is not paused");
        _;
    }

   /**
    * @notice Called by the owner to pause, triggers stopped state
    */
    function _pause() internal whenNotPaused {
        paused = true;
        /*solium-disable-next-line security/no-block-members*/
        emit Pause(now);
    }

    /**
    * @notice Called by the owner to unpause, returns to normal state
    */
    function _unpause() internal whenPaused {
        paused = false;
        /*solium-disable-next-line security/no-block-members*/
        emit Unpause(now);
    }

}

/**
 * @title Interface that every module contract should implement
 */
interface IModule {

    /**
     * @notice This function returns the signature of configure function
     */
    function getInitFunction() external pure returns (bytes4);

    /**
     * @notice Return the permission flags that are associated with a module
     */
    function getPermissions() external view returns(bytes32[]);

    /**
     * @notice Used to withdraw the fee by the factory owner
     */
    function takeFee(uint256 _amount) external returns(bool);

}

/**
 * @title Interface for all security tokens
 */
interface ISecurityToken {

    // Standard ERC20 interface
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint256);
    function balanceOf(address _owner) external view returns (uint256);
    function allowance(address _owner, address _spender) external view returns (uint256);
    function transfer(address _to, uint256 _value) external returns (bool);
    function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
    function approve(address _spender, uint256 _value) external returns (bool);
    function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool);
    function increaseApproval(address _spender, uint _addedValue) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    //transfer, transferFrom must respect the result of verifyTransfer
    function verifyTransfer(address _from, address _to, uint256 _value) external returns (bool success);

    /**
     * @notice Mints new tokens and assigns them to the target _investor.
     * Can only be called by the STO attached to the token (Or by the ST owner if there's no STO attached yet)
     * @param _investor Address the tokens will be minted to
     * @param _value is the amount of tokens that will be minted to the investor
     */
    function mint(address _investor, uint256 _value) external returns (bool success);

    /**
     * @notice Mints new tokens and assigns them to the target _investor.
     * Can only be called by the STO attached to the token (Or by the ST owner if there's no STO attached yet)
     * @param _investor Address the tokens will be minted to
     * @param _value is The amount of tokens that will be minted to the investor
     * @param _data Data to indicate validation
     */
    function mintWithData(address _investor, uint256 _value, bytes _data) external returns (bool success);

    /**
     * @notice Used to burn the securityToken on behalf of someone else
     * @param _from Address for whom to burn tokens
     * @param _value No. of tokens to be burned
     * @param _data Data to indicate validation
     */
    function burnFromWithData(address _from, uint256 _value, bytes _data) external;

    /**
     * @notice Used to burn the securityToken
     * @param _value No. of tokens to be burned
     * @param _data Data to indicate validation
     */
    function burnWithData(uint256 _value, bytes _data) external;

    event Minted(address indexed _to, uint256 _value);
    event Burnt(address indexed _burner, uint256 _value);

    // Permissions this to a Permission module, which has a key of 1
    // If no Permission return false - note that IModule withPerm will allow ST owner all permissions anyway
    // this allows individual modules to override this logic if needed (to not allow ST owner all permissions)
    function checkPermission(address _delegate, address _module, bytes32 _perm) external view returns (bool);

    /**
     * @notice Returns module list for a module type
     * @param _module Address of the module
     * @return bytes32 Name
     * @return address Module address
     * @return address Module factory address
     * @return bool Module archived
     * @return uint8 Module type
     * @return uint256 Module index
     * @return uint256 Name index

     */
    function getModule(address _module) external view returns(bytes32, address, address, bool, uint8, uint256, uint256);

    /**
     * @notice Returns module list for a module name
     * @param _name Name of the module
     * @return address[] List of modules with this name
     */
    function getModulesByName(bytes32 _name) external view returns (address[]);

    /**
     * @notice Returns module list for a module type
     * @param _type Type of the module
     * @return address[] List of modules with this type
     */
    function getModulesByType(uint8 _type) external view returns (address[]);

    /**
     * @notice Queries totalSupply at a specified checkpoint
     * @param _checkpointId Checkpoint ID to query as of
     */
    function totalSupplyAt(uint256 _checkpointId) external view returns (uint256);

    /**
     * @notice Queries balance at a specified checkpoint
     * @param _investor Investor to query balance for
     * @param _checkpointId Checkpoint ID to query as of
     */
    function balanceOfAt(address _investor, uint256 _checkpointId) external view returns (uint256);

    /**
     * @notice Creates a checkpoint that can be used to query historical balances / totalSuppy
     */
    function createCheckpoint() external returns (uint256);

    /**
     * @notice Gets length of investors array
     * NB - this length may differ from investorCount if the list has not been pruned of zero-balance investors
     * @return Length
     */
    function getInvestors() external view returns (address[]);

    /**
     * @notice returns an array of investors at a given checkpoint
     * NB - this length may differ from investorCount as it contains all investors that ever held tokens
     * @param _checkpointId Checkpoint id at which investor list is to be populated
     * @return list of investors
     */
    function getInvestorsAt(uint256 _checkpointId) external view returns(address[]);

    /**
     * @notice generates subset of investors
     * NB - can be used in batches if investor list is large
     * @param _start Position of investor to start iteration from
     * @param _end Position of investor to stop iteration at
     * @return list of investors
     */
    function iterateInvestors(uint256 _start, uint256 _end) external view returns(address[]);
    
    /**
     * @notice Gets current checkpoint ID
     * @return Id
     */
    function currentCheckpointId() external view returns (uint256);

    /**
    * @notice Gets an investor at a particular index
    * @param _index Index to return address from
    * @return Investor address
    */
    function investors(uint256 _index) external view returns (address);

   /**
    * @notice Allows the owner to withdraw unspent POLY stored by them on the ST or any ERC20 token.
    * @dev Owner can transfer POLY to the ST which will be used to pay for modules that require a POLY fee.
    * @param _tokenContract Address of the ERC20Basic compliance token
    * @param _value Amount of POLY to withdraw
    */
    function withdrawERC20(address _tokenContract, uint256 _value) external;

    /**
    * @notice Allows owner to approve more POLY to one of the modules
    * @param _module Module address
    * @param _budget New budget
    */
    function changeModuleBudget(address _module, uint256 _budget) external;

    /**
     * @notice Changes the tokenDetails
     * @param _newTokenDetails New token details
     */
    function updateTokenDetails(string _newTokenDetails) external;

    /**
    * @notice Allows the owner to change token granularity
    * @param _granularity Granularity level of the token
    */
    function changeGranularity(uint256 _granularity) external;

    /**
    * @notice Removes addresses with zero balances from the investors list
    * @param _start Index in investors list at which to start removing zero balances
    * @param _iters Max number of iterations of the for loop
    * NB - pruning this list will mean you may not be able to iterate over investors on-chain as of a historical checkpoint
    */
    function pruneInvestors(uint256 _start, uint256 _iters) external;

    /**
     * @notice Freezes all the transfers
     */
    function freezeTransfers() external;

    /**
     * @notice Un-freezes all the transfers
     */
    function unfreezeTransfers() external;

    /**
     * @notice Ends token minting period permanently
     */
    function freezeMinting() external;

    /**
     * @notice Mints new tokens and assigns them to the target investors.
     * Can only be called by the STO attached to the token or by the Issuer (Security Token contract owner)
     * @param _investors A list of addresses to whom the minted tokens will be delivered
     * @param _values A list of the amount of tokens to mint to corresponding addresses from _investor[] list
     * @return Success
     */
    function mintMulti(address[] _investors, uint256[] _values) external returns (bool success);

    /**
     * @notice Function used to attach a module to the security token
     * @dev  E.G.: On deployment (through the STR) ST gets a TransferManager module attached to it
     * @dev to control restrictions on transfers.
     * @dev You are allowed to add a new moduleType if:
     * @dev - there is no existing module of that type yet added
     * @dev - the last member of the module list is replacable
     * @param _moduleFactory is the address of the module factory to be added
     * @param _data is data packed into bytes used to further configure the module (See STO usage)
     * @param _maxCost max amount of POLY willing to pay to module. (WIP)
     */
    function addModule(
        address _moduleFactory,
        bytes _data,
        uint256 _maxCost,
        uint256 _budget
    ) external;

    /**
    * @notice Archives a module attached to the SecurityToken
    * @param _module address of module to archive
    */
    function archiveModule(address _module) external;

    /**
    * @notice Unarchives a module attached to the SecurityToken
    * @param _module address of module to unarchive
    */
    function unarchiveModule(address _module) external;

    /**
    * @notice Removes a module attached to the SecurityToken
    * @param _module address of module to archive
    */
    function removeModule(address _module) external;

    /**
     * @notice Used by the issuer to set the controller addresses
     * @param _controller address of the controller
     */
    function setController(address _controller) external;

    /**
     * @notice Used by a controller to execute a forced transfer
     * @param _from address from which to take tokens
     * @param _to address where to send tokens
     * @param _value amount of tokens to transfer
     * @param _data data to indicate validation
     * @param _log data attached to the transfer by controller to emit in event
     */
    function forceTransfer(address _from, address _to, uint256 _value, bytes _data, bytes _log) external;

    /**
     * @notice Used by a controller to execute a foced burn
     * @param _from address from which to take tokens
     * @param _value amount of tokens to transfer
     * @param _data data to indicate validation
     * @param _log data attached to the transfer by controller to emit in event
     */
    function forceBurn(address _from, uint256 _value, bytes _data, bytes _log) external;

    /**
     * @notice Used by the issuer to permanently disable controller functionality
     * @dev enabled via feature switch "disableControllerAllowed"
     */
     function disableController() external;

     /**
     * @notice Used to get the version of the securityToken
     */
     function getVersion() external view returns(uint8[]);

     /**
     * @notice Gets the investor count
     */
     function getInvestorCount() external view returns(uint256);

     /**
      * @notice Overloaded version of the transfer function
      * @param _to receiver of transfer
      * @param _value value of transfer
      * @param _data data to indicate validation
      * @return bool success
      */
     function transferWithData(address _to, uint256 _value, bytes _data) external returns (bool success);

     /**
      * @notice Overloaded version of the transferFrom function
      * @param _from sender of transfer
      * @param _to receiver of transfer
      * @param _value value of transfer
      * @param _data data to indicate validation
      * @return bool success
      */
     function transferFromWithData(address _from, address _to, uint256 _value, bytes _data) external returns(bool);

     /**
      * @notice Provides the granularity of the token
      * @return uint256
      */
     function granularity() external view returns(uint256);
}

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
interface IERC20 {
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint256);
    function balanceOf(address _owner) external view returns (uint256);
    function allowance(address _owner, address _spender) external view returns (uint256);
    function transfer(address _to, uint256 _value) external returns (bool);
    function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
    function approve(address _spender, uint256 _value) external returns (bool);
    function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool);
    function increaseApproval(address _spender, uint _addedValue) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;


  event OwnershipRenounced(address indexed previousOwner);
  event OwnershipTransferred(
    address indexed previousOwner,
    address indexed newOwner
  );


  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  constructor() public {
    owner = msg.sender;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Allows the current owner to relinquish control of the contract.
   */
  function renounceOwnership() public onlyOwner {
    emit OwnershipRenounced(owner);
    owner = address(0);
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param _newOwner The address to transfer ownership to.
   */
  function transferOwnership(address _newOwner) public onlyOwner {
    _transferOwnership(_newOwner);
  }

  /**
   * @dev Transfers control of the contract to a newOwner.
   * @param _newOwner The address to transfer ownership to.
   */
  function _transferOwnership(address _newOwner) internal {
    require(_newOwner != address(0));
    emit OwnershipTransferred(owner, _newOwner);
    owner = _newOwner;
  }
}

/**
 * @title Interface that any module contract should implement
 * @notice Contract is abstract
 */
contract Module is IModule {

    address public factory;

    address public securityToken;

    bytes32 public constant FEE_ADMIN = "FEE_ADMIN";

    IERC20 public polyToken;

    /**
     * @notice Constructor
     * @param _securityToken Address of the security token
     * @param _polyAddress Address of the polytoken
     */
    constructor (address _securityToken, address _polyAddress) public {
        securityToken = _securityToken;
        factory = msg.sender;
        polyToken = IERC20(_polyAddress);
    }

    //Allows owner, factory or permissioned delegate
    modifier withPerm(bytes32 _perm) {
        bool isOwner = msg.sender == Ownable(securityToken).owner();
        bool isFactory = msg.sender == factory;
        require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed");
        _;
    }

    modifier onlyOwner {
        require(msg.sender == Ownable(securityToken).owner(), "Sender is not owner");
        _;
    }

    modifier onlyFactory {
        require(msg.sender == factory, "Sender is not factory");
        _;
    }

    modifier onlyFactoryOwner {
        require(msg.sender == Ownable(factory).owner(), "Sender is not factory owner");
        _;
    }

    modifier onlyFactoryOrOwner {
        require((msg.sender == Ownable(securityToken).owner()) || (msg.sender == factory), "Sender is not factory or owner");
        _;
    }

    /**
     * @notice used to withdraw the fee by the factory owner
     */
    function takeFee(uint256 _amount) public withPerm(FEE_ADMIN) returns(bool) {
        require(polyToken.transferFrom(securityToken, Ownable(factory).owner(), _amount), "Unable to take fee");
        return true;
    }
}

/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {

  /**
  * @dev Multiplies two numbers, throws on overflow.
  */
  function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
    // Gas optimization: this is cheaper than asserting 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
    if (a == 0) {
      return 0;
    }

    c = a * b;
    assert(c / a == b);
    return c;
  }

  /**
  * @dev Integer division of two numbers, truncating the quotient.
  */
  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    // uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return a / b;
  }

  /**
  * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
  function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
    c = a + b;
    assert(c >= a);
    return c;
  }
}

/**
 * @title Interface to be implemented by all STO modules
 */
contract ISTO is Module, Pausable  {
    using SafeMath for uint256;

    enum FundRaiseType { ETH, POLY, DAI }
    mapping (uint8 => bool) public fundRaiseTypes;
    mapping (uint8 => uint256) public fundsRaised;

    // Start time of the STO
    uint256 public startTime;
    // End time of the STO
    uint256 public endTime;
    // Time STO was paused
    uint256 public pausedTime;
    // Number of individual investors
    uint256 public investorCount;
    // Address where ETH & POLY funds are delivered
    address public wallet;
     // Final amount of tokens sold
    uint256 public totalTokensSold;

    // Event
    event SetFundRaiseTypes(FundRaiseType[] _fundRaiseTypes);

    /**
    * @notice Reclaims ERC20Basic compatible tokens
    * @dev We duplicate here due to the overriden owner & onlyOwner
    * @param _tokenContract The address of the token contract
    */
    function reclaimERC20(address _tokenContract) external onlyOwner {
        require(_tokenContract != address(0), "Invalid address");
        IERC20 token = IERC20(_tokenContract);
        uint256 balance = token.balanceOf(address(this));
        require(token.transfer(msg.sender, balance), "Transfer failed");
    }

    /**
     * @notice Returns funds raised by the STO
     */
    function getRaised(FundRaiseType _fundRaiseType) public view returns (uint256) {
        return fundsRaised[uint8(_fundRaiseType)];
    }

    /**
     * @notice Returns the total no. of tokens sold
     */
    function getTokensSold() public view returns (uint256);

    /**
     * @notice Pause (overridden function)
     */
    function pause() public onlyOwner {
        /*solium-disable-next-line security/no-block-members*/
        require(now < endTime, "STO has been finalized");
        super._pause();
    }

    /**
     * @notice Unpause (overridden function)
     */
    function unpause() public onlyOwner {
        super._unpause();
    }

    function _setFundRaiseType(FundRaiseType[] _fundRaiseTypes) internal {
        // FundRaiseType[] parameter type ensures only valid values for _fundRaiseTypes
        require(_fundRaiseTypes.length > 0, "Raise type is not specified");
        fundRaiseTypes[uint8(FundRaiseType.ETH)] = false;
        fundRaiseTypes[uint8(FundRaiseType.POLY)] = false;
        fundRaiseTypes[uint8(FundRaiseType.DAI)] = false;
        for (uint8 j = 0; j < _fundRaiseTypes.length; j++) {
            fundRaiseTypes[uint8(_fundRaiseTypes[j])] = true;
        }
        emit SetFundRaiseTypes(_fundRaiseTypes);
    }

}

/**
 * @title Helps contracts guard agains reentrancy attacks.
 * @author Remco Bloemen <[email protected]π.com>
 * @notice If you mark a function `nonReentrant`, you should also
 * mark it `external`.
 */
contract ReentrancyGuard {

  /**
   * @dev We use a single lock for the whole contract.
   */
  bool private reentrancyLock = false;

  /**
   * @dev Prevents a contract from calling itself, directly or indirectly.
   * @notice If you mark a function `nonReentrant`, you should also
   * mark it `external`. Calling one nonReentrant function from
   * another is not supported. Instead, you can implement a
   * `private` function doing the actual work, and a `external`
   * wrapper marked as `nonReentrant`.
   */
  modifier nonReentrant() {
    require(!reentrancyLock);
    reentrancyLock = true;
    _;
    reentrancyLock = false;
  }

}

/**
 * @title STO module for standard capped crowdsale
 */
contract CappedSTO is ISTO, ReentrancyGuard {
    using SafeMath for uint256;

    // Determine whether users can invest on behalf of a beneficiary
    bool public allowBeneficialInvestments = false;
    // How many token units a buyer gets per wei / base unit of POLY
    uint256 public rate;
    //How many tokens this STO will be allowed to sell to investors
    uint256 public cap;

    mapping (address => uint256) public investors;

    /**
    * Event for token purchase logging
    * @param purchaser who paid for the tokens
    * @param beneficiary who got the tokens
    * @param value weis paid for purchase
    * @param amount amount of tokens purchased
    */
    event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

    event SetAllowBeneficialInvestments(bool _allowed);

    constructor (address _securityToken, address _polyAddress) public
    Module(_securityToken, _polyAddress)
    {
    }

    //////////////////////////////////
    /**
    * @notice fallback function ***DO NOT OVERRIDE***
    */
    function () external payable {
        buyTokens(msg.sender);
    }

    /**
     * @notice Function used to intialize the contract variables
     * @param _startTime Unix timestamp at which offering get started
     * @param _endTime Unix timestamp at which offering get ended
     * @param _cap Maximum No. of tokens for sale
     * @param _rate Token units a buyer gets per wei / base unit of POLY
     * @param _fundRaiseTypes Type of currency used to collect the funds
     * @param _fundsReceiver Ethereum account address to hold the funds
     */
    function configure(
        uint256 _startTime,
        uint256 _endTime,
        uint256 _cap,
        uint256 _rate,
        FundRaiseType[] _fundRaiseTypes,
        address _fundsReceiver
    )
    public
    onlyFactory
    {
        require(_rate > 0, "Rate of token should be greater than 0");
        require(_fundsReceiver != address(0), "Zero address is not permitted");
        /*solium-disable-next-line security/no-block-members*/
        require(_startTime >= now && _endTime > _startTime, "Date parameters are not valid");
        require(_cap > 0, "Cap should be greater than 0");
        require(_fundRaiseTypes.length == 1, "It only selects single fund raise type");
        startTime = _startTime;
        endTime = _endTime;
        cap = _cap;
        rate = _rate;
        wallet = _fundsReceiver;
        _setFundRaiseType(_fundRaiseTypes);
    }

    /**
     * @notice This function returns the signature of configure function
     */
    function getInitFunction() public pure returns (bytes4) {
        return bytes4(keccak256("configure(uint256,uint256,uint256,uint256,uint8[],address)"));
    }

    /**
     * @notice Function to set allowBeneficialInvestments (allow beneficiary to be different to funder)
     * @param _allowBeneficialInvestments Boolean to allow or disallow beneficial investments
     */
    function changeAllowBeneficialInvestments(bool _allowBeneficialInvestments) public onlyOwner {
        require(_allowBeneficialInvestments != allowBeneficialInvestments, "Does not change value");
        allowBeneficialInvestments = _allowBeneficialInvestments;
        emit SetAllowBeneficialInvestments(allowBeneficialInvestments);
    }

    /**
      * @notice Low level token purchase ***DO NOT OVERRIDE***
      * @param _beneficiary Address performing the token purchase
      */
    function buyTokens(address _beneficiary) public payable nonReentrant {
        if (!allowBeneficialInvestments) {
            require(_beneficiary == msg.sender, "Beneficiary address does not match msg.sender");
        }

        require(!paused, "Should not be paused");
        require(fundRaiseTypes[uint8(FundRaiseType.ETH)], "Mode of investment is not ETH");

        uint256 weiAmount = msg.value;
        _processTx(_beneficiary, weiAmount);

        _forwardFunds();
        _postValidatePurchase(_beneficiary, weiAmount);
    }

    /**
      * @notice low level token purchase
      * @param _investedPOLY Amount of POLY invested
      */
    function buyTokensWithPoly(uint256 _investedPOLY) public nonReentrant{
        require(!paused, "Should not be paused");
        require(fundRaiseTypes[uint8(FundRaiseType.POLY)], "Mode of investment is not POLY");
        _processTx(msg.sender, _investedPOLY);
        _forwardPoly(msg.sender, wallet, _investedPOLY);
        _postValidatePurchase(msg.sender, _investedPOLY);
    }

    /**
    * @notice Checks whether the cap has been reached.
    * @return bool Whether the cap was reached
    */
    function capReached() public view returns (bool) {
        return totalTokensSold >= cap;
    }

    /**
     * @notice Return the total no. of tokens sold
     */
    function getTokensSold() public view returns (uint256) {
        return totalTokensSold;
    }

    /**
     * @notice Return the permissions flag that are associated with STO
     */
    function getPermissions() public view returns(bytes32[]) {
        bytes32[] memory allPermissions = new bytes32[](0);
        return allPermissions;
    }

    /**
     * @notice Return the STO details
     * @return Unixtimestamp at which offering gets start.
     * @return Unixtimestamp at which offering ends.
     * @return Number of tokens this STO will be allowed to sell to investors.
     * @return Amount of funds raised
     * @return Number of individual investors this STO have.
     * @return Amount of tokens get sold. 
     * @return Boolean value to justify whether the fund raise type is POLY or not, i.e true for POLY.
     */
    function getSTODetails() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, bool) {
        return (
            startTime,
            endTime,
            cap,
            rate,
            (fundRaiseTypes[uint8(FundRaiseType.POLY)]) ? fundsRaised[uint8(FundRaiseType.POLY)]: fundsRaised[uint8(FundRaiseType.ETH)],
            investorCount,
            totalTokensSold,
            (fundRaiseTypes[uint8(FundRaiseType.POLY)])
        );
    }

    // -----------------------------------------
    // Internal interface (extensible)
    // -----------------------------------------
    /**
      * Processing the purchase as well as verify the required validations
      * @param _beneficiary Address performing the token purchase
      * @param _investedAmount Value in wei involved in the purchase
    */
    function _processTx(address _beneficiary, uint256 _investedAmount) internal {

        _preValidatePurchase(_beneficiary, _investedAmount);
        // calculate token amount to be created
        uint256 tokens = _getTokenAmount(_investedAmount);

        // update state
        if (fundRaiseTypes[uint8(FundRaiseType.POLY)]) {
            fundsRaised[uint8(FundRaiseType.POLY)] = fundsRaised[uint8(FundRaiseType.POLY)].add(_investedAmount);
        } else {
            fundsRaised[uint8(FundRaiseType.ETH)] = fundsRaised[uint8(FundRaiseType.ETH)].add(_investedAmount);
        }
        totalTokensSold = totalTokensSold.add(tokens);

        _processPurchase(_beneficiary, tokens);
        emit TokenPurchase(msg.sender, _beneficiary, _investedAmount, tokens);

        _updatePurchasingState(_beneficiary, _investedAmount);
    }

    /**
    * @notice Validation of an incoming purchase.
      Use require statements to revert state when conditions are not met. Use super to concatenate validations.
    * @param _beneficiary Address performing the token purchase
    * @param _investedAmount Value in wei involved in the purchase
    */
    function _preValidatePurchase(address _beneficiary, uint256 _investedAmount) internal view {
        require(_beneficiary != address(0), "Beneficiary address should not be 0x");
        require(_investedAmount != 0, "Amount invested should not be equal to 0");
        require(totalTokensSold.add(_getTokenAmount(_investedAmount)) <= cap, "Investment more than cap is not allowed");
        /*solium-disable-next-line security/no-block-members*/
        require(now >= startTime && now <= endTime, "Offering is closed/Not yet started");
    }

    /**
    * @notice Validation of an executed purchase.
      Observe state and use revert statements to undo rollback when valid conditions are not met.
    */
    function _postValidatePurchase(address /*_beneficiary*/, uint256 /*_investedAmount*/) internal pure {
      // optional override
    }

    /**
    * @notice Source of tokens.
      Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
    * @param _beneficiary Address performing the token purchase
    * @param _tokenAmount Number of tokens to be emitted
    */
    function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
        require(ISecurityToken(securityToken).mint(_beneficiary, _tokenAmount), "Error in minting the tokens");
    }

    /**
    * @notice Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
    * @param _beneficiary Address receiving the tokens
    * @param _tokenAmount Number of tokens to be purchased
    */
    function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
        if (investors[_beneficiary] == 0) {
            investorCount = investorCount + 1;
        }
        investors[_beneficiary] = investors[_beneficiary].add(_tokenAmount);

        _deliverTokens(_beneficiary, _tokenAmount);
    }

    /**
    * @notice Overrides for extensions that require an internal state to check for validity
      (current user contributions, etc.)
    */
    function _updatePurchasingState(address /*_beneficiary*/, uint256 /*_investedAmount*/) internal pure {
      // optional override
    }

    /**
    * @notice Overrides to extend the way in which ether is converted to tokens.
    * @param _investedAmount Value in wei to be converted into tokens
    * @return Number of tokens that can be purchased with the specified _investedAmount
    */
    function _getTokenAmount(uint256 _investedAmount) internal view returns (uint256) {
        return _investedAmount.mul(rate);
    }

    /**
    * @notice Determines how ETH is stored/forwarded on purchases.
    */
    function _forwardFunds() internal {
        wallet.transfer(msg.value);
    }

    /**
     * @notice Internal function used to forward the POLY raised to beneficiary address
     * @param _beneficiary Address of the funds reciever
     * @param _to Address who wants to ST-20 tokens
     * @param _fundsAmount Amount invested by _to
     */
    function _forwardPoly(address _beneficiary, address _to, uint256 _fundsAmount) internal {
        polyToken.transferFrom(_beneficiary, _to, _fundsAmount);
    }

}

/**
 * @title Interface that every module factory contract should implement
 */
interface IModuleFactory {

    event ChangeFactorySetupFee(uint256 _oldSetupCost, uint256 _newSetupCost, address _moduleFactory);
    event ChangeFactoryUsageFee(uint256 _oldUsageCost, uint256 _newUsageCost, address _moduleFactory);
    event ChangeFactorySubscriptionFee(uint256 _oldSubscriptionCost, uint256 _newMonthlySubscriptionCost, address _moduleFactory);
    event GenerateModuleFromFactory(
        address _module,
        bytes32 indexed _moduleName,
        address indexed _moduleFactory,
        address _creator,
        uint256 _setupCost,
        uint256 _timestamp
    );
    event ChangeSTVersionBound(string _boundType, uint8 _major, uint8 _minor, uint8 _patch);

    //Should create an instance of the Module, or throw
    function deploy(bytes _data) external returns(address);

    /**
     * @notice Type of the Module factory
     */
    function getTypes() external view returns(uint8[]);

    /**
     * @notice Get the name of the Module
     */
    function getName() external view returns(bytes32);

    /**
     * @notice Returns the instructions associated with the module
     */
    function getInstructions() external view returns (string);

    /**
     * @notice Get the tags related to the module factory
     */
    function getTags() external view returns (bytes32[]);

    /**
     * @notice Used to change the setup fee
     * @param _newSetupCost New setup fee
     */
    function changeFactorySetupFee(uint256 _newSetupCost) external;

    /**
     * @notice Used to change the usage fee
     * @param _newUsageCost New usage fee
     */
    function changeFactoryUsageFee(uint256 _newUsageCost) external;

    /**
     * @notice Used to change the subscription fee
     * @param _newSubscriptionCost New subscription fee
     */
    function changeFactorySubscriptionFee(uint256 _newSubscriptionCost) external;

    /**
     * @notice Function use to change the lower and upper bound of the compatible version st
     * @param _boundType Type of bound
     * @param _newVersion New version array
     */
    function changeSTVersionBounds(string _boundType, uint8[] _newVersion) external;

   /**
     * @notice Get the setup cost of the module
     */
    function getSetupCost() external view returns (uint256);

    /**
     * @notice Used to get the lower bound
     * @return Lower bound
     */
    function getLowerSTVersionBounds() external view returns(uint8[]);

     /**
     * @notice Used to get the upper bound
     * @return Upper bound
     */
    function getUpperSTVersionBounds() external view returns(uint8[]);

}

/**
 * @title Helper library use to compare or validate the semantic versions
 */

library VersionUtils {

    /**
     * @notice This function is used to validate the version submitted
     * @param _current Array holds the present version of ST
     * @param _new Array holds the latest version of the ST
     * @return bool
     */
    function isValidVersion(uint8[] _current, uint8[] _new) internal pure returns(bool) {
        bool[] memory _temp = new bool[](_current.length);
        uint8 counter = 0;
        for (uint8 i = 0; i < _current.length; i++) {
            if (_current[i] < _new[i])
                _temp[i] = true;
            else
                _temp[i] = false;
        }

        for (i = 0; i < _current.length; i++) {
            if (i == 0) {
                if (_current[i] <= _new[i])
                    if(_temp[0]) {
                        counter = counter + 3;
                        break;
                    } else
                        counter++;
                else
                    return false;
            } else {
                if (_temp[i-1])
                    counter++;
                else if (_current[i] <= _new[i])
                    counter++;
                else
                    return false;
            }
        }
        if (counter == _current.length)
            return true;
    }

    /**
     * @notice Used to compare the lower bound with the latest version
     * @param _version1 Array holds the lower bound of the version
     * @param _version2 Array holds the latest version of the ST
     * @return bool
     */
    function compareLowerBound(uint8[] _version1, uint8[] _version2) internal pure returns(bool) {
        require(_version1.length == _version2.length, "Input length mismatch");
        uint counter = 0;
        for (uint8 j = 0; j < _version1.length; j++) {
            if (_version1[j] == 0)
                counter ++;
        }
        if (counter != _version1.length) {
            counter = 0;
            for (uint8 i = 0; i < _version1.length; i++) {
                if (_version2[i] > _version1[i])
                    return true;
                else if (_version2[i] < _version1[i])
                    return false;
                else
                    counter++;
            }
            if (counter == _version1.length - 1)
                return true;
            else
                return false;
        } else
            return true;
    }

    /**
     * @notice Used to compare the upper bound with the latest version
     * @param _version1 Array holds the upper bound of the version
     * @param _version2 Array holds the latest version of the ST
     * @return bool
     */
    function compareUpperBound(uint8[] _version1, uint8[] _version2) internal pure returns(bool) {
        require(_version1.length == _version2.length, "Input length mismatch");
        uint counter = 0;
        for (uint8 j = 0; j < _version1.length; j++) {
            if (_version1[j] == 0)
                counter ++;
        }
        if (counter != _version1.length) {
            counter = 0;
            for (uint8 i = 0; i < _version1.length; i++) {
                if (_version1[i] > _version2[i])
                    return true;
                else if (_version1[i] < _version2[i])
                    return false;
                else
                    counter++;
            }
            if (counter == _version1.length - 1)
                return true;
            else
                return false;
        } else
            return true;
    }


    /**
     * @notice Used to pack the uint8[] array data into uint24 value
     * @param _major Major version
     * @param _minor Minor version
     * @param _patch Patch version
     */
    function pack(uint8 _major, uint8 _minor, uint8 _patch) internal pure returns(uint24) {
        return (uint24(_major) << 16) | (uint24(_minor) << 8) | uint24(_patch);
    }

    /**
     * @notice Used to convert packed data into uint8 array
     * @param _packedVersion Packed data
     */
    function unpack(uint24 _packedVersion) internal pure returns (uint8[]) {
        uint8[] memory _unpackVersion = new uint8[](3);
        _unpackVersion[0] = uint8(_packedVersion >> 16);
        _unpackVersion[1] = uint8(_packedVersion >> 8);
        _unpackVersion[2] = uint8(_packedVersion);
        return _unpackVersion;
    }


}

/**
 * @title Interface that any module factory contract should implement
 * @notice Contract is abstract
 */
contract ModuleFactory is IModuleFactory, Ownable {

    IERC20 public polyToken;
    uint256 public usageCost;
    uint256 public monthlySubscriptionCost;

    uint256 public setupCost;
    string public description;
    string public version;
    bytes32 public name;
    string public title;

    // @notice Allow only two variables to be stored
    // 1. lowerBound 
    // 2. upperBound
    // @dev (0.0.0 will act as the wildcard) 
    // @dev uint24 consists packed value of uint8 _major, uint8 _minor, uint8 _patch
    mapping(string => uint24) compatibleSTVersionRange;

    event ChangeFactorySetupFee(uint256 _oldSetupCost, uint256 _newSetupCost, address _moduleFactory);
    event ChangeFactoryUsageFee(uint256 _oldUsageCost, uint256 _newUsageCost, address _moduleFactory);
    event ChangeFactorySubscriptionFee(uint256 _oldSubscriptionCost, uint256 _newMonthlySubscriptionCost, address _moduleFactory);
    event GenerateModuleFromFactory(
        address _module,
        bytes32 indexed _moduleName,
        address indexed _moduleFactory,
        address _creator,
        uint256 _timestamp
    );
    event ChangeSTVersionBound(string _boundType, uint8 _major, uint8 _minor, uint8 _patch);

    /**
     * @notice Constructor
     * @param _polyAddress Address of the polytoken
     */
    constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public {
        polyToken = IERC20(_polyAddress);
        setupCost = _setupCost;
        usageCost = _usageCost;
        monthlySubscriptionCost = _subscriptionCost;
    }

    /**
     * @notice Used to change the fee of the setup cost
     * @param _newSetupCost new setup cost
     */
    function changeFactorySetupFee(uint256 _newSetupCost) public onlyOwner {
        emit ChangeFactorySetupFee(setupCost, _newSetupCost, address(this));
        setupCost = _newSetupCost;
    }

    /**
     * @notice Used to change the fee of the usage cost
     * @param _newUsageCost new usage cost
     */
    function changeFactoryUsageFee(uint256 _newUsageCost) public onlyOwner {
        emit ChangeFactoryUsageFee(usageCost, _newUsageCost, address(this));
        usageCost = _newUsageCost;
    }

    /**
     * @notice Used to change the fee of the subscription cost
     * @param _newSubscriptionCost new subscription cost
     */
    function changeFactorySubscriptionFee(uint256 _newSubscriptionCost) public onlyOwner {
        emit ChangeFactorySubscriptionFee(monthlySubscriptionCost, _newSubscriptionCost, address(this));
        monthlySubscriptionCost = _newSubscriptionCost;

    }

    /**
     * @notice Updates the title of the ModuleFactory
     * @param _newTitle New Title that will replace the old one.
     */
    function changeTitle(string _newTitle) public onlyOwner {
        require(bytes(_newTitle).length > 0, "Invalid title");
        title = _newTitle;
    }

    /**
     * @notice Updates the description of the ModuleFactory
     * @param _newDesc New description that will replace the old one.
     */
    function changeDescription(string _newDesc) public onlyOwner {
        require(bytes(_newDesc).length > 0, "Invalid description");
        description = _newDesc;
    }

    /**
     * @notice Updates the name of the ModuleFactory
     * @param _newName New name that will replace the old one.
     */
    function changeName(bytes32 _newName) public onlyOwner {
        require(_newName != bytes32(0),"Invalid name");
        name = _newName;
    }

    /**
     * @notice Updates the version of the ModuleFactory
     * @param _newVersion New name that will replace the old one.
     */
    function changeVersion(string _newVersion) public onlyOwner {
        require(bytes(_newVersion).length > 0, "Invalid version");
        version = _newVersion;
    }

    /**
     * @notice Function use to change the lower and upper bound of the compatible version st
     * @param _boundType Type of bound
     * @param _newVersion new version array
     */
    function changeSTVersionBounds(string _boundType, uint8[] _newVersion) external onlyOwner {
        require(
            keccak256(abi.encodePacked(_boundType)) == keccak256(abi.encodePacked("lowerBound")) ||
            keccak256(abi.encodePacked(_boundType)) == keccak256(abi.encodePacked("upperBound")),
            "Must be a valid bound type"
        );
        require(_newVersion.length == 3);
        if (compatibleSTVersionRange[_boundType] != uint24(0)) { 
            uint8[] memory _currentVersion = VersionUtils.unpack(compatibleSTVersionRange[_boundType]);
            require(VersionUtils.isValidVersion(_currentVersion, _newVersion), "Failed because of in-valid version");
        }
        compatibleSTVersionRange[_boundType] = VersionUtils.pack(_newVersion[0], _newVersion[1], _newVersion[2]);
        emit ChangeSTVersionBound(_boundType, _newVersion[0], _newVersion[1], _newVersion[2]);
    }

    /**
     * @notice Used to get the lower bound
     * @return lower bound
     */
    function getLowerSTVersionBounds() external view returns(uint8[]) {
        return VersionUtils.unpack(compatibleSTVersionRange["lowerBound"]);
    }

    /**
     * @notice Used to get the upper bound
     * @return upper bound
     */
    function getUpperSTVersionBounds() external view returns(uint8[]) {
        return VersionUtils.unpack(compatibleSTVersionRange["upperBound"]);
    }

    /**
     * @notice Get the setup cost of the module
     */
    function getSetupCost() external view returns (uint256) {
        return setupCost;
    }

   /**
    * @notice Get the name of the Module
    */
    function getName() public view returns(bytes32) {
        return name;
    }

}

/**
 * @title Utility contract for reusable code
 */
library Util {

   /**
    * @notice Changes a string to upper case
    * @param _base String to change
    */
    function upper(string _base) internal pure returns (string) {
        bytes memory _baseBytes = bytes(_base);
        for (uint i = 0; i < _baseBytes.length; i++) {
            bytes1 b1 = _baseBytes[i];
            if (b1 >= 0x61 && b1 <= 0x7A) {
                b1 = bytes1(uint8(b1)-32);
            }
            _baseBytes[i] = b1;
        }
        return string(_baseBytes);
    }

    /**
     * @notice Changes the string into bytes32
     * @param _source String that need to convert into bytes32
     */
    /// Notice - Maximum Length for _source will be 32 chars otherwise returned bytes32 value will have lossy value.
    function stringToBytes32(string memory _source) internal pure returns (bytes32) {
        return bytesToBytes32(bytes(_source), 0);
    }

    /**
     * @notice Changes bytes into bytes32
     * @param _b Bytes that need to convert into bytes32
     * @param _offset Offset from which to begin conversion
     */
    /// Notice - Maximum length for _source will be 32 chars otherwise returned bytes32 value will have lossy value.
    function bytesToBytes32(bytes _b, uint _offset) internal pure returns (bytes32) {
        bytes32 result;

        for (uint i = 0; i < _b.length; i++) {
            result |= bytes32(_b[_offset + i] & 0xFF) >> (i * 8);
        }
        return result;
    }

    /**
     * @notice Changes the bytes32 into string
     * @param _source that need to convert into string
     */
    function bytes32ToString(bytes32 _source) internal pure returns (string result) {
        bytes memory bytesString = new bytes(32);
        uint charCount = 0;
        for (uint j = 0; j < 32; j++) {
            byte char = byte(bytes32(uint(_source) * 2 ** (8 * j)));
            if (char != 0) {
                bytesString[charCount] = char;
                charCount++;
            }
        }
        bytes memory bytesStringTrimmed = new bytes(charCount);
        for (j = 0; j < charCount; j++) {
            bytesStringTrimmed[j] = bytesString[j];
        }
        return string(bytesStringTrimmed);
    }

    /**
     * @notice Gets function signature from _data
     * @param _data Passed data
     * @return bytes4 sig
     */
    function getSig(bytes _data) internal pure returns (bytes4 sig) {
        uint len = _data.length < 4 ? _data.length : 4;
        for (uint i = 0; i < len; i++) {
            sig = bytes4(uint(sig) + uint(_data[i]) * (2 ** (8 * (len - 1 - i))));
        }
    }


}

/**
 * @title Factory for deploying CappedSTO module
 */
contract CappedSTOFactory is ModuleFactory {

    /**
     * @notice Constructor
     * @param _polyAddress Address of the polytoken
     */
    constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
    ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
    {
        version = "1.0.0";
        name = "CappedSTO";
        title = "Capped STO";
        description = "Use to collects the funds and once the cap is reached then investment will be no longer entertained";
        compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
        compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
    }

     /**
     * @notice Used to launch the Module with the help of factory
     * @return address Contract address of the Module
     */
    function deploy(bytes _data) external returns(address) {
        if(setupCost > 0)
            require(polyToken.transferFrom(msg.sender, owner, setupCost), "Sufficent Allowance is not provided");
        //Check valid bytes - can only call module init function
        CappedSTO cappedSTO = new CappedSTO(msg.sender, address(polyToken));
        //Checks that _data is valid (not calling anything it shouldn't)
        require(Util.getSig(_data) == cappedSTO.getInitFunction(), "Invalid data");
        /*solium-disable-next-line security/no-low-level-calls*/
        require(address(cappedSTO).call(_data), "Unsuccessfull call");
        /*solium-disable-next-line security/no-block-members*/
        emit GenerateModuleFromFactory(address(cappedSTO), getName(), address(this), msg.sender, setupCost, now);
        return address(cappedSTO);
    }

    /**
     * @notice Type of the Module factory
     */
    function getTypes() external view returns(uint8[]) {
        uint8[] memory res = new uint8[](1);
        res[0] = 3;
        return res;
    }

    /**
     * @notice Returns the instructions associated with the module
     */
    function getInstructions() external view returns(string) {
        /*solium-disable-next-line max-len*/
        return "Initialises a capped STO. Init parameters are _startTime (time STO starts), _endTime (time STO ends), _cap (cap in tokens for STO), _rate (POLY/ETH to token rate), _fundRaiseType (whether you are raising in POLY or ETH), _polyToken (address of POLY token), _fundsReceiver (address which will receive funds)";
    }

    /**
     * @notice Get the tags related to the module factory
     */
    function getTags() external view returns(bytes32[]) {
        bytes32[] memory availableTags = new bytes32[](4);
        availableTags[0] = "Capped";
        availableTags[1] = "Non-refundable";
        availableTags[2] = "POLY";
        availableTags[3] = "ETH";
        return availableTags;
    }

}

Contract ABI
[{"constant":false,"inputs":[{"name":"_data","type":"bytes"}],"name":"deploy","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"monthlySubscriptionCost","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getName","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newTitle","type":"string"}],"name":"changeTitle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newSubscriptionCost","type":"uint256"}],"name":"changeFactorySubscriptionFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"title","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newSetupCost","type":"uint256"}],"name":"changeFactorySetupFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newVersion","type":"string"}],"name":"changeVersion","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"polyToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"description","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"setupCost","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getLowerSTVersionBounds","outputs":[{"name":"","type":"uint8[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newName","type":"bytes32"}],"name":"changeName","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":"getTags","outputs":[{"name":"","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getSetupCost","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newUsageCost","type":"uint256"}],"name":"changeFactoryUsageFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getTypes","outputs":[{"name":"","type":"uint8[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"usageCost","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInstructions","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newDesc","type":"string"}],"name":"changeDescription","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getUpperSTVersionBounds","outputs":[{"name":"","type":"uint8[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_boundType","type":"string"},{"name":"_newVersion","type":"uint8[]"}],"name":"changeSTVersionBounds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_polyAddress","type":"address"},{"name":"_setupCost","type":"uint256"},{"name":"_usageCost","type":"uint256"},{"name":"_subscriptionCost","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_oldSetupCost","type":"uint256"},{"indexed":false,"name":"_newSetupCost","type":"uint256"},{"indexed":false,"name":"_moduleFactory","type":"address"}],"name":"ChangeFactorySetupFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_oldUsageCost","type":"uint256"},{"indexed":false,"name":"_newUsageCost","type":"uint256"},{"indexed":false,"name":"_moduleFactory","type":"address"}],"name":"ChangeFactoryUsageFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_oldSubscriptionCost","type":"uint256"},{"indexed":false,"name":"_newMonthlySubscriptionCost","type":"uint256"},{"indexed":false,"name":"_moduleFactory","type":"address"}],"name":"ChangeFactorySubscriptionFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_module","type":"address"},{"indexed":true,"name":"_moduleName","type":"bytes32"},{"indexed":true,"name":"_moduleFactory","type":"address"},{"indexed":false,"name":"_creator","type":"address"},{"indexed":false,"name":"_timestamp","type":"uint256"}],"name":"GenerateModuleFromFactory","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_boundType","type":"string"},{"indexed":false,"name":"_major","type":"uint8"},{"indexed":false,"name":"_minor","type":"uint8"},{"indexed":false,"name":"_patch","type":"uint8"}],"name":"ChangeSTVersionBound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_module","type":"address"},{"indexed":true,"name":"_moduleName","type":"bytes32"},{"indexed":true,"name":"_moduleFactory","type":"address"},{"indexed":false,"name":"_creator","type":"address"},{"indexed":false,"name":"_setupCost","type":"uint256"},{"indexed":false,"name":"_timestamp","type":"uint256"}],"name":"GenerateModuleFromFactory","type":"event"}]

Contract Creation Code
60806040523480156200001157600080fd5b50604051608080620040858339810160408181528251602080850151838601516060909601516000805433600160a060020a03199182161790915560018054909116600160a060020a03861617905560048290556002879055600381905584860190945260058086527f312e302e300000000000000000000000000000000000000000000000000000009290950191825291949193919291620000b791600691620002e4565b507f43617070656453544f000000000000000000000000000000000000000000000060075560408051808201909152600a8082527f4361707065642053544f0000000000000000000000000000000000000000000060209092019182526200012291600891620002e4565b5060a060405190810160405280606381526020017f55736520746f20636f6c6c65637473207468652066756e647320616e64206f6e81526020017f636520746865206361702069732072656163686564207468656e20696e76657381526020017f746d656e742077696c6c206265206e6f206c6f6e67657220656e74657274616981526020017f6e6564000000000000000000000000000000000000000000000000000000000081525060059080519060200190620001e3929190620002e4565b50620002006000808064010000000062001963620002c982021704565b604080517f6c6f776572426f756e640000000000000000000000000000000000000000000081526009600a820152905190819003602a019020805462ffffff9290921662ffffff199092169190911790556200026d6000808064010000000062001963620002c982021704565b604080517f7570706572426f756e640000000000000000000000000000000000000000000081526009600a820152905190819003602a019020805462ffffff9290921662ffffff19909216919091179055506200038992505050565b60ff9081169181166101000292166201000002919091171790565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200032757805160ff191683800117855562000357565b8280016001018555821562000357579182015b82811115620003575782518255916020019190600101906200033a565b506200036592915062000369565b5090565b6200038691905b8082111562000365576000815560010162000370565b90565b613cec80620003996000396000f3006080604052600436106101445763ffffffff60e060020a600035041662774360811461014957806306184a251461018557806306fdde03146101ac57806317d7de7c146101c15780632dbe07c7146101d65780633ae192bd146102315780634a79d50c1461024957806354fd4d50146102d357806358a191c3146102e857806364bb432c146103005780636faa22a514610359578063715018a61461036e5780637284e416146103835780637e363ffa146103985780638677768f146103ad578063898855ed146104125780638da5cb5b1461042a578063995d9ab71461043f578063a5e9d7c914610454578063aac67b0514610469578063b4579d6014610481578063d54c472614610496578063e0d54970146104ab578063e6120413146104c0578063f2fde38b14610519578063f78629991461053a578063fb9724561461054f575b600080fd5b34801561015557600080fd5b50610169600480356024810191013561057b565b60408051600160a060020a039092168252519081900360200190f35b34801561019157600080fd5b5061019a61091d565b60408051918252519081900360200190f35b3480156101b857600080fd5b5061019a610923565b3480156101cd57600080fd5b5061019a610929565b3480156101e257600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261022f9436949293602493928401919081908401838280828437509497506109309650505050505050565b005b34801561023d57600080fd5b5061022f6004356109b7565b34801561025557600080fd5b5061025e610a14565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610298578181015183820152602001610280565b50505050905090810190601f1680156102c55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102df57600080fd5b5061025e610aa2565b3480156102f457600080fd5b5061022f600435610afd565b34801561030c57600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261022f943694929360249392840191908190840183828082843750949750610b5a9650505050505050565b34801561036557600080fd5b50610169610bdd565b34801561037a57600080fd5b5061022f610bec565b34801561038f57600080fd5b5061025e610c58565b3480156103a457600080fd5b5061019a610cb3565b3480156103b957600080fd5b506103c2610cb9565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103fe5781810151838201526020016103e6565b505050509050019250505060405180910390f35b34801561041e57600080fd5b5061022f600435610d09565b34801561043657600080fd5b50610169610d7c565b34801561044b57600080fd5b506103c2610d8b565b34801561046057600080fd5b5061019a610ea4565b34801561047557600080fd5b5061022f600435610eaa565b34801561048d57600080fd5b506103c2610f07565b3480156104a257600080fd5b5061019a610f53565b3480156104b757600080fd5b5061025e610f59565b3480156104cc57600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261022f943694929360249392840191908190840183828082843750949750610f7d9650505050505050565b34801561052557600080fd5b5061022f600160a060020a0360043516611000565b34801561054657600080fd5b506103c2611023565b34801561055b57600080fd5b5061022f602460048035828101929082013591813591820191013561106e565b600080600060045411156106b3576001546000805460048054604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523393810193909352600160a060020a03938416602484015260448301919091525191909316926323b872dd9260648083019360209390929083900390910190829087803b15801561060b57600080fd5b505af115801561061f573d6000803e3d6000fd5b505050506040513d602081101561063557600080fd5b505115156106b3576040805160e560020a62461bcd02815260206004820152602360248201527f537566666963656e7420416c6c6f77616e6365206973206e6f742070726f766960448201527f6465640000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6001543390600160a060020a03166106c961197e565b600160a060020a03928316815291166020820152604080519182900301906000f0801580156106fc573d6000803e3d6000fd5b50905080600160a060020a0316631613ec9d6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561073d57600080fd5b505af1158015610751573d6000803e3d6000fd5b505050506040513d602081101561076757600080fd5b5051604080516020601f87018190048102820181019092528581527bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19909216916107c2918790879081908401838280828437506115ad945050505050565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614610836576040805160e560020a62461bcd02815260206004820152600c60248201527f496e76616c696420646174610000000000000000000000000000000000000000604482015290519081900360640190fd5b80600160a060020a03168484604051808383808284378201915050925050506000604051808303816000865af191505015156108bc576040805160e560020a62461bcd02815260206004820152601260248201527f556e7375636365737366756c6c2063616c6c0000000000000000000000000000604482015290519081900360640190fd5b306108c5610929565b60045460408051600160a060020a038616815233602082015280820192909252426060830152517fb68b4973fbce93f056103272c1f3f53b607527138d7e323b7b94f7ac169ebf779181900360800190a39392505050565b60035481565b60075481565b6007545b90565b600054600160a060020a0316331461094757600080fd5b80516000106109a0576040805160e560020a62461bcd02815260206004820152600d60248201527f496e76616c6964207469746c6500000000000000000000000000000000000000604482015290519081900360640190fd5b80516109b390600890602084019061198e565b5050565b600054600160a060020a031633146109ce57600080fd5b60035460408051918252602082018390523082820152517fb14468ff50b0c356f5373be0ef0791de71449aaf8ac5ca096049b7ac79d0b1139181900360600190a1600355565b6008805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610a9a5780601f10610a6f57610100808354040283529160200191610a9a565b820191906000526020600020905b815481529060010190602001808311610a7d57829003601f168201915b505050505081565b6006805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610a9a5780601f10610a6f57610100808354040283529160200191610a9a565b600054600160a060020a03163314610b1457600080fd5b60045460408051918252602082018390523082820152517f9672983540fb671cd7c0c946255b4dc769a3e557a25ef91ca7c98995c8d694b69181900360600190a1600455565b600054600160a060020a03163314610b7157600080fd5b8051600010610bca576040805160e560020a62461bcd02815260206004820152600f60248201527f496e76616c69642076657273696f6e0000000000000000000000000000000000604482015290519081900360640190fd5b80516109b390600690602084019061198e565b600154600160a060020a031681565b600054600160a060020a03163314610c0357600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6005805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610a9a5780601f10610a6f57610100808354040283529160200191610a9a565b60045481565b604080517f6c6f776572426f756e640000000000000000000000000000000000000000000081526009600a820152905190819003602a01902054606090610d049062ffffff1661162e565b905090565b600054600160a060020a03163314610d2057600080fd5b801515610d77576040805160e560020a62461bcd02815260206004820152600c60248201527f496e76616c6964206e616d650000000000000000000000000000000000000000604482015290519081900360640190fd5b600755565b600054600160a060020a031681565b60408051600480825260a08201909252606091829190602082016080803883390190505090507f4361707065640000000000000000000000000000000000000000000000000000816000815181101515610de157fe5b6020908102909101015280517f4e6f6e2d726566756e6461626c650000000000000000000000000000000000009082906001908110610e1c57fe5b6020908102909101015280517f504f4c59000000000000000000000000000000000000000000000000000000009082906002908110610e5757fe5b6020908102909101015280517f45544800000000000000000000000000000000000000000000000000000000009082906003908110610e9257fe5b602090810290910101529050805b5090565b60045490565b600054600160a060020a03163314610ec157600080fd5b60025460408051918252602082018390523082820152517fc39ec4e85127e00b5b203f9c40814616d5977d8de85e6e0717e5ca4b0896206c9181900360600190a1600255565b604080516001808252818301909252606091829190602080830190803883390190505090506003816000815181101515610f3d57fe5b60ff909216602092830290910190910152905090565b60025481565b6060610160604051908101604052806101328152602001613b8f6101329139905090565b600054600160a060020a03163314610f9457600080fd5b8051600010610fed576040805160e560020a62461bcd02815260206004820152601360248201527f496e76616c6964206465736372697074696f6e00000000000000000000000000604482015290519081900360640190fd5b80516109b390600590602084019061198e565b600054600160a060020a0316331461101757600080fd5b611020816116d3565b50565b604080517f7570706572426f756e640000000000000000000000000000000000000000000081526009600a820152905190819003602a01902054606090610d049062ffffff1661162e565b600054606090600160a060020a0316331461108857600080fd5b60405160200180807f6c6f776572426f756e6400000000000000000000000000000000000000000000815250600a0190506040516020818303038152906040526040518082805190602001908083835b602083106110f75780518252601f1990920191602091820191016110d8565b51815160209384036101000a600019018019909216911617905260405191909301819003812094508993508892019050808383808284378201915050925050506040516020818303038152906040526040518082805190602001908083835b602083106111755780518252601f199092019160209182019101611156565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191614806112cd575060405160200180807f7570706572426f756e6400000000000000000000000000000000000000000000815250600a0190506040516020818303038152906040526040518082805190602001908083835b6020831061121c5780518252601f1990920191602091820191016111fd565b51815160209384036101000a600019018019909216911617905260405191909301819003812094508993508892019050808383808284378201915050925050506040516020818303038152906040526040518082805190602001908083835b6020831061129a5780518252601f19909201916020918201910161127b565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916145b1515611323576040805160e560020a62461bcd02815260206004820152601a60248201527f4d75737420626520612076616c696420626f756e642074797065000000000000604482015290519081900360640190fd5b6003821461133057600080fd5b600062ffffff1660098686604051808383808284379091019485525050604051928390036020019092205462ffffff169290921491506114569050576113a160098686604051808383808284379091019485525050604051928390036020019092205462ffffff16915061162e9050565b90506113da8184848080602002602001604051908101604052809392919081815260200183836020028082843750611750945050505050565b1515611456576040805160e560020a62461bcd02815260206004820152602260248201527f4661696c65642062656361757365206f6620696e2d76616c696420766572736960448201527f6f6e000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6114a78383600081811061146657fe5b9050602002013560ff1684846001818110151561147f57fe5b9050602002013560ff1685856002818110151561149857fe5b9050602002013560ff16611963565b6009868660405180838380828437909101948552505060405192839003602001909220805462ffffff9490941662ffffff1990941693909317909255507f5b67e16edaf7fc70c8d065ea6e70b97ed944d98fe593b04d682216615a3b04db905085858585600081811061151657fe5b9050602002013560ff1686866001818110151561152f57fe5b9050602002013560ff1687876002818110151561154857fe5b9050602002013560ff1660405180806020018560ff1660ff1681526020018460ff1660ff1681526020018360ff1660ff168152602001828103825287878281815260200192508082843760405192018290039850909650505050505050a15050505050565b600080600060048451106115c25760046115c5565b83515b9150600090505b818110156116275780600183030360080260020a84828151811015156115ee57fe5b90602001015160f860020a900460f860020a0260f860020a9004028360e060020a90040160e060020a02925080806001019150506115cc565b5050919050565b6040805160038082526080820190925260609182919060208201838038833950508151919250506201000062ffffff851604908290600090811061166e57fe5b60ff909216602092830290910190910152805161010062ffffff851604908290600190811061169957fe5b60ff90921660209283029091019091015280518390829060029081106116bb57fe5b60ff9092166020928302909101909101529050919050565b600160a060020a03811615156116e857600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600060606000808551604051908082528060200260200182016040528015611782578160200160208202803883390190505b50925060009150600090505b85518160ff16101561182e57848160ff168151811015156117ab57fe5b9060200190602002015160ff16868260ff168151811015156117c957fe5b9060200190602002015160ff161015611803576001838260ff168151811015156117ef57fe5b911515602092830290910190910152611826565b6000838260ff1681518110151561181657fe5b9115156020928302909101909101525b60010161178e565b5060005b85518160ff1610156119495760ff811615156118cb57848160ff1681518110151561185957fe5b9060200190602002015160ff16868260ff1681518110151561187757fe5b6020908102909101015160ff16116118bd5782600081518110151561189857fe5b90602001906020020151156118b257816003019150611949565b6001909101906118c6565b6000935061195a565b611941565b826001820360ff168151811015156118df57fe5b90602001906020020151156118f957600190910190611941565b848160ff1681518110151561190a57fe5b9060200190602002015160ff16868260ff1681518110151561192857fe5b6020908102909101015160ff16116118bd576001909101905b600101611832565b85518260ff16141561195a57600193505b50505092915050565b60ff9081169181166101000292166201000002919091171790565b60405161217280611a1d83390190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106119cf57805160ff19168380011785556119fc565b828001600101855582156119fc579182015b828111156119fc5782518255916020019190600101906119e1565b50610ea09261092d9250905b80821115610ea05760008155600101611a08560060806040526002805460a060020a60ff0219169055600b805461ffff1916905534801561002b57600080fd5b5060405160408061217283398101604052805160209091015160018054600160a060020a03938416600160a060020a03199182161790915560008054821633179055600280549390921692169190911790556120e68061008c6000396000f3006080604052600436106101715763ffffffff60e060020a6000350416631040dc27811461017c5780631365eaaf146101d45780631613ec9d146102465780632c4e722e146102905780632df413e2146102b75780633197cbb6146102e0578063355274ea146102f55780633f4ba83a1461030a578063441b9e4a1461031f5780634f93594514610339578063521eb2731461034e5780635c975abb1461037f5780635f7619a41461039457806363b20117146103ac5780636f7bc9be146103c15780636faa22a5146103e257806378e97925146103f75780638456cb591461040c5780638905fd4f146104215780639a7cc13514610442578063b2cca39d1461045d578063b84dfbd214610472578063c3a07df614610487578063c45a0155146104ec578063c4d2c6bd14610501578063cb7526791461051c578063d143a37914610534578063d70afa961461054f578063d7e64c0014610564578063ec8ac4d814610579578063ee7c0db01461058d575b61017a336105a2565b005b34801561018857600080fd5b5061019161076a565b604080519889526020890197909752878701959095526060870193909352608086019190915260a085015260c0840152151560e083015251908190036101000190f35b3480156101e057600080fd5b50604080516020600460843581810135838102808601850190965280855261017a95833595602480359660443596606435963696919560a49594909101928291908501908490808284375094975050509235600160a060020a0316935061084792505050565b34801561025257600080fd5b5061025b610b10565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b34801561029c57600080fd5b506102a5610b6b565b60408051918252519081900360200190f35b3480156102c357600080fd5b506102cc610b71565b604080519115158252519081900360200190f35b3480156102ec57600080fd5b506102a5610b7f565b34801561030157600080fd5b506102a5610b85565b34801561031657600080fd5b5061017a610b8b565b34801561032b57600080fd5b5061017a6004351515610c61565b34801561034557600080fd5b506102cc610ded565b34801561035a57600080fd5b50610363610df8565b60408051600160a060020a039092168252519081900360200190f35b34801561038b57600080fd5b506102cc610e07565b3480156103a057600080fd5b506102cc600435610e17565b3480156103b857600080fd5b506102a561115b565b3480156103cd57600080fd5b506102a5600160a060020a0360043516611161565b3480156103ee57600080fd5b50610363611173565b34801561040357600080fd5b506102a5611182565b34801561041857600080fd5b5061017a611188565b34801561042d57600080fd5b5061017a600160a060020a03600435166112b5565b34801561044e57600080fd5b506102a560ff60043516611567565b34801561046957600080fd5b506102a5611593565b34801561047e57600080fd5b50610363611599565b34801561049357600080fd5b5061049c6115a8565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156104d85781810151838201526020016104c0565b505050509050019250505060405180910390f35b3480156104f857600080fd5b506103636115ba565b34801561050d57600080fd5b506102a560ff600435166115c9565b34801561052857600080fd5b5061017a6004356115db565b34801561054057600080fd5b506102cc60ff60043516611706565b34801561055b57600080fd5b506102a561171b565b34801561057057600080fd5b506102a561173f565b61017a600160a060020a03600435166105a2565b34801561059957600080fd5b506102a5611745565b600b5460009060ff16156105b557600080fd5b600b805460ff191660011790819055610100900460ff16151561065857600160a060020a0382163314610658576040805160e560020a62461bcd02815260206004820152602d60248201527f42656e6566696369617279206164647265737320646f6573206e6f74206d617460448201527f6368206d73672e73656e64657200000000000000000000000000000000000000606482015290519081900360840190fd5b60025460a060020a900460ff16156106ba576040805160e560020a62461bcd02815260206004820152601460248201527f53686f756c64206e6f7420626520706175736564000000000000000000000000604482015290519081900360640190fd5b6000805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff5460ff16151561073e576040805160e560020a62461bcd02815260206004820152601d60248201527f4d6f6465206f6620696e766573746d656e74206973206e6f7420455448000000604482015290519081900360640190fd5b503461074a828261174b565b61075261188d565b61075c82826118c9565b5050600b805460ff19169055565b600080600080600080600080600554600654600d54600c54600360006001600281111561079357fe5b60ff9081168252602082019290925260400160002054166107de576000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec5461080b565b600160005260046020527fabd6e7cb50984ff9c2f3e18a2660c3353dadf4e3291deeb275dae2cd1e44fe05545b600854600a546001600052600360205260008051602061207b83398151915254969f959e50939c50919a5098509650945060ff90911692509050565b600054600160a060020a031633146108a9576040805160e560020a62461bcd02815260206004820152601560248201527f53656e646572206973206e6f7420666163746f72790000000000000000000000604482015290519081900360640190fd5b60008311610927576040805160e560020a62461bcd02815260206004820152602660248201527f52617465206f6620746f6b656e2073686f756c6420626520677265617465722060448201527f7468616e20300000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a0381161515610987576040805160e560020a62461bcd02815260206004820152601d60248201527f5a65726f2061646472657373206973206e6f74207065726d6974746564000000604482015290519081900360640190fd5b42861015801561099657508585115b15156109ec576040805160e560020a62461bcd02815260206004820152601d60248201527f4461746520706172616d657465727320617265206e6f742076616c6964000000604482015290519081900360640190fd5b60008411610a44576040805160e560020a62461bcd02815260206004820152601c60248201527f4361702073686f756c642062652067726561746572207468616e203000000000604482015290519081900360640190fd5b8151600114610ac3576040805160e560020a62461bcd02815260206004820152602660248201527f4974206f6e6c792073656c656374732073696e676c652066756e64207261697360448201527f6520747970650000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60058690556006859055600d849055600c8390556009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038316179055610b08826118cd565b505050505050565b604080517f636f6e6669677572652875696e743235362c75696e743235362c75696e74323581527f362c75696e743235362c75696e74385b5d2c61646472657373290000000000006020820152905190819003603a01902090565b600c5481565b600b54610100900460ff1681565b60065481565b600d5481565b600160009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610bde57600080fd5b505af1158015610bf2573d6000803e3d6000fd5b505050506040513d6020811015610c0857600080fd5b5051600160a060020a03163314610c57576040805160e560020a62461bcd028152602060048201526013602482015260008051602061209b833981519152604482015290519081900360640190fd5b610c5f611a7c565b565b600160009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610cb457600080fd5b505af1158015610cc8573d6000803e3d6000fd5b505050506040513d6020811015610cde57600080fd5b5051600160a060020a03163314610d2d576040805160e560020a62461bcd028152602060048201526013602482015260008051602061209b833981519152604482015290519081900360640190fd5b600b54610100900460ff1615158115151415610d93576040805160e560020a62461bcd02815260206004820152601560248201527f446f6573206e6f74206368616e67652076616c75650000000000000000000000604482015290519081900360640190fd5b600b805482151561010090810261ff00199092169190911791829055604080519190920460ff161515815290517fea6eddcb8f2bf55dfb29aef4bd48214ef0798b9eae2e1bbb25dac99ecf6da6ae9181900360200190a150565b600d54600a54101590565b600954600160a060020a031681565b60025460a060020a900460ff1681565b60007f4645455f41444d494e0000000000000000000000000000000000000000000000600080600160009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610e9057600080fd5b505af1158015610ea4573d6000803e3d6000fd5b505050506040513d6020811015610eba57600080fd5b505160005433600160a060020a039283168114945091161490508180610edd5750805b80610f835750600154604080517f8658b8b9000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018690529051600160a060020a0390921691638658b8b9916064808201926020929091908290030181600087803b158015610f5657600080fd5b505af1158015610f6a573d6000803e3d6000fd5b505050506040513d6020811015610f8057600080fd5b50515b1515610fd9576040805160e560020a62461bcd02815260206004820152601760248201527f5065726d697373696f6e20636865636b206661696c6564000000000000000000604482015290519081900360640190fd5b60025460015460008054604080517f8da5cb5b0000000000000000000000000000000000000000000000000000000081529051600160a060020a03958616956323b872dd95811694931692638da5cb5b92600480820193602093909283900390910190829087803b15801561104d57600080fd5b505af1158015611061573d6000803e3d6000fd5b505050506040513d602081101561107757600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a039384166004820152929091166024830152604482018990525160648083019260209291908290030181600087803b1580156110ce57600080fd5b505af11580156110e2573d6000803e3d6000fd5b505050506040513d60208110156110f857600080fd5b50511515611150576040805160e560020a62461bcd02815260206004820152601260248201527f556e61626c6520746f2074616b65206665650000000000000000000000000000604482015290519081900360640190fd5b506001949350505050565b600a5481565b600e6020526000908152604090205481565b600254600160a060020a031681565b60055481565b600160009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156111db57600080fd5b505af11580156111ef573d6000803e3d6000fd5b505050506040513d602081101561120557600080fd5b5051600160a060020a03163314611254576040805160e560020a62461bcd028152602060048201526013602482015260008051602061209b833981519152604482015290519081900360640190fd5b60065442106112ad576040805160e560020a62461bcd02815260206004820152601660248201527f53544f20686173206265656e2066696e616c697a656400000000000000000000604482015290519081900360640190fd5b610c5f611b32565b600080600160009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561130b57600080fd5b505af115801561131f573d6000803e3d6000fd5b505050506040513d602081101561133557600080fd5b5051600160a060020a03163314611384576040805160e560020a62461bcd028152602060048201526013602482015260008051602061209b833981519152604482015290519081900360640190fd5b600160a060020a03831615156113e4576040805160e560020a62461bcd02815260206004820152600f60248201527f496e76616c696420616464726573730000000000000000000000000000000000604482015290519081900360640190fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051849350600160a060020a038416916370a082319160248083019260209291908290030181600087803b15801561144857600080fd5b505af115801561145c573d6000803e3d6000fd5b505050506040513d602081101561147257600080fd5b5051604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018390529051919250600160a060020a0384169163a9059cbb916044808201926020929091908290030181600087803b1580156114e057600080fd5b505af11580156114f4573d6000803e3d6000fd5b505050506040513d602081101561150a57600080fd5b50511515611562576040805160e560020a62461bcd02815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b505050565b60006004600083600281111561157957fe5b60ff16815260208101919091526040016000205492915050565b60075481565b600154600160a060020a031681565b60408051600081526020810190915290565b600054600160a060020a031681565b60046020526000908152604090205481565b600b5460ff16156115eb57600080fd5b600b805460ff1916600117905560025460a060020a900460ff161561165a576040805160e560020a62461bcd02815260206004820152601460248201527f53686f756c64206e6f7420626520706175736564000000000000000000000000604482015290519081900360640190fd5b6001600052600360205260008051602061207b8339815191525460ff1615156116cd576040805160e560020a62461bcd02815260206004820152601e60248201527f4d6f6465206f6620696e766573746d656e74206973206e6f7420504f4c590000604482015290519081900360640190fd5b6116d7338261174b565b6009546116ef903390600160a060020a031683611bed565b6116f933826118c9565b50600b805460ff19169055565b60036020526000908152604090205460ff1681565b7f4645455f41444d494e000000000000000000000000000000000000000000000081565b60085481565b600a5490565b60006117578383611c95565b61176082611ec1565b6001600052600360205260008051602061207b8339815191525490915060ff16156117e1576117b0826004600060015b60ff1681526020810191909152604001600020549063ffffffff611ede16565b600160005260046020527fabd6e7cb50984ff9c2f3e18a2660c3353dadf4e3291deeb275dae2cd1e44fe055561181b565b6117ef826004600080611790565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec555b600a5461182e908263ffffffff611ede16565b600a5561183b8382611eeb565b60408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a361156283836118c9565b600954604051600160a060020a03909116903480156108fc02916000818181858888f193505050501580156118c6573d6000803e3d6000fd5b50565b5050565b6000808251111515611929576040805160e560020a62461bcd02815260206004820152601b60248201527f52616973652074797065206973206e6f74207370656369666965640000000000604482015290519081900360640190fd5b5060036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805460ff1990811690915560008051602061207b833981519152805482169055600260009081527fc3a24b0501bd2c13a7e57f2db4369ec4c223447539fc0724a9d55ac4a06ebd4d80549092169091555b81518160ff161015611a0357600160036000848460ff168151811015156119c457fe5b9060200190602002015160028111156119d957fe5b60ff1681526020810191909152604001600020805460ff19169115159190911790556001016119a1565b7fe5724f42dd9f217c97b3768212ed6d6692c0135e252387d61b98af28fecd9b02826040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015611a65578181015183820152602001611a4d565b505050509050019250505060405180910390a15050565b60025460a060020a900460ff161515611adf576040805160e560020a62461bcd02815260206004820152601660248201527f436f6e7472616374206973206e6f742070617573656400000000000000000000604482015290519081900360640190fd5b6002805474ff0000000000000000000000000000000000000000191690556040805142815290517faaa520fdd7d2c83061d632fa017b0432407e798818af63ea908589fceda39ab79181900360200190a1565b60025460a060020a900460ff1615611b94576040805160e560020a62461bcd02815260206004820152601260248201527f436f6e7472616374206973207061757365640000000000000000000000000000604482015290519081900360640190fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a1790556040805142815290517f68b095021b1f40fe513109f513c66692f0b3219aee674a69f4efc57badb8201d9181900360200190a1565b600254604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152858116602483015260448201859052915191909216916323b872dd9160648083019260209291908290030181600087803b158015611c6457600080fd5b505af1158015611c78573d6000803e3d6000fd5b505050506040513d6020811015611c8e57600080fd5b5050505050565b600160a060020a0382161515611d1a576040805160e560020a62461bcd028152602060048201526024808201527f42656e656669636961727920616464726573732073686f756c64206e6f74206260448201527f6520307800000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b801515611d97576040805160e560020a62461bcd02815260206004820152602860248201527f416d6f756e7420696e7665737465642073686f756c64206e6f7420626520657160448201527f75616c20746f2030000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600d54611db5611da683611ec1565b600a549063ffffffff611ede16565b1115611e31576040805160e560020a62461bcd02815260206004820152602760248201527f496e766573746d656e74206d6f7265207468616e20636170206973206e6f742060448201527f616c6c6f77656400000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6005544210158015611e4557506006544211155b15156118c9576040805160e560020a62461bcd02815260206004820152602260248201527f4f66666572696e6720697320636c6f7365642f4e6f742079657420737461727460448201527f6564000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000611ed8600c5483611f6090919063ffffffff16565b92915050565b81810182811015611ed857fe5b600160a060020a0382166000908152600e60205260409020541515611f14576008805460010190555b600160a060020a0382166000908152600e6020526040902054611f3d908263ffffffff611ede16565b600160a060020a0383166000908152600e60205260409020556118c98282611f89565b6000821515611f7157506000611ed8565b50818102818382811515611f8157fe5b0414611ed857fe5b600154604080517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015260248201859052915191909216916340c10f199160448083019260209291908290030181600087803b158015611ff857600080fd5b505af115801561200c573d6000803e3d6000fd5b505050506040513d602081101561202257600080fd5b505115156118c9576040805160e560020a62461bcd02815260206004820152601b60248201527f4572726f7220696e206d696e74696e672074686520746f6b656e730000000000604482015290519081900360640190fd00a15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054c53656e646572206973206e6f74206f776e657200000000000000000000000000a165627a7a7230582076595337e7d8d6b672de734ec78923638f8bb6aed9f7179635c136d2a3409a620029496e697469616c697365732061206361707065642053544f2e20496e697420706172616d657465727320617265205f737461727454696d65202874696d652053544f20737461727473292c205f656e6454696d65202874696d652053544f20656e6473292c205f636170202863617020696e20746f6b656e7320666f722053544f292c205f726174652028504f4c592f45544820746f20746f6b656e2072617465292c205f66756e6452616973655479706520287768657468657220796f75206172652072616973696e6720696e20504f4c59206f7220455448292c205f706f6c79546f6b656e202861646472657373206f6620504f4c5920746f6b656e292c205f66756e647352656365697665722028616464726573732077686963682077696c6c20726563656976652066756e647329a165627a7a7230582013ef49b395cfa4f3322806eb96e0d4605ea4ad6953957d82538ad2f076b8e4970029000000000000000000000000b06d72a24df50d4e2cac133b320c5e7de3ef94cb00000000000000000000000000000000000000000000043c33c193756480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


   Swarm Source:
bzzr://13ef49b395cfa4f3322806eb96e0d4605ea4ad6953957d82538ad2f076b8e497
Block Age Transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward