Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 3 txns
Misc:
Address Watch: Add To Watch List
Contract Creator: 0x6efba8fb2ac5b6730729a972ec224426a287c3adat txn 0x1f7128fa1e05e76d31bb9a2229175b86ae11688a4b66c30d12e86ee00d561133
 Latest 3 txns

TxHash Age From To Value [TxFee]
0xded2e863807a0ae2977d1616533125b01013dacb5b0a2abce1f3d60a5ab09f61140 days 17 hrs ago0x4af013afbadb22d8a88c92d68fc96b033b9ebb8a  IN   0x15e90976b01cbc38e203cf9f367fba6f3462b5ff0 Ether0.002124125
0x9ed5e761a05dc7b7c222d962eabaa4ff5e33b033343968dd55b3f13e424f18ed161 days 16 hrs ago0x4af013afbadb22d8a88c92d68fc96b033b9ebb8a  IN   0x15e90976b01cbc38e203cf9f367fba6f3462b5ff0 Ether0.02121605
0x1f7128fa1e05e76d31bb9a2229175b86ae11688a4b66c30d12e86ee00d561133161 days 21 hrs ago0x6efba8fb2ac5b6730729a972ec224426a287c3ad  IN    Contract Creation0 Ether0.021621
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 25 Internal Txns, Click here To View More View All
ParentTxHash Block Age From To Value
0x49d7ae93d675292c8b286411129d456a830c51fefb001dc6eba4ac2466d35df9668479373 days 17 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x028dfbc84bd2c8aa2760aaf30a649a1e65db09d7c658cefda3af7510f25fded8668462973 days 18 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xe1167377dcf0184de96d9682eda9737fc924f89d0870c4b90d3dd7699970443a668462173 days 18 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x6199da48658d86f00fa908133839adf2d4f98863afc9096908e3ec22b1b89412666614976 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x407d9fa2015250690d1d7930526ace4096defc2b52b213715b9ea0ea38519c02666608976 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x338120dfabdd86e3a60023afaa0c512e049561f4516d902b78ab5d39086e35c7666590576 days 20 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xdc25b1095bd67ee4eef7a2a0ab3da389d71cf9a3c3ffe70decbea8500c8c225b666582676 days 20 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xf3e59c8d9f299f9a2999e3bb006546e6ff978875446a14e87d869f0854bccecd666098977 days 15 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xe3d2d9ba760ac5cfc5a5e958ffe7c4a8387658cdb7f11712fed3792219fd33b5666086477 days 15 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x163bacc99f25da74b37aa112bc76c251727df28d3222f7c50e0b9d1de46693a5665555378 days 12 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x67a7fde41d3785bf1f578c74ab55e8bfe43552107cec6fa1fafbdc68ba9aa3e7665432378 days 17 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xacf2b3b3251bd6657dc914f6075ddc6370d8960481a2695340eb6bdb5080f089665430578 days 17 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xc54dd3f6036a21f4bb0377f885b1e09fc2624765dea539216006253fa0142d33665425378 days 17 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x342a134aefcf51e10d1941185f67cdd55c7bbc3f6f05dceba47235cc65fe2de4665420478 days 17 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x27528a9a64a3312570aad7755ae91d9fab827c41267a452aec2b358b890cd602665391678 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xc2755e9ed19363c4fb17e83d623a38321521a3411ac185b7ea327e0fb2997a6f665389678 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x9c074277c1cf41480ce8ab41bbacc8bc353a5c7af2aca34eec198908728fd28a665000679 days 10 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xca5396f591c7622fab430c7afab1175fad98a811ff7034f3cb9c64a0743f5cf8664964279 days 11 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x16f97db82982aa37c362ce252d3a95077056b7bc6092421e14824ea9d1bf5ac0656763092 days 22 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xbc0f9cd739ed2364e3a85e8eb139cf2f7c36b64c8ad6a964dd0cb77931ae9f4d656757792 days 22 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xb18443bef4e3cee84030d9cc4027c34cd8ecc9e8b7ef01b29416f025c5c8e300656749992 days 23 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x83a89cd49e282574cc8af3aa2d7a050eae8971c84eb50449ec42d3a2765bd42f656315193 days 15 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0xcea3c48edb83983601b917df82f6097a0e7e2399b43251ad77a02d7993862017656226293 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x408bbabd4eb40a4b80f134b1d2cf313dd14a93d62f5017bf0de17b806db40e62656224893 days 19 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
0x0d8225524a3d27d6491e018dde12f52ae33a4faf9f8e75df76c542a59875fd97656171793 days 21 hrs ago0x15e90976b01cbc38e203cf9f367fba6f3462b5ff  Contract Creation0 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: LiabilityFactory
Compiler Text: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity 0.4.24;

/**
 * @title Eliptic curve signature operations
 *
 * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
 *
 * TODO Remove this library once solidity supports passing a signature to ecrecover.
 * See https://github.com/ethereum/solidity/issues/864
 *
 */

library ECRecovery {

  /**
   * @dev Recover signer address from a message by using their signature
   * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
   * @param sig bytes signature, the signature is generated using web3.eth.sign()
   */
  function recover(bytes32 hash, bytes sig)
    internal
    pure
    returns (address)
  {
    bytes32 r;
    bytes32 s;
    uint8 v;

    // Check the signature length
    if (sig.length != 65) {
      return (address(0));
    }

    // Divide the signature in r, s and v variables
    // ecrecover takes the signature parameters, and the only way to get them
    // currently is to use assembly.
    // solium-disable-next-line security/no-inline-assembly
    assembly {
      r := mload(add(sig, 32))
      s := mload(add(sig, 64))
      v := byte(0, mload(add(sig, 96)))
    }

    // Version of signature should be 27 or 28, but 0 and 1 are also possible versions
    if (v < 27) {
      v += 27;
    }

    // If the version is correct return the signer address
    if (v != 27 && v != 28) {
      return (address(0));
    } else {
      // solium-disable-next-line arg-overflow
      return ecrecover(hash, v, r, s);
    }
  }

  /**
   * toEthSignedMessageHash
   * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:"
   * @dev and hash the result
   */
  function toEthSignedMessageHash(bytes32 hash)
    internal
    pure
    returns (bytes32)
  {
    // 32 is the length in bytes of hash,
    // enforced by the type signature above
    return keccak256(
      "\x19Ethereum Signed Message:\n32",
      hash
    );
  }
}

// File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol

/**
 * @title ERC20Basic
 * @dev Simpler version of ERC20 interface
 * See https://github.com/ethereum/EIPs/issues/179
 */
contract ERC20Basic {
  function totalSupply() public view returns (uint256);
  function balanceOf(address _who) public view returns (uint256);
  function transfer(address _to, uint256 _value) public returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);
}

// File: openzeppelin-solidity/contracts/math/SafeMath.sol

/**
 * @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;
  }
}

// File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol

/**
 * @title Basic token
 * @dev Basic version of StandardToken, with no allowances.
 */
contract BasicToken is ERC20Basic {
  using SafeMath for uint256;

  mapping(address => uint256) internal balances;

  uint256 internal totalSupply_;

  /**
  * @dev Total number of tokens in existence
  */
  function totalSupply() public view returns (uint256) {
    return totalSupply_;
  }

  /**
  * @dev Transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint256 _value) public returns (bool) {
    require(_value <= balances[msg.sender]);
    require(_to != address(0));

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
    return true;
  }

  /**
  * @dev Gets the balance of the specified address.
  * @param _owner The address to query the the balance of.
  * @return An uint256 representing the amount owned by the passed address.
  */
  function balanceOf(address _owner) public view returns (uint256) {
    return balances[_owner];
  }

}

// File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
contract ERC20 is ERC20Basic {
  function allowance(address _owner, address _spender)
    public view returns (uint256);

  function transferFrom(address _from, address _to, uint256 _value)
    public returns (bool);

  function approve(address _spender, uint256 _value) public returns (bool);
  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
  );
}

// File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol

/**
 * @title Standard ERC20 token
 *
 * @dev Implementation of the basic standard token.
 * https://github.com/ethereum/EIPs/issues/20
 * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is ERC20, BasicToken {

  mapping (address => mapping (address => uint256)) internal allowed;


  /**
   * @dev Transfer tokens from one address to another
   * @param _from address The address which you want to send tokens from
   * @param _to address The address which you want to transfer to
   * @param _value uint256 the amount of tokens to be transferred
   */
  function transferFrom(
    address _from,
    address _to,
    uint256 _value
  )
    public
    returns (bool)
  {
    require(_value <= balances[_from]);
    require(_value <= allowed[_from][msg.sender]);
    require(_to != address(0));

    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
    emit Transfer(_from, _to, _value);
    return true;
  }

  /**
   * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
   * Beware that changing an allowance with this method brings the risk that someone may use both the old
   * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
   * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
   * @param _spender The address which will spend the funds.
   * @param _value The amount of tokens to be spent.
   */
  function approve(address _spender, uint256 _value) public returns (bool) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
  }

  /**
   * @dev Function to check the amount of tokens that an owner allowed to a spender.
   * @param _owner address The address which owns the funds.
   * @param _spender address The address which will spend the funds.
   * @return A uint256 specifying the amount of tokens still available for the spender.
   */
  function allowance(
    address _owner,
    address _spender
   )
    public
    view
    returns (uint256)
  {
    return allowed[_owner][_spender];
  }

  /**
   * @dev Increase the amount of tokens that an owner allowed to a spender.
   * approve should be called when allowed[_spender] == 0. To increment
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _addedValue The amount of tokens to increase the allowance by.
   */
  function increaseApproval(
    address _spender,
    uint256 _addedValue
  )
    public
    returns (bool)
  {
    allowed[msg.sender][_spender] = (
      allowed[msg.sender][_spender].add(_addedValue));
    emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    return true;
  }

  /**
   * @dev Decrease the amount of tokens that an owner allowed to a spender.
   * approve should be called when allowed[_spender] == 0. To decrement
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _subtractedValue The amount of tokens to decrease the allowance by.
   */
  function decreaseApproval(
    address _spender,
    uint256 _subtractedValue
  )
    public
    returns (bool)
  {
    uint256 oldValue = allowed[msg.sender][_spender];
    if (_subtractedValue >= oldValue) {
      allowed[msg.sender][_spender] = 0;
    } else {
      allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
    }
    emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    return true;
  }

}

// File: openzeppelin-solidity/contracts/ownership/Ownable.sol

/**
 * @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.
   * @notice Renouncing to ownership will leave the contract without an owner.
   * It will not be possible to call the functions with the `onlyOwner`
   * modifier anymore.
   */
  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;
  }
}

// File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol

/**
 * @title Mintable token
 * @dev Simple ERC20 Token example, with mintable token creation
 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
 */
contract MintableToken is StandardToken, Ownable {
  event Mint(address indexed to, uint256 amount);
  event MintFinished();

  bool public mintingFinished = false;


  modifier canMint() {
    require(!mintingFinished);
    _;
  }

  modifier hasMintPermission() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Function to mint tokens
   * @param _to The address that will receive the minted tokens.
   * @param _amount The amount of tokens to mint.
   * @return A boolean that indicates if the operation was successful.
   */
  function mint(
    address _to,
    uint256 _amount
  )
    public
    hasMintPermission
    canMint
    returns (bool)
  {
    totalSupply_ = totalSupply_.add(_amount);
    balances[_to] = balances[_to].add(_amount);
    emit Mint(_to, _amount);
    emit Transfer(address(0), _to, _amount);
    return true;
  }

  /**
   * @dev Function to stop minting new tokens.
   * @return True if the operation was successful.
   */
  function finishMinting() public onlyOwner canMint returns (bool) {
    mintingFinished = true;
    emit MintFinished();
    return true;
  }
}

// File: openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol

/**
 * @title Burnable Token
 * @dev Token that can be irreversibly burned (destroyed).
 */
contract BurnableToken is BasicToken {

  event Burn(address indexed burner, uint256 value);

  /**
   * @dev Burns a specific amount of tokens.
   * @param _value The amount of token to be burned.
   */
  function burn(uint256 _value) public {
    _burn(msg.sender, _value);
  }

  function _burn(address _who, uint256 _value) internal {
    require(_value <= balances[_who]);
    // no need to require value <= totalSupply, since that would imply the
    // sender's balance is greater than the totalSupply, which *should* be an assertion failure

    balances[_who] = balances[_who].sub(_value);
    totalSupply_ = totalSupply_.sub(_value);
    emit Burn(_who, _value);
    emit Transfer(_who, address(0), _value);
  }
}

// File: contracts/robonomics/XRT.sol

contract XRT is MintableToken, BurnableToken {
    string public constant name     = "Robonomics Beta";
    string public constant symbol   = "XRT";
    uint   public constant decimals = 9;

    uint256 public constant INITIAL_SUPPLY = 1000 * (10 ** uint256(decimals));

    constructor() public {
        totalSupply_ = INITIAL_SUPPLY;
        balances[msg.sender] = INITIAL_SUPPLY;
        emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
    }
}


// File: contracts/robonomics/DutchAuction.sol

/// @title Dutch auction contract - distribution of XRT tokens using an auction.
/// @author Stefan George - <[email protected]>
/// @author Airalab - <[email protected]> 
contract DutchAuction {

    /*
     *  Events
     */
    event BidSubmission(address indexed sender, uint256 amount);

    /*
     *  Constants
     */
    uint constant public MAX_TOKENS_SOLD = 8000 * 10**9; // 8M XRT = 10M - 1M (Foundation) - 1M (Early investors base)
    uint constant public WAITING_PERIOD = 0; // 1 days;

    /*
     *  Storage
     */
    XRT     public xrt;
    address public ambix;
    address public wallet;
    address public owner;
    uint public ceiling;
    uint public priceFactor;
    uint public startBlock;
    uint public endTime;
    uint public totalReceived;
    uint public finalPrice;
    mapping (address => uint) public bids;
    Stages public stage;

    /*
     *  Enums
     */
    enum Stages {
        AuctionDeployed,
        AuctionSetUp,
        AuctionStarted,
        AuctionEnded,
        TradingStarted
    }

    /*
     *  Modifiers
     */
    modifier atStage(Stages _stage) {
        // Contract on stage
        require(stage == _stage);
        _;
    }

    modifier isOwner() {
        // Only owner is allowed to proceed
        require(msg.sender == owner);
        _;
    }

    modifier isWallet() {
        // Only wallet is allowed to proceed
        require(msg.sender == wallet);
        _;
    }

    modifier isValidPayload() {
        require(msg.data.length == 4 || msg.data.length == 36);
        _;
    }

    modifier timedTransitions() {
        if (stage == Stages.AuctionStarted && calcTokenPrice() <= calcStopPrice())
            finalizeAuction();
        if (stage == Stages.AuctionEnded && now > endTime + WAITING_PERIOD)
            stage = Stages.TradingStarted;
        _;
    }

    /*
     *  Public functions
     */
    /// @dev Contract constructor function sets owner.
    /// @param _wallet Multisig wallet.
    /// @param _ceiling Auction ceiling.
    /// @param _priceFactor Auction price factor.
    constructor(address _wallet, uint _ceiling, uint _priceFactor)
        public
    {
        require(_wallet != 0 && _ceiling != 0 && _priceFactor != 0);
        owner = msg.sender;
        wallet = _wallet;
        ceiling = _ceiling;
        priceFactor = _priceFactor;
        stage = Stages.AuctionDeployed;
    }

    /// @dev Setup function sets external contracts' addresses.
    /// @param _xrt Robonomics token address.
    /// @param _ambix Distillation cube address.
    function setup(address _xrt, address _ambix)
        public
        isOwner
        atStage(Stages.AuctionDeployed)
    {
        // Validate argument
        require(_xrt != 0 && _ambix != 0);
        xrt = XRT(_xrt);
        ambix = _ambix;

        // Validate token balance
        require(xrt.balanceOf(this) == MAX_TOKENS_SOLD);

        stage = Stages.AuctionSetUp;
    }

    /// @dev Starts auction and sets startBlock.
    function startAuction()
        public
        isWallet
        atStage(Stages.AuctionSetUp)
    {
        stage = Stages.AuctionStarted;
        startBlock = block.number;
    }

    /// @dev Changes auction ceiling and start price factor before auction is started.
    /// @param _ceiling Updated auction ceiling.
    /// @param _priceFactor Updated start price factor.
    function changeSettings(uint _ceiling, uint _priceFactor)
        public
        isWallet
        atStage(Stages.AuctionSetUp)
    {
        ceiling = _ceiling;
        priceFactor = _priceFactor;
    }

    /// @dev Calculates current token price.
    /// @return Returns token price.
    function calcCurrentTokenPrice()
        public
        timedTransitions
        returns (uint)
    {
        if (stage == Stages.AuctionEnded || stage == Stages.TradingStarted)
            return finalPrice;
        return calcTokenPrice();
    }

    /// @dev Returns correct stage, even if a function with timedTransitions modifier has not yet been called yet.
    /// @return Returns current auction stage.
    function updateStage()
        public
        timedTransitions
        returns (Stages)
    {
        return stage;
    }

    /// @dev Allows to send a bid to the auction.
    /// @param receiver Bid will be assigned to this address if set.
    function bid(address receiver)
        public
        payable
        isValidPayload
        timedTransitions
        atStage(Stages.AuctionStarted)
        returns (uint amount)
    {
        require(msg.value > 0);
        amount = msg.value;

        // If a bid is done on behalf of a user via ShapeShift, the receiver address is set.
        if (receiver == 0)
            receiver = msg.sender;

        // Prevent that more than 90% of tokens are sold. Only relevant if cap not reached.
        uint maxWei = MAX_TOKENS_SOLD * calcTokenPrice() / 10**9 - totalReceived;
        uint maxWeiBasedOnTotalReceived = ceiling - totalReceived;
        if (maxWeiBasedOnTotalReceived < maxWei)
            maxWei = maxWeiBasedOnTotalReceived;

        // Only invest maximum possible amount.
        if (amount > maxWei) {
            amount = maxWei;
            // Send change back to receiver address. In case of a ShapeShift bid the user receives the change back directly.
            receiver.transfer(msg.value - amount);
        }

        // Forward funding to ether wallet
        wallet.transfer(amount);

        bids[receiver] += amount;
        totalReceived += amount;
        BidSubmission(receiver, amount);

        // Finalize auction when maxWei reached
        if (amount == maxWei)
            finalizeAuction();
    }

    /// @dev Claims tokens for bidder after auction.
    /// @param receiver Tokens will be assigned to this address if set.
    function claimTokens(address receiver)
        public
        isValidPayload
        timedTransitions
        atStage(Stages.TradingStarted)
    {
        if (receiver == 0)
            receiver = msg.sender;
        uint tokenCount = bids[receiver] * 10**9 / finalPrice;
        bids[receiver] = 0;
        require(xrt.transfer(receiver, tokenCount));
    }

    /// @dev Calculates stop price.
    /// @return Returns stop price.
    function calcStopPrice()
        view
        public
        returns (uint)
    {
        return totalReceived * 10**9 / MAX_TOKENS_SOLD + 1;
    }

    /// @dev Calculates token price.
    /// @return Returns token price.
    function calcTokenPrice()
        view
        public
        returns (uint)
    {
        return priceFactor * 10**18 / (block.number - startBlock + 7500) + 1;
    }

    /*
     *  Private functions
     */
    function finalizeAuction()
        private
    {
        stage = Stages.AuctionEnded;
        finalPrice = totalReceived == ceiling ? calcTokenPrice() : calcStopPrice();
        uint soldTokens = totalReceived * 10**9 / finalPrice;

        if (totalReceived == ceiling) {
            // Auction contract transfers all unsold tokens to Ambix contract
            require(xrt.transfer(ambix, MAX_TOKENS_SOLD - soldTokens));
        } else {
            // Auction contract burn all unsold tokens
            xrt.burn(MAX_TOKENS_SOLD - soldTokens);
        }

        endTime = now;
    }
}

// File: ens/contracts/ENS.sol

interface ENS {

    // Logged when the owner of a node assigns a new owner to a subnode.
    event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);

    // Logged when the owner of a node transfers ownership to a new account.
    event Transfer(bytes32 indexed node, address owner);

    // Logged when the resolver for a node changes.
    event NewResolver(bytes32 indexed node, address resolver);

    // Logged when the TTL of a node changes
    event NewTTL(bytes32 indexed node, uint64 ttl);


    function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public;
    function setResolver(bytes32 node, address resolver) public;
    function setOwner(bytes32 node, address owner) public;
    function setTTL(bytes32 node, uint64 ttl) public;
    function owner(bytes32 node) public view returns (address);
    function resolver(bytes32 node) public view returns (address);
    function ttl(bytes32 node) public view returns (uint64);

}

// File: ens/contracts/PublicResolver.sol

/**
 * A simple resolver anyone can use; only allows the owner of a node to set its
 * address.
 */
contract PublicResolver {

    bytes4 constant INTERFACE_META_ID = 0x01ffc9a7;
    bytes4 constant ADDR_INTERFACE_ID = 0x3b3b57de;
    bytes4 constant CONTENT_INTERFACE_ID = 0xd8389dc5;
    bytes4 constant NAME_INTERFACE_ID = 0x691f3431;
    bytes4 constant ABI_INTERFACE_ID = 0x2203ab56;
    bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233;
    bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c;
    bytes4 constant MULTIHASH_INTERFACE_ID = 0xe89401a1;

    event AddrChanged(bytes32 indexed node, address a);
    event ContentChanged(bytes32 indexed node, bytes32 hash);
    event NameChanged(bytes32 indexed node, string name);
    event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
    event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
    event TextChanged(bytes32 indexed node, string indexedKey, string key);
    event MultihashChanged(bytes32 indexed node, bytes hash);

    struct PublicKey {
        bytes32 x;
        bytes32 y;
    }

    struct Record {
        address addr;
        bytes32 content;
        string name;
        PublicKey pubkey;
        mapping(string=>string) text;
        mapping(uint256=>bytes) abis;
        bytes multihash;
    }

    ENS ens;

    mapping (bytes32 => Record) records;

    modifier only_owner(bytes32 node) {
        require(ens.owner(node) == msg.sender);
        _;
    }

    /**
     * Constructor.
     * @param ensAddr The ENS registrar contract.
     */
    function PublicResolver(ENS ensAddr) public {
        ens = ensAddr;
    }

    /**
     * Sets the address associated with an ENS node.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     * @param addr The address to set.
     */
    function setAddr(bytes32 node, address addr) public only_owner(node) {
        records[node].addr = addr;
        AddrChanged(node, addr);
    }

    /**
     * Sets the content hash associated with an ENS node.
     * May only be called by the owner of that node in the ENS registry.
     * Note that this resource type is not standardized, and will likely change
     * in future to a resource type based on multihash.
     * @param node The node to update.
     * @param hash The content hash to set
     */
    function setContent(bytes32 node, bytes32 hash) public only_owner(node) {
        records[node].content = hash;
        ContentChanged(node, hash);
    }

    /**
     * Sets the multihash associated with an ENS node.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     * @param hash The multihash to set
     */
    function setMultihash(bytes32 node, bytes hash) public only_owner(node) {
        records[node].multihash = hash;
        MultihashChanged(node, hash);
    }
    
    /**
     * Sets the name associated with an ENS node, for reverse records.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     * @param name The name to set.
     */
    function setName(bytes32 node, string name) public only_owner(node) {
        records[node].name = name;
        NameChanged(node, name);
    }

    /**
     * Sets the ABI associated with an ENS node.
     * Nodes may have one ABI of each content type. To remove an ABI, set it to
     * the empty string.
     * @param node The node to update.
     * @param contentType The content type of the ABI
     * @param data The ABI data.
     */
    function setABI(bytes32 node, uint256 contentType, bytes data) public only_owner(node) {
        // Content types must be powers of 2
        require(((contentType - 1) & contentType) == 0);
        
        records[node].abis[contentType] = data;
        ABIChanged(node, contentType);
    }
    
    /**
     * Sets the SECP256k1 public key associated with an ENS node.
     * @param node The ENS node to query
     * @param x the X coordinate of the curve point for the public key.
     * @param y the Y coordinate of the curve point for the public key.
     */
    function setPubkey(bytes32 node, bytes32 x, bytes32 y) public only_owner(node) {
        records[node].pubkey = PublicKey(x, y);
        PubkeyChanged(node, x, y);
    }

    /**
     * Sets the text data associated with an ENS node and key.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     * @param key The key to set.
     * @param value The text data value to set.
     */
    function setText(bytes32 node, string key, string value) public only_owner(node) {
        records[node].text[key] = value;
        TextChanged(node, key, key);
    }

    /**
     * Returns the text data associated with an ENS node and key.
     * @param node The ENS node to query.
     * @param key The text data key to query.
     * @return The associated text data.
     */
    function text(bytes32 node, string key) public view returns (string) {
        return records[node].text[key];
    }

    /**
     * Returns the SECP256k1 public key associated with an ENS node.
     * Defined in EIP 619.
     * @param node The ENS node to query
     * @return x, y the X and Y coordinates of the curve point for the public key.
     */
    function pubkey(bytes32 node) public view returns (bytes32 x, bytes32 y) {
        return (records[node].pubkey.x, records[node].pubkey.y);
    }

    /**
     * Returns the ABI associated with an ENS node.
     * Defined in EIP205.
     * @param node The ENS node to query
     * @param contentTypes A bitwise OR of the ABI formats accepted by the caller.
     * @return contentType The content type of the return value
     * @return data The ABI data
     */
    function ABI(bytes32 node, uint256 contentTypes) public view returns (uint256 contentType, bytes data) {
        Record storage record = records[node];
        for (contentType = 1; contentType <= contentTypes; contentType <<= 1) {
            if ((contentType & contentTypes) != 0 && record.abis[contentType].length > 0) {
                data = record.abis[contentType];
                return;
            }
        }
        contentType = 0;
    }

    /**
     * Returns the name associated with an ENS node, for reverse records.
     * Defined in EIP181.
     * @param node The ENS node to query.
     * @return The associated name.
     */
    function name(bytes32 node) public view returns (string) {
        return records[node].name;
    }

    /**
     * Returns the content hash associated with an ENS node.
     * Note that this resource type is not standardized, and will likely change
     * in future to a resource type based on multihash.
     * @param node The ENS node to query.
     * @return The associated content hash.
     */
    function content(bytes32 node) public view returns (bytes32) {
        return records[node].content;
    }

    /**
     * Returns the multihash associated with an ENS node.
     * @param node The ENS node to query.
     * @return The associated multihash.
     */
    function multihash(bytes32 node) public view returns (bytes) {
        return records[node].multihash;
    }

    /**
     * Returns the address associated with an ENS node.
     * @param node The ENS node to query.
     * @return The associated address.
     */
    function addr(bytes32 node) public view returns (address) {
        return records[node].addr;
    }

    /**
     * Returns true if the resolver implements the interface specified by the provided hash.
     * @param interfaceID The ID of the interface to check for.
     * @return True if the contract implements the requested interface.
     */
    function supportsInterface(bytes4 interfaceID) public pure returns (bool) {
        return interfaceID == ADDR_INTERFACE_ID ||
        interfaceID == CONTENT_INTERFACE_ID ||
        interfaceID == NAME_INTERFACE_ID ||
        interfaceID == ABI_INTERFACE_ID ||
        interfaceID == PUBKEY_INTERFACE_ID ||
        interfaceID == TEXT_INTERFACE_ID ||
        interfaceID == MULTIHASH_INTERFACE_ID ||
        interfaceID == INTERFACE_META_ID;
    }
}

contract LightContract {
    /**
     * @dev Shared code smart contract 
     */
    address lib;

    constructor(address _library) public {
        lib = _library;
    }

    function() public {
        require(lib.delegatecall(msg.data));
    }
}

contract LighthouseABI {
    function refill(uint256 _value) external;
    function withdraw(uint256 _value) external;
    function to(address _to, bytes _data) external;
    function () external;
}

contract LighthouseAPI {
    address[] public members;
    mapping(address => uint256) indexOf;

    mapping(address => uint256) public balances;

    uint256 public minimalFreeze;
    uint256 public timeoutBlocks;

    LiabilityFactory public factory;
    XRT              public xrt;

    uint256 public keepaliveBlock = 0;
    uint256 public marker = 0;
    uint256 public quota = 0;

    function quotaOf(address _member) public view returns (uint256)
    { return balances[_member] / minimalFreeze; }
}

contract LighthouseLib is LighthouseAPI, LighthouseABI {

    function refill(uint256 _value) external {
        require(xrt.transferFrom(msg.sender, this, _value));
        require(_value >= minimalFreeze);

        if (balances[msg.sender] == 0) {
            indexOf[msg.sender] = members.length;
            members.push(msg.sender);
        }
        balances[msg.sender] += _value;
    }

    function withdraw(uint256 _value) external {
        require(balances[msg.sender] >= _value);

        balances[msg.sender] -= _value;
        require(xrt.transfer(msg.sender, _value));

        // Drop member if quota go to zero
        if (quotaOf(msg.sender) == 0) {
            uint256 balance = balances[msg.sender];
            balances[msg.sender] = 0;
            require(xrt.transfer(msg.sender, balance)); 
            
            uint256 senderIndex = indexOf[msg.sender];
            uint256 lastIndex = members.length - 1;
            if (senderIndex < lastIndex)
                members[senderIndex] = members[lastIndex];
            members.length -= 1;
        }
    }

    function nextMember() internal
    { marker = (marker + 1) % members.length; }

    modifier quoted {
        if (quota == 0) {
            // Step over marker
            nextMember();

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        // Consume one quota for transaction sending
        assert(quota > 0);
        quota -= 1;

        _;
    }

    modifier keepalive {
        if (timeoutBlocks < block.number - keepaliveBlock) {
            // Search keepalive sender
            while (msg.sender != members[marker])
                nextMember();

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        _;
    }

    modifier member {
        // Zero members guard
        require(members.length > 0);

        // Only member with marker can to send transaction
        require(msg.sender == members[marker]);

        // Store transaction sending block
        keepaliveBlock = block.number;

        _;
    }

    function to(address _to, bytes _data) external keepalive quoted member {
        require(factory.gasUtilizing(_to) > 0);
        require(_to.call(_data));
    }

    function () external keepalive quoted member
    { require(factory.call(msg.data)); }
}

contract Lighthouse is LighthouseAPI, LightContract {
    constructor(
        address _lib,
        uint256 _minimalFreeze,
        uint256 _timeoutBlocks
    ) 
        public
        LightContract(_lib)
    {
        minimalFreeze = _minimalFreeze;
        timeoutBlocks = _timeoutBlocks;
        factory = LiabilityFactory(msg.sender);
        xrt = factory.xrt();
    }
}

contract RobotLiabilityABI {
    function ask(
        bytes   _model,
        bytes   _objective,

        ERC20   _token,
        uint256 _cost,

        address _validator,
        uint256 _validator_fee,

        uint256 _deadline,
        bytes32 _nonce,
        bytes   _signature
    ) external returns (bool);

    function bid(
        bytes   _model,
        bytes   _objective,
        
        ERC20   _token,
        uint256 _cost,

        uint256 _lighthouse_fee,

        uint256 _deadline,
        bytes32 _nonce,
        bytes   _signature
    ) external returns (bool);

    function finalize(
        bytes _result,
        bytes _signature,
        bool  _agree
    ) external returns (bool);
}

contract RobotLiabilityAPI {
    bytes   public model;
    bytes   public objective;
    bytes   public result;

    ERC20   public token;
    uint256 public cost;
    uint256 public lighthouseFee;
    uint256 public validatorFee;

    bytes32 public askHash;
    bytes32 public bidHash;

    address public promisor;
    address public promisee;
    address public validator;

    bool    public isConfirmed;
    bool    public isFinalized;

    LiabilityFactory public factory;
}

contract RobotLiabilityLib is RobotLiabilityABI
                            , RobotLiabilityAPI {
    using ECRecovery for bytes32;

    function ask(
        bytes   _model,
        bytes   _objective,

        ERC20   _token,
        uint256 _cost,

        address _validator,
        uint256 _validator_fee,

        uint256 _deadline,
        bytes32 _nonce,
        bytes   _signature
    )
        external
        returns (bool)
    {
        require(msg.sender == address(factory));
        require(block.number < _deadline);

        model        = _model;
        objective    = _objective;
        token        = _token;
        cost         = _cost;
        validator    = _validator;
        validatorFee = _validator_fee;

        askHash = keccak256(abi.encodePacked(
            _model
          , _objective
          , _token
          , _cost
          , _validator
          , _validator_fee
          , _deadline
          , _nonce
        ));

        promisee = askHash
            .toEthSignedMessageHash()
            .recover(_signature);
        return true;
    }

    function bid(
        bytes   _model,
        bytes   _objective,
        
        ERC20   _token,
        uint256 _cost,

        uint256 _lighthouse_fee,

        uint256 _deadline,
        bytes32 _nonce,
        bytes   _signature
    )
        external
        returns (bool)
    {
        require(msg.sender == address(factory));
        require(block.number < _deadline);
        require(keccak256(model) == keccak256(_model));
        require(keccak256(objective) == keccak256(_objective));
        require(_token == token);
        require(_cost == cost);

        lighthouseFee = _lighthouse_fee;

        bidHash = keccak256(abi.encodePacked(
            _model
          , _objective
          , _token
          , _cost
          , _lighthouse_fee
          , _deadline
          , _nonce
        ));

        promisor = bidHash
            .toEthSignedMessageHash()
            .recover(_signature);
        return true;
    }

    /**
     * @dev Finalize this liability
     * @param _result Result data hash
     * @param _agree Validation network confirmation
     * @param _signature Result sender signature
     */
    function finalize(
        bytes _result,
        bytes _signature,
        bool  _agree
    )
        external
        returns (bool)
    {
        uint256 gasinit = gasleft();
        require(!isFinalized);

        address resultSender = keccak256(abi.encodePacked(this, _result))
            .toEthSignedMessageHash()
            .recover(_signature);
        require(resultSender == promisor);

        result = _result;
        isFinalized = true;

        if (validator == 0) {
            require(factory.isLighthouse(msg.sender));
            require(token.transfer(promisor, cost));
        } else {
            require(msg.sender == validator);

            isConfirmed = _agree;
            if (isConfirmed)
                require(token.transfer(promisor, cost));
            else
                require(token.transfer(promisee, cost));

            if (validatorFee > 0)
                require(factory.xrt().transfer(validator, validatorFee));
        }

        require(factory.liabilityFinalized(gasinit));
        return true;
    }
}

// Standard robot liability light contract
contract RobotLiability is RobotLiabilityAPI, LightContract {
    constructor(address _lib) public LightContract(_lib)
    { factory = LiabilityFactory(msg.sender); }
}

contract LiabilityFactory {
    constructor(
        address _robot_liability_lib,
        address _lighthouse_lib,
        DutchAuction _auction,
        XRT _xrt,
        ENS _ens
    ) public {
        robotLiabilityLib = _robot_liability_lib;
        lighthouseLib = _lighthouse_lib;
        auction = _auction;
        xrt = _xrt;
        ens = _ens;
    }

    /**
     * @dev New liability created 
     */
    event NewLiability(address indexed liability);

    /**
     * @dev New lighthouse created
     */
    event NewLighthouse(address indexed lighthouse, string name);

    /**
     * @dev Robonomics dutch auction contract
     */
    DutchAuction public auction;

    /**
     * @dev Robonomics network protocol token
     */
    XRT public xrt;

    /**
     * @dev Ethereum name system
     */
    ENS public ens;

    /**
     * @dev Total GAS utilized by Robonomics network
     */
    uint256 public totalGasUtilizing = 0;

    /**
     * @dev GAS utilized by liability contracts
     */
    mapping(address => uint256) public gasUtilizing;

    /**
     * @dev The count of utilized gas for switch to next epoch 
     */
    uint256 public constant gasEpoch = 347 * 10**10;

    /**
     * @dev Weighted average gasprice
     */
    uint256 public constant gasPrice = 10 * 10**9;

    /**
     * @dev Used market orders accounting
     */
    mapping(bytes32 => bool) public usedHash;

    /**
     * @dev Lighthouse accounting
     */
    mapping(address => bool) public isLighthouse;

    /**
     * @dev Robot liability shared code smart contract
     */
    address public robotLiabilityLib;

    /**
     * @dev Lightouse shared code smart contract
     */
    address public lighthouseLib;

    /**
     * @dev XRT emission value for utilized gas
     */
    function wnFromGas(uint256 _gas) public view returns (uint256) {
        // Just return wn=gas when auction isn't finish
        if (auction.finalPrice() == 0)
            return _gas;

        // Current gas utilization epoch
        uint256 epoch = totalGasUtilizing / gasEpoch;

        // XRT emission with addition coefficient by gas utilzation epoch
        uint256 wn = _gas * 10**9 * gasPrice * 2**epoch / 3**epoch / auction.finalPrice();

        // Check to not permit emission decrease below wn=gas
        return wn < _gas ? _gas : wn;
    }

    /**
     * @dev Only lighthouse guard
     */
    modifier onlyLighthouse {
        require(isLighthouse[msg.sender]);
        _;
    }

    /**
     * @dev Parameter can be used only once
     * @param _hash Single usage hash
     */
    function usedHashGuard(bytes32 _hash) internal {
        require(!usedHash[_hash]);
        usedHash[_hash] = true;
    }

    /**
     * @dev Create robot liability smart contract
     * @param _ask ABI-encoded ASK order message 
     * @param _bid ABI-encoded BID order message 
     */
    function createLiability(
        bytes _ask,
        bytes _bid
    )
        external 
        onlyLighthouse
        returns (RobotLiability liability)
    {
        // Store in memory available gas
        uint256 gasinit = gasleft();

        // Create liability
        liability = new RobotLiability(robotLiabilityLib);
        emit NewLiability(liability);

        // Parse messages
        require(liability.call(abi.encodePacked(bytes4(0x82fbaa25), _ask))); // liability.ask(...)
        usedHashGuard(liability.askHash());

        require(liability.call(abi.encodePacked(bytes4(0x66193359), _bid))); // liability.bid(...)
        usedHashGuard(liability.bidHash());

        // Transfer lighthouse fee to lighthouse worker directly
        require(xrt.transferFrom(liability.promisor(),
                                 tx.origin,
                                 liability.lighthouseFee()));

        // Transfer liability security and hold on contract
        ERC20 token = liability.token();
        require(token.transferFrom(liability.promisee(),
                                   liability,
                                   liability.cost()));

        // Transfer validator fee and hold on contract
        if (address(liability.validator()) != 0 && liability.validatorFee() > 0)
            require(xrt.transferFrom(liability.promisee(),
                                     liability,
                                     liability.validatorFee()));

        // Accounting gas usage of transaction
        uint256 gas = gasinit - gasleft() + 110525; // Including observation error
        totalGasUtilizing       += gas;
        gasUtilizing[liability] += gas;
     }

    /**
     * @dev Create lighthouse smart contract
     * @param _minimalFreeze Minimal freeze value of XRT token
     * @param _timeoutBlocks Max time of lighthouse silence in blocks
     * @param _name Lighthouse subdomain,
     *              example: for 'my-name' will created 'my-name.lighthouse.1.robonomics.eth' domain
     */
    function createLighthouse(
        uint256 _minimalFreeze,
        uint256 _timeoutBlocks,
        string  _name
    )
        external
        returns (address lighthouse)
    {
        bytes32 lighthouseNode
            // lighthouse.1.robonomics.eth
            = 0x3662a5d633e9a5ca4b4bd25284e1b343c15a92b5347feb9b965a2b1ef3e1ea1a;

        // Name reservation check
        bytes32 subnode = keccak256(abi.encodePacked(lighthouseNode, keccak256(_name)));
        require(ens.resolver(subnode) == 0);

        // Create lighthouse
        lighthouse = new Lighthouse(lighthouseLib, _minimalFreeze, _timeoutBlocks);
        emit NewLighthouse(lighthouse, _name);
        isLighthouse[lighthouse] = true;

        // Register subnode
        ens.setSubnodeOwner(lighthouseNode, keccak256(_name), this);

        // Register lighthouse address
        PublicResolver resolver = PublicResolver(ens.resolver(lighthouseNode));
        ens.setResolver(subnode, resolver);
        resolver.setAddr(subnode, lighthouse);
    }

    /**
     * @dev Is called whan after liability finalization
     * @param _gas Liability finalization gas expenses
     */
    function liabilityFinalized(
        uint256 _gas
    )
        external
        returns (bool)
    {
        require(gasUtilizing[msg.sender] > 0);

        uint256 gas = _gas - gasleft();
        totalGasUtilizing        += gas;
        gasUtilizing[msg.sender] += gas;
        require(xrt.mint(tx.origin, wnFromGas(gasUtilizing[msg.sender])));
        return true;
    }
}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"robotLiabilityLib","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gasEpoch","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"xrt","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_minimalFreeze","type":"uint256"},{"name":"_timeoutBlocks","type":"uint256"},{"name":"_name","type":"string"}],"name":"createLighthouse","outputs":[{"name":"lighthouse","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"usedHash","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"auction","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"gasUtilizing","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isLighthouse","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalGasUtilizing","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_gas","type":"uint256"}],"name":"liabilityFinalized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_ask","type":"bytes"},{"name":"_bid","type":"bytes"}],"name":"createLiability","outputs":[{"name":"liability","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_gas","type":"uint256"}],"name":"wnFromGas","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lighthouseLib","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gasPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_robot_liability_lib","type":"address"},{"name":"_lighthouse_lib","type":"address"},{"name":"_auction","type":"address"},{"name":"_xrt","type":"address"},{"name":"_ens","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"liability","type":"address"}],"name":"NewLiability","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"lighthouse","type":"address"},{"indexed":false,"name":"name","type":"string"}],"name":"NewLighthouse","type":"event"}]

  Contract Creation Code Switch To Opcodes View
6080604052600060035534801561001557600080fd5b5060405160a080611e358339810160409081528151602083015191830151606084015160809094015160078054600160a060020a0319908116600160a060020a039586161790915560088054821695851695909517909455600080548516928416929092178255600180548516958416959095179094556002805490931691909316179055611d8b9081906100aa90396000f3006080604052600436106100c15763ffffffff60e060020a6000350416630d71212f81146100c6578063284fd42f146100f7578063330f95881461011e5780633f15457f146101335780634d5b85f114610148578063560ebbd1146101705780637d9f6db51461019c578063afecd5e4146101b1578063bbb6630f146101d2578063c15aec44146101f3578063c9b94eb914610208578063d2b962f214610220578063d64d136d1461024c578063da302fc314610264578063fe173b9714610279575b600080fd5b3480156100d257600080fd5b506100db61028e565b60408051600160a060020a039092168252519081900360200190f35b34801561010357600080fd5b5061010c61029d565b60408051918252519081900360200190f35b34801561012a57600080fd5b506100db6102a7565b34801561013f57600080fd5b506100db6102b6565b34801561015457600080fd5b506100db600480359060248035916044359182019101356102c5565b34801561017c57600080fd5b50610188600435610734565b604080519115158252519081900360200190f35b3480156101a857600080fd5b506100db610749565b3480156101bd57600080fd5b5061010c600160a060020a0360043516610758565b3480156101de57600080fd5b50610188600160a060020a036004351661076a565b3480156101ff57600080fd5b5061010c61077f565b34801561021457600080fd5b50610188600435610785565b34801561022c57600080fd5b506100db602460048035828101929082013591813591820191013561087b565b34801561025857600080fd5b5061010c6004356111fe565b34801561027057600080fd5b506100db611360565b34801561028557600080fd5b5061010c61136f565b600754600160a060020a031681565b650327ec1e0c0081565b600154600160a060020a031681565b600254600160a060020a031681565b6000806000807f3662a5d633e9a5ca4b4bd25284e1b343c15a92b5347feb9b965a2b1ef3e1ea1a6001029250828686604051808383808284376040805193909101839003832060208085019890985283820152805180840382018152606090930190819052825192969095508594508601925081905083835b6020831061035d5780518252601f19909201916020918201910161033e565b51815160209384036101000a6000190180199092169116179052604080519290940182900382206002547f0178b8bf000000000000000000000000000000000000000000000000000000008452600484018290529451909850600160a060020a039094169550630178b8bf945060248083019491935090918290030181600087803b1580156103eb57600080fd5b505af11580156103ff573d6000803e3d6000fd5b505050506040513d602081101561041557600080fd5b5051600160a060020a03161561042a57600080fd5b600854600160a060020a031688886104406113af565b600160a060020a03909316835260208301919091526040808301919091525190819003606001906000f08015801561047c573d6000803e3d6000fd5b50935083600160a060020a03167ffea5f888ffd98cd2299e704fb235c2166cb5a9d9d8e9debcc08160626b8019a487876040518080602001828103825284848281815260200192508082843760405192018290039550909350505050a2600160a060020a0380851660009081526006602052604090819020805460ff1916600117905560025490519116906306ab592390859089908990808383808284376040805191909301819003812060e060020a63ffffffff8a160282526004820197909752602481019690965250306044860152516064808601956000955091935090839003019050818387803b15801561057357600080fd5b505af1158015610587573d6000803e3d6000fd5b5050600254604080517f0178b8bf000000000000000000000000000000000000000000000000000000008152600481018890529051600160a060020a039092169350630178b8bf92506024808201926020929091908290030181600087803b1580156105f257600080fd5b505af1158015610606573d6000803e3d6000fd5b505050506040513d602081101561061c57600080fd5b5051600254604080517f1896f70a00000000000000000000000000000000000000000000000000000000815260048101869052600160a060020a0380851660248301529151939450911691631896f70a9160448082019260009290919082900301818387803b15801561068e57600080fd5b505af11580156106a2573d6000803e3d6000fd5b5050604080517fd5fa2b0000000000000000000000000000000000000000000000000000000000815260048101869052600160a060020a0388811660248301529151918516935063d5fa2b00925060448082019260009290919082900301818387803b15801561071157600080fd5b505af1158015610725573d6000803e3d6000fd5b50505050505050949350505050565b60056020526000908152604090205460ff1681565b600054600160a060020a031681565b60046020526000908152604090205481565b60066020526000908152604090205460ff1681565b60035481565b33600090815260046020526040812054819081106107a257600080fd5b5a6003805491850391820190553360009081526004602052604090208054820190819055600154919250600160a060020a03909116906340c10f199032906107e9906111fe565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561083b57600080fd5b505af115801561084f573d6000803e3d6000fd5b505050506040513d602081101561086557600080fd5b5051151561087257600080fd5b50600192915050565b3360009081526006602052604081205481908190819060ff16151561089f57600080fd5b5a600754909350600160a060020a03166108b76113bf565b600160a060020a03909116815260405190819003602001906000f0801580156108e4573d6000803e3d6000fd5b50604051909450600160a060020a038516907ff0f0e2354315aae25080baa26761b4ef52d621c91208fb0edde9e3f3fade321990600090a26040517f82fbaa250000000000000000000000000000000000000000000000000000000060208201818152600160a060020a038716928b918b916024018383808284378201915050935050505060405160208183030381529060405260405180828051906020019080838360005b838110156109a257818101518382015260200161098a565b50505050905090810190601f1680156109cf5780820380516001836020036101000a031916815260200191505b509150506000604051808303816000865af191505015156109ef57600080fd5b610a6184600160a060020a0316630b0a4b176040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610a3057600080fd5b505af1158015610a44573d6000803e3d6000fd5b505050506040513d6020811015610a5a57600080fd5b5051611378565b6040517f661933590000000000000000000000000000000000000000000000000000000060208201818152600160a060020a03871692899189916024018383808284378201915050935050505060405160208183030381529060405260405180828051906020019080838360005b83811015610ae7578181015183820152602001610acf565b50505050905090810190601f168015610b145780820380516001836020036101000a031916815260200191505b509150506000604051808303816000865af19150501515610b3457600080fd5b610b7584600160a060020a031663654f4b616040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610a3057600080fd5b600160009054906101000a9004600160a060020a0316600160a060020a03166323b872dd85600160a060020a031663c2d8de546040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610bd757600080fd5b505af1158015610beb573d6000803e3d6000fd5b505050506040513d6020811015610c0157600080fd5b5051604080517f051064c600000000000000000000000000000000000000000000000000000000815290513291600160a060020a038a169163051064c6916004808201926020929091908290030181600087803b158015610c6157600080fd5b505af1158015610c75573d6000803e3d6000fd5b505050506040513d6020811015610c8b57600080fd5b50516040805160e060020a63ffffffff8716028152600160a060020a0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b158015610ce157600080fd5b505af1158015610cf5573d6000803e3d6000fd5b505050506040513d6020811015610d0b57600080fd5b50511515610d1857600080fd5b83600160a060020a031663fc0c546a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610d5657600080fd5b505af1158015610d6a573d6000803e3d6000fd5b505050506040513d6020811015610d8057600080fd5b5051604080517f474ce8720000000000000000000000000000000000000000000000000000000081529051919350600160a060020a03808516926323b872dd929188169163474ce8729160048083019260209291908290030181600087803b158015610deb57600080fd5b505af1158015610dff573d6000803e3d6000fd5b505050506040513d6020811015610e1557600080fd5b5051604080517f13faede600000000000000000000000000000000000000000000000000000000815290518891600160a060020a038316916313faede6916004808201926020929091908290030181600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b505050506040513d6020811015610e9f57600080fd5b50516040805160e060020a63ffffffff8716028152600160a060020a0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b158015610ef557600080fd5b505af1158015610f09573d6000803e3d6000fd5b505050506040513d6020811015610f1f57600080fd5b50511515610f2c57600080fd5b83600160a060020a0316633a5381b56040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610f6a57600080fd5b505af1158015610f7e573d6000803e3d6000fd5b505050506040513d6020811015610f9457600080fd5b5051600160a060020a0316158015906110165750600084600160a060020a0316633f6d82566040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610fe857600080fd5b505af1158015610ffc573d6000803e3d6000fd5b505050506040513d602081101561101257600080fd5b5051115b156111be57600160009054906101000a9004600160a060020a0316600160a060020a03166323b872dd85600160a060020a031663474ce8726040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561107d57600080fd5b505af1158015611091573d6000803e3d6000fd5b505050506040513d60208110156110a757600080fd5b5051604080517f3f6d825600000000000000000000000000000000000000000000000000000000815290518891600160a060020a03831691633f6d8256916004808201926020929091908290030181600087803b15801561110757600080fd5b505af115801561111b573d6000803e3d6000fd5b505050506040513d602081101561113157600080fd5b50516040805160e060020a63ffffffff8716028152600160a060020a0394851660048201529290931660248301526044820152905160648083019260209291908290030181600087803b15801561118757600080fd5b505af115801561119b573d6000803e3d6000fd5b505050506040513d60208110156111b157600080fd5b505115156111be57600080fd5b5a600380546201afbd9290950394850182019055600160a060020a0385166000908152600460205260409020805490940101909255509095945050505050565b60008060008060009054906101000a9004600160a060020a0316600160a060020a031663a6b513ee6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561125557600080fd5b505af1158015611269573d6000803e3d6000fd5b505050506040513d602081101561127f57600080fd5b5051151561128f57839250611359565b600354650327ec1e0c00900491506000809054906101000a9004600160a060020a0316600160a060020a031663a6b513ee6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156112ef57600080fd5b505af1158015611303573d6000803e3d6000fd5b505050506040513d602081101561131957600080fd5b5051600383900a600284900a8602678ac7230489e800000281151561133a57fe5b0481151561134457fe5b0490508381106113545780611356565b835b92505b5050919050565b600854600160a060020a031681565b6402540be40081565b60008181526005602052604090205460ff161561139457600080fd5b6000908152600560205260409020805460ff19166001179055565b604051610402806113d083390190565b60405161058e806117d2833901905600608060405260006007556000600855600060095534801561001f57600080fd5b50604051606080610402833981016040818152825160208085015194830151600a8054600160a060020a03808616600160a060020a03199283161790925560038890556004838155600580549092163317918290557f330f95880000000000000000000000000000000000000000000000000000000088529551949796929591169363330f958893828401939092908290030181600087803b1580156100c457600080fd5b505af11580156100d8573d6000803e3d6000fd5b505050506040513d60208110156100ee57600080fd5b505160068054600160a060020a03909216600160a060020a03199092169190911790555050506102df806101236000396000f3006080604052600436106100a35763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166327e235e381146100f35780632ebe14b014610126578063330f95881461013b5780633acddfc11461016c5780635daf08ca146101815780636c55e3851461019957806380c6ff73146101ae578063c45a0155146101c3578063cebe09c9146101d8578063ef23b3a3146101ed575b3480156100af57600080fd5b50600a54604051600160a060020a0390911690600090369080838380828437820191505092505050600060405180830381855af491505015156100f157600080fd5b005b3480156100ff57600080fd5b50610114600160a060020a036004351661020e565b60408051918252519081900360200190f35b34801561013257600080fd5b50610114610220565b34801561014757600080fd5b50610150610226565b60408051600160a060020a039092168252519081900360200190f35b34801561017857600080fd5b50610114610235565b34801561018d57600080fd5b5061015060043561023b565b3480156101a557600080fd5b50610114610263565b3480156101ba57600080fd5b50610114610269565b3480156101cf57600080fd5b5061015061026f565b3480156101e457600080fd5b5061011461027e565b3480156101f957600080fd5b50610114600160a060020a0360043516610284565b60026020526000908152604090205481565b60045481565b600654600160a060020a031681565b60085481565b600080548290811061024957fe5b600091825260209091200154600160a060020a0316905081565b60035481565b60075481565b600554600160a060020a031681565b60095481565b600354600160a060020a0382166000908152600260205260408120549091908115156102ac57fe5b04929150505600a165627a7a72305820754ff1af4ffa0e643e2d4e073022e31b8fa19908a0daaaf700c7961335ef61070029608060405234801561001057600080fd5b5060405160208061058e8339810160405251600d8054600160a060020a03909216600160a060020a0319928316179055600c8054909116331790556105348061005a6000396000f3006080604052600436106100da5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663051064c6811461012a5780630ad9d052146101515780630b0a4b17146101db57806313faede6146101f057806314f1586a146102055780633a5381b51461021a5780633f6d82561461024b578063474ce872146102605780636537214714610275578063654f4b611461028a5780638d4e40831461029f578063a79a3cee146102c8578063c2d8de54146102dd578063c45a0155146102f2578063fc0c546a14610307575b3480156100e657600080fd5b50600d54604051600160a060020a0390911690600090369080838380828437820191505092505050600060405180830381855af4915050151561012857600080fd5b005b34801561013657600080fd5b5061013f61031c565b60408051918252519081900360200190f35b34801561015d57600080fd5b50610166610322565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101a0578181015183820152602001610188565b50505050905090810190601f1680156101cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101e757600080fd5b5061013f6103b0565b3480156101fc57600080fd5b5061013f6103b6565b34801561021157600080fd5b506101666103bc565b34801561022657600080fd5b5061022f610416565b60408051600160a060020a039092168252519081900360200190f35b34801561025757600080fd5b5061013f610425565b34801561026c57600080fd5b5061022f61042b565b34801561028157600080fd5b5061016661043a565b34801561029657600080fd5b5061013f610492565b3480156102ab57600080fd5b506102b4610498565b604080519115158252519081900360200190f35b3480156102d457600080fd5b506102b46104ba565b3480156102e957600080fd5b5061022f6104db565b3480156102fe57600080fd5b5061022f6104ea565b34801561031357600080fd5b5061022f6104f9565b60055481565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b505050505081565b60075481565b60045481565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b600b54600160a060020a031681565b60065481565b600a54600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156103a85780601f1061037d576101008083540402835291602001916103a8565b60085481565b600b547501000000000000000000000000000000000000000000900460ff1681565b600b5474010000000000000000000000000000000000000000900460ff1681565b600954600160a060020a031681565b600c54600160a060020a031681565b600354600160a060020a0316815600a165627a7a72305820e5bc1608a9682cfdd19acc0b2f78967a6055ad217343a1862fe2035d4218560d0029a165627a7a723058204c48eb6c55881c03befcef40c8158580ec8366f9bcf28d39860445c2c9e47f9600290000000000000000000000003da3987500da899a06796950f248c124c0f5cb6b000000000000000000000000c99bbf4c6feb29d8a4ed4f360e09f56a21fd611b000000000000000000000000562b1cd868bc33966540f7e0c0cbfd2bf07ef9b8000000000000000000000000bd949595ee52346c225a19724084ce517b2cb735000000000000000000000000314159265dd8dbb310642f98f50c066173c1259b

    Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003da3987500da899a06796950f248c124c0f5cb6b000000000000000000000000c99bbf4c6feb29d8a4ed4f360e09f56a21fd611b000000000000000000000000562b1cd868bc33966540f7e0c0cbfd2bf07ef9b8000000000000000000000000bd949595ee52346c225a19724084ce517b2cb735000000000000000000000000314159265dd8dbb310642f98f50c066173c1259b

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000003da3987500da899a06796950f248c124c0f5cb6b
Arg [1] : 000000000000000000000000c99bbf4c6feb29d8a4ed4f360e09f56a21fd611b
Arg [2] : 000000000000000000000000562b1cd868bc33966540f7e0c0cbfd2bf07ef9b8
Arg [3] : 000000000000000000000000bd949595ee52346c225a19724084ce517b2cb735
Arg [4] : 000000000000000000000000314159265dd8dbb310642f98f50c066173c1259b


   Swarm Source:
bzzr://4c48eb6c55881c03befcef40c8158580ec8366f9bcf28d39860445c2c9e47f96

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.