ETH Price: $3,244.28 (-1.15%)

Token

Etherbots (ETHBOT)
 

Overview

Max Total Supply

18,407 ETHBOT

Holders

5

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 0 Decimals)

Filtered by Token Holder
odp.eth
Balance
30 ETHBOT

Value
$0.00
0xE293390d7651234c6DFB1f41a47358B9377C004F
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
EtherbotsCore

Compiler Version
v0.4.20+commit.3155dd80

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-03-04
*/

pragma solidity ^0.4.18;



/**
 * @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 OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() 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 transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }

}



 // Pause functionality taken from OpenZeppelin. License below.
 /* The MIT License (MIT)
 Copyright (c) 2016 Smart Contract Solutions, Inc.
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions: */

 /**
  * @title Pausable
  * @dev Base contract which allows children to implement an emergency stop mechanism.
  */
contract Pausable is Ownable {

  event SetPaused(bool paused);

  // starts unpaused
  bool public paused = false;

  /* @dev modifier to allow actions only when the contract IS paused */
  modifier whenNotPaused() {
    require(!paused);
    _;
  }

  /* @dev modifier to allow actions only when the contract IS NOT paused */
  modifier whenPaused() {
    require(paused);
    _;
  }

  function pause() public onlyOwner whenNotPaused returns (bool) {
    paused = true;
    SetPaused(paused);
    return true;
  }

  function unpause() public onlyOwner whenPaused returns (bool) {
    paused = false;
    SetPaused(paused);
    return true;
  }
}

contract EtherbotsPrivileges is Pausable {
  event ContractUpgrade(address newContract);

}



// This contract implements both the original ERC-721 standard and
// the proposed 'deed' standard of 841
// I don't know which standard will eventually be adopted - support both for now


/// @title Interface for contracts conforming to ERC-721: Deed Standard
/// @author William Entriken (https://phor.net), et. al.
/// @dev Specification at https://github.com/ethereum/eips/841
/// can read the comments there
contract ERC721 {

    // COMPLIANCE WITH ERC-165 (DRAFT)

    /// @dev ERC-165 (draft) interface signature for itself
    bytes4 internal constant INTERFACE_SIGNATURE_ERC165 =
        bytes4(keccak256("supportsInterface(bytes4)"));

    /// @dev ERC-165 (draft) interface signature for ERC721
    bytes4 internal constant INTERFACE_SIGNATURE_ERC721 =
         bytes4(keccak256("ownerOf(uint256)")) ^
         bytes4(keccak256("countOfDeeds()")) ^
         bytes4(keccak256("countOfDeedsByOwner(address)")) ^
         bytes4(keccak256("deedOfOwnerByIndex(address,uint256)")) ^
         bytes4(keccak256("approve(address,uint256)")) ^
         bytes4(keccak256("takeOwnership(uint256)"));

    function supportsInterface(bytes4 _interfaceID) external pure returns (bool);

    // PUBLIC QUERY FUNCTIONS //////////////////////////////////////////////////

    function ownerOf(uint256 _deedId) public view returns (address _owner);
    function countOfDeeds() external view returns (uint256 _count);
    function countOfDeedsByOwner(address _owner) external view returns (uint256 _count);
    function deedOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _deedId);

    // TRANSFER MECHANISM //////////////////////////////////////////////////////

    event Transfer(address indexed from, address indexed to, uint256 indexed deedId);
    event Approval(address indexed owner, address indexed approved, uint256 indexed deedId);

    function approve(address _to, uint256 _deedId) external payable;
    function takeOwnership(uint256 _deedId) external payable;
}

/// @title Metadata extension to ERC-721 interface
/// @author William Entriken (https://phor.net)
/// @dev Specification at https://github.com/ethereum/eips/issues/XXXX
contract ERC721Metadata is ERC721 {

    bytes4 internal constant INTERFACE_SIGNATURE_ERC721Metadata =
        bytes4(keccak256("name()")) ^
        bytes4(keccak256("symbol()")) ^
        bytes4(keccak256("deedUri(uint256)"));

    function name() public pure returns (string n);
    function symbol() public pure returns (string s);

    /// @notice A distinct URI (RFC 3986) for a given token.
    /// @dev If:
    ///  * The URI is a URL
    ///  * The URL is accessible
    ///  * The URL points to a valid JSON file format (ECMA-404 2nd ed.)
    ///  * The JSON base element is an object
    ///  then these names of the base element SHALL have special meaning:
    ///  * "name": A string identifying the item to which `_deedId` grants
    ///    ownership
    ///  * "description": A string detailing the item to which `_deedId` grants
    ///    ownership
    ///  * "image": A URI pointing to a file of image/* mime type representing
    ///    the item to which `_deedId` grants ownership
    ///  Wallets and exchanges MAY display this to the end user.
    ///  Consider making any images at a width between 320 and 1080 pixels and
    ///  aspect ratio between 1.91:1 and 4:5 inclusive.
    function deedUri(uint256 _deedId) external view returns (string _uri);
}

/// @title Enumeration extension to ERC-721 interface
/// @author William Entriken (https://phor.net)
/// @dev Specification at https://github.com/ethereum/eips/issues/XXXX
contract ERC721Enumerable is ERC721Metadata {

    /// @dev ERC-165 (draft) interface signature for ERC721
    bytes4 internal constant INTERFACE_SIGNATURE_ERC721Enumerable =
        bytes4(keccak256("deedByIndex()")) ^
        bytes4(keccak256("countOfOwners()")) ^
        bytes4(keccak256("ownerByIndex(uint256)"));

    function deedByIndex(uint256 _index) external view returns (uint256 _deedId);
    function countOfOwners() external view returns (uint256 _count);
    function ownerByIndex(uint256 _index) external view returns (address _owner);
}

contract ERC721Original {

    bytes4 constant INTERFACE_SIGNATURE_ERC721Original =
        bytes4(keccak256("totalSupply()")) ^
        bytes4(keccak256("balanceOf(address)")) ^
        bytes4(keccak256("ownerOf(uint256)")) ^
        bytes4(keccak256("approve(address,uint256)")) ^
        bytes4(keccak256("takeOwnership(uint256)")) ^
        bytes4(keccak256("transfer(address,uint256)"));

    // Core functions
    function implementsERC721() public pure returns (bool);
    function totalSupply() public view returns (uint256 _totalSupply);
    function balanceOf(address _owner) public view returns (uint256 _balance);
    function ownerOf(uint _tokenId) public view returns (address _owner);
    function approve(address _to, uint _tokenId) external payable;
    function transferFrom(address _from, address _to, uint _tokenId) public;
    function transfer(address _to, uint _tokenId) public payable;

    // Optional functions
    function name() public pure returns (string _name);
    function symbol() public pure returns (string _symbol);
    function tokenOfOwnerByIndex(address _owner, uint _index) external view returns (uint _tokenId);
    function tokenMetadata(uint _tokenId) public view returns (string _infoUrl);

    // Events
    // event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
    // event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
}

contract ERC721AllImplementations is ERC721Original, ERC721Enumerable {

}

contract EtherbotsBase is EtherbotsPrivileges {


    function EtherbotsBase() public {
    //   scrapyard = address(this);
    }
    /*** EVENTS ***/

    ///  Forge fires when a new part is created - 4 times when a crate is opened,
    /// and once when a battle takes place. Also has fires when
    /// parts are combined in the furnace.
    event Forge(address owner, uint256 partID, Part part);

    ///  Transfer event as defined in ERC721.
    event Transfer(address from, address to, uint256 tokenId);

    /*** DATA TYPES ***/
    ///  The main struct representation of a robot part. Each robot in Etherbots is represented by four copies
    ///  of this structure, one for each of the four parts comprising it:
    /// 1. Right Arm (Melee),
    /// 2. Left Arm (Defence),
    /// 3. Head (Turret),
    /// 4. Body.
    // store token id on this?
     struct Part {
        uint32 tokenId;
        uint8 partType;
        uint8 partSubType;
        uint8 rarity;
        uint8 element;
        uint32 battlesLastDay;
        uint32 experience;
        uint32 forgeTime;
        uint32 battlesLastReset;
    }

    // Part type - can be shared with other part factories.
    uint8 constant DEFENCE = 1;
    uint8 constant MELEE = 2;
    uint8 constant BODY = 3;
    uint8 constant TURRET = 4;

    // Rarity - can be shared with other part factories.
    uint8 constant STANDARD = 1;
    uint8 constant SHADOW = 2;
    uint8 constant GOLD = 3;


    // Store a user struct
    // in order to keep track of experience and perk choices.
    // This perk tree is a binary tree, efficiently encodable as an array.
    // 0 reflects no perk selected. 1 is first choice. 2 is second. 3 is both.
    // Each choice costs experience (deducted from user struct).

    /*** ~~~~~ROBOT PERKS~~~~~ ***/
    // PERK 1: ATTACK vs DEFENCE PERK CHOICE.
    // Choose
    // PERK TWO ATTACK/ SHOOT, or DEFEND/DODGE
    // PERK 2: MECH vs ELEMENTAL PERK CHOICE ---
    // Choose steel and electric (Mech path), or water and fire (Elemetal path)
    // (... will the mechs win the war for Ethertopia? or will the androids
    // be deluged in flood and fire? ...)
    // PERK 3: Commit to a specific elemental pathway:
    // 1. the path of steel: the iron sword; the burning frying pan!
    // 2. the path of electricity: the deadly taser, the fearsome forcefield
    // 3. the path of water: high pressure water blasters have never been so cool
    // 4. the path of fire!: we will hunt you down, Aang...


    struct User {
        // address userAddress;
        uint32 numShards; //limit shards to upper bound eg 10000
        uint32 experience;
        uint8[32] perks;
    }

    //Maintain an array of all users.
    // User[] public users;

    // Store a map of the address to a uint representing index of User within users
    // we check if a user exists at multiple points, every time they acquire
    // via a crate or the market. Users can also manually register their address.
    mapping ( address => User ) public addressToUser;

    // Array containing the structs of all parts in existence. The ID
    // of each part is an index into this array.
    Part[] parts;

    // Mapping from part IDs to to owning address. Should always exist.
    mapping (uint256 => address) public partIndexToOwner;

    //  A mapping from owner address to count of tokens that address owns.
    //  Used internally inside balanceOf() to resolve ownership count. REMOVE?
    mapping (address => uint256) addressToTokensOwned;

    // Mapping from Part ID to an address approved to call transferFrom().
    // maximum of one approved address for transfer at any time.
    mapping (uint256 => address) public partIndexToApproved;

    address auction;
    // address scrapyard;

    // Array to store approved battle contracts.
    // Can only ever be added to, not removed from.
    // Once a ruleset is published, you will ALWAYS be able to use that contract
    address[] approvedBattles;


    function getUserByAddress(address _user) public view returns (uint32, uint8[32]) {
        return (addressToUser[_user].experience, addressToUser[_user].perks);
    }

    //  Transfer a part to an address
    function _transfer(address _from, address _to, uint256 _tokenId) internal {
        // No cap on number of parts
        // Very unlikely to ever be 2^256 parts owned by one account
        // Shouldn't waste gas checking for overflow
        // no point making it less than a uint --> mappings don't pack
        addressToTokensOwned[_to]++;
        // transfer ownership
        partIndexToOwner[_tokenId] = _to;
        // New parts are transferred _from 0x0, but we can't account that address.
        if (_from != address(0)) {
            addressToTokensOwned[_from]--;
            // clear any previously approved ownership exchange
            delete partIndexToApproved[_tokenId];
        }
        // Emit the transfer event.
        Transfer(_from, _to, _tokenId);
    }

    function getPartById(uint _id) external view returns (
        uint32 tokenId,
        uint8 partType,
        uint8 partSubType,
        uint8 rarity,
        uint8 element,
        uint32 battlesLastDay,
        uint32 experience,
        uint32 forgeTime,
        uint32 battlesLastReset
    ) {
        Part memory p = parts[_id];
        return (p.tokenId, p.partType, p.partSubType, p.rarity, p.element, p.battlesLastDay, p.experience, p.forgeTime, p.battlesLastReset);
    }


    function substring(string str, uint startIndex, uint endIndex) internal pure returns (string) {
        bytes memory strBytes = bytes(str);
        bytes memory result = new bytes(endIndex-startIndex);
        for (uint i = startIndex; i < endIndex; i++) {
            result[i-startIndex] = strBytes[i];
        }
        return string(result);
    }

    // helper functions adapted from  Jossie Calderon on stackexchange
    function stringToUint32(string s) internal pure returns (uint32) {
        bytes memory b = bytes(s);
        uint result = 0;
        for (uint i = 0; i < b.length; i++) { // c = b[i] was not needed
            if (b[i] >= 48 && b[i] <= 57) {
                result = result * 10 + (uint(b[i]) - 48); // bytes and int are not compatible with the operator -.
            }
        }
        return uint32(result);
    }

    function stringToUint8(string s) internal pure returns (uint8) {
        return uint8(stringToUint32(s));
    }

    function uintToString(uint v) internal pure returns (string) {
        uint maxlength = 100;
        bytes memory reversed = new bytes(maxlength);
        uint i = 0;
        while (v != 0) {
            uint remainder = v % 10;
            v = v / 10;
            reversed[i++] = byte(48 + remainder);
        }
        bytes memory s = new bytes(i); // i + 1 is inefficient
        for (uint j = 0; j < i; j++) {
            s[j] = reversed[i - j - 1]; // to avoid the off-by-one error
        }
        string memory str = string(s);
        return str;
    }
}
contract EtherbotsNFT is EtherbotsBase, ERC721Enumerable, ERC721Original {
    function supportsInterface(bytes4 _interfaceID) external pure returns (bool) {
        return (_interfaceID == ERC721Original.INTERFACE_SIGNATURE_ERC721Original) ||
            (_interfaceID == ERC721.INTERFACE_SIGNATURE_ERC721) ||
            (_interfaceID == ERC721Metadata.INTERFACE_SIGNATURE_ERC721Metadata) ||
            (_interfaceID == ERC721Enumerable.INTERFACE_SIGNATURE_ERC721Enumerable);
    }
    function implementsERC721() public pure returns (bool) {
        return true;
    }

    function name() public pure returns (string _name) {
      return "Etherbots";
    }

    function symbol() public pure returns (string _smbol) {
      return "ETHBOT";
    }

    // total supply of parts --> as no parts are ever deleted, this is simply
    // the total supply of parts ever created
    function totalSupply() public view returns (uint) {
        return parts.length;
    }

    /// @notice Returns the total number of deeds currently in existence.
    /// @dev Required for ERC-721 compliance.
    function countOfDeeds() external view returns (uint256) {
        return parts.length;
    }

    //--/ internal function    which checks whether the token with id (_tokenId)
    /// is owned by the (_claimant) address
    function owns(address _owner, uint256 _tokenId) public view returns (bool) {
        return (partIndexToOwner[_tokenId] == _owner);
    }

    /// internal function    which checks whether the token with id (_tokenId)
    /// is owned by the (_claimant) address
    function ownsAll(address _owner, uint256[] _tokenIds) public view returns (bool) {
        require(_tokenIds.length > 0);
        for (uint i = 0; i < _tokenIds.length; i++) {
            if (partIndexToOwner[_tokenIds[i]] != _owner) {
                return false;
            }
        }
        return true;
    }

    function _approve(uint256 _tokenId, address _approved) internal {
        partIndexToApproved[_tokenId] = _approved;
    }

    function _approvedFor(address _newOwner, uint256 _tokenId) internal view returns (bool) {
        return (partIndexToApproved[_tokenId] == _newOwner);
    }

    function ownerByIndex(uint256 _index) external view returns (address _owner){
        return partIndexToOwner[_index];
    }

    // returns the NUMBER of tokens owned by (_owner)
    function balanceOf(address _owner) public view returns (uint256 count) {
        return addressToTokensOwned[_owner];
    }

    function countOfDeedsByOwner(address _owner) external view returns (uint256) {
        return balanceOf(_owner);
    }

    // transfers a part to another account
    function transfer(address _to, uint256 _tokenId) public whenNotPaused payable {
        // payable for ERC721 --> don't actually send eth @_@
        require(msg.value == 0);

        // Safety checks to prevent accidental transfers to common accounts
        require(_to != address(0));
        require(_to != address(this));
        // can't transfer parts to the auction contract directly
        require(_to != address(auction));
        // can't transfer parts to any of the battle contracts directly
        for (uint j = 0; j < approvedBattles.length; j++) {
            require(_to != approvedBattles[j]);
        }

        // Cannot send tokens you don't own
        require(owns(msg.sender, _tokenId));

        // perform state changes necessary for transfer
        _transfer(msg.sender, _to, _tokenId);
    }
    // transfers a part to another account

    function transferAll(address _to, uint256[] _tokenIds) public whenNotPaused payable {
        require(msg.value == 0);

        // Safety checks to prevent accidental transfers to common accounts
        require(_to != address(0));
        require(_to != address(this));
        // can't transfer parts to the auction contract directly
        require(_to != address(auction));
        // can't transfer parts to any of the battle contracts directly
        for (uint j = 0; j < approvedBattles.length; j++) {
            require(_to != approvedBattles[j]);
        }

        // Cannot send tokens you don't own
        require(ownsAll(msg.sender, _tokenIds));

        for (uint k = 0; k < _tokenIds.length; k++) {
            // perform state changes necessary for transfer
            _transfer(msg.sender, _to, _tokenIds[k]);
        }


    }


    // approves the (_to) address to use the transferFrom function on the token with id (_tokenId)
    // if you want to clear all approvals, simply pass the zero address
    function approve(address _to, uint256 _deedId) external whenNotPaused payable {
        // payable for ERC721 --> don't actually send eth @_@
        require(msg.value == 0);
// use internal function?
        // Cannot approve the transfer of tokens you don't own
        require(owns(msg.sender, _deedId));

        // Store the approval (can only approve one at a time)
        partIndexToApproved[_deedId] = _to;

        Approval(msg.sender, _to, _deedId);
    }

    // approves many token ids
    function approveMany(address _to, uint256[] _tokenIds) external whenNotPaused payable {

        for (uint i = 0; i < _tokenIds.length; i++) {
            uint _tokenId = _tokenIds[i];

            // Cannot approve the transfer of tokens you don't own
            require(owns(msg.sender, _tokenId));

            // Store the approval (can only approve one at a time)
            partIndexToApproved[_tokenId] = _to;
            //create event for each approval? _tokenId guaranteed to hold correct value?
            Approval(msg.sender, _to, _tokenId);
        }
    }

    // transfer the part with id (_tokenId) from (_from) to (_to)
    // (_to) must already be approved for this (_tokenId)
    function transferFrom(address _from, address _to, uint256 _tokenId) public whenNotPaused {

        // Safety checks to prevent accidents
        require(_to != address(0));
        require(_to != address(this));

        // sender must be approved
        require(partIndexToApproved[_tokenId] == msg.sender);
        // from must currently own the token
        require(owns(_from, _tokenId));

        // Reassign ownership (also clears pending approvals and emits Transfer event).
        _transfer(_from, _to, _tokenId);
    }

    // returns the current owner of the token with id = _tokenId
    function ownerOf(uint256 _deedId) public view returns (address _owner) {
        _owner = partIndexToOwner[_deedId];
        // must result false if index key not found
        require(_owner != address(0));
    }

    // returns a dynamic array of the ids of all tokens which are owned by (_owner)
    // Looping through every possible part and checking it against the owner is
    // actually much more efficient than storing a mapping or something, because
    // it won't be executed as a transaction
    function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
        uint256 totalParts = totalSupply();

        return tokensOfOwnerWithinRange(_owner, 0, totalParts);
  
    }

    function tokensOfOwnerWithinRange(address _owner, uint _start, uint _numToSearch) public view returns(uint256[] ownerTokens) {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tmpResult = new uint256[](tokenCount);
        if (tokenCount == 0) {
            return tmpResult;
        }

        uint256 resultIndex = 0;
        for (uint partId = _start; partId < _start + _numToSearch; partId++) {
            if (partIndexToOwner[partId] == _owner) {
                tmpResult[resultIndex] = partId;
                resultIndex++;
                if (resultIndex == tokenCount) { //found all tokens accounted for, no need to continue
                    break;
                }
            }
        }

        // copy number of tokens found in given range
        uint resultLength = resultIndex;
        uint256[] memory result = new uint256[](resultLength);
        for (uint i=0; i<resultLength; i++) {
            result[i] = tmpResult[i];
        }
        return result;
    }



    //same issues as above
    // Returns an array of all part structs owned by the user. Free to call.
    function getPartsOfOwner(address _owner) external view returns(bytes24[]) {
        uint256 totalParts = totalSupply();

        return getPartsOfOwnerWithinRange(_owner, 0, totalParts);
    }
    
    // This is public so it can be called by getPartsOfOwner. It should NOT be called by another contract
    // as it is very gas hungry.
    function getPartsOfOwnerWithinRange(address _owner, uint _start, uint _numToSearch) public view returns(bytes24[]) {
        uint256 tokenCount = balanceOf(_owner);

        uint resultIndex = 0;
        bytes24[] memory result = new bytes24[](tokenCount);
        for (uint partId = _start; partId < _start + _numToSearch; partId++) {
            if (partIndexToOwner[partId] == _owner) {
                result[resultIndex] = _partToBytes(parts[partId]);
                resultIndex++;
            }
        }
        return result; // will have 0 elements if tokenCount == 0
    }


    function _partToBytes(Part p) internal pure returns (bytes24 b) {
        b = bytes24(p.tokenId);

        b = b << 8;
        b = b | bytes24(p.partType);

        b = b << 8;
        b = b | bytes24(p.partSubType);

        b = b << 8;
        b = b | bytes24(p.rarity);

        b = b << 8;
        b = b | bytes24(p.element);

        b = b << 32;
        b = b | bytes24(p.battlesLastDay);

        b = b << 32;
        b = b | bytes24(p.experience);

        b = b << 32;
        b = b | bytes24(p.forgeTime);

        b = b << 32;
        b = b | bytes24(p.battlesLastReset);
    }

    uint32 constant FIRST_LEVEL = 1000;
    uint32 constant INCREMENT = 1000;

    // every level, you need 1000 more exp to go up a level
    function getLevel(uint32 _exp) public pure returns(uint32) {
        uint32 c = 0;
        for (uint32 i = FIRST_LEVEL; i <= FIRST_LEVEL + _exp; i += c * INCREMENT) {
            c++;
        }
        return c;
    }

    string metadataBase = "https://api.etherbots.io/api/";


    function setMetadataBase(string _base) external onlyOwner {
        metadataBase = _base;
    }

    // part type, subtype,
    // have one internal function which lets us implement the divergent interfaces
    function _metadata(uint256 _id) internal view returns(string) {
        Part memory p = parts[_id];
        return strConcat(strConcat(
            metadataBase,
            uintToString(uint(p.partType)),
            "/",
            uintToString(uint(p.partSubType)),
            "/"
        ), uintToString(uint(p.rarity)), "", "", "");
    }

    function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string){
        bytes memory _ba = bytes(_a);
        bytes memory _bb = bytes(_b);
        bytes memory _bc = bytes(_c);
        bytes memory _bd = bytes(_d);
        bytes memory _be = bytes(_e);
        string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
        bytes memory babcde = bytes(abcde);
        uint k = 0;
        for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
        for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
        for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
        for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
        for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
        return string(babcde);
    }

    /// @notice A distinct URI (RFC 3986) for a given token.
    /// @dev If:
    ///  * The URI is a URL
    ///  * The URL is accessible
    ///  * The URL points to a valid JSON file format (ECMA-404 2nd ed.)
    ///  * The JSON base element is an object
    ///  then these names of the base element SHALL have special meaning:
    ///  * "name": A string identifying the item to which `_deedId` grants
    ///    ownership
    ///  * "description": A string detailing the item to which `_deedId` grants
    ///    ownership
    ///  * "image": A URI pointing to a file of image/* mime type representing
    ///    the item to which `_deedId` grants ownership
    ///  Wallets and exchanges MAY display this to the end user.
    ///  Consider making any images at a width between 320 and 1080 pixels and
    ///  aspect ratio between 1.91:1 and 4:5 inclusive.
    function deedUri(uint256 _deedId) external view returns (string _uri){
        return _metadata(_deedId);
    }

    /// returns a metadata URI
    function tokenMetadata(uint256 _tokenId) public view returns (string infoUrl) {
        return _metadata(_tokenId);
    }

    function takeOwnership(uint256 _deedId) external payable {
        // payable for ERC721 --> don't actually send eth @_@
        require(msg.value == 0);

        address _from = partIndexToOwner[_deedId];

        require(_approvedFor(msg.sender, _deedId));

        _transfer(_from, msg.sender, _deedId);
    }

    // parts are stored sequentially
    function deedByIndex(uint256 _index) external view returns (uint256 _deedId){
        return _index;
    }

    function countOfOwners() external view returns (uint256 _count){
        // TODO: implement this
        return 0;
    }

// thirsty function
    function tokenOfOwnerByIndex(address _owner, uint _index) external view returns (uint _tokenId){
        return _tokenOfOwnerByIndex(_owner, _index);
    }

// code duplicated
    function _tokenOfOwnerByIndex(address _owner, uint _index) private view returns (uint _tokenId){
        // The index should be valid.
        require(_index < balanceOf(_owner));

        // can loop through all without
        uint256 seen = 0;
        uint256 totalTokens = totalSupply();

        for (uint i = 0; i < totalTokens; i++) {
            if (partIndexToOwner[i] == _owner) {
                if (seen == _index) {
                    return i;
                }
                seen++;
            }
        }
    }

    function deedOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _deedId){
        return _tokenOfOwnerByIndex(_owner, _index);
    }
}

// the contract which all battles must implement
// allows for different types of battles to take place
contract PerkTree is EtherbotsNFT {
    // The perktree is represented in a uint8[32] representing a binary tree
    // see the number of perks active
    // buy a new perk
    // 0: Prestige level -> starts at 0;
    // next row of tree
    // 1: offensive moves 2: defensive moves
    // next row of tree
    // 3: melee attack 4: turret shooting 5: defend arm 6: body dodge
    // next row of tree
    // 7: mech melee 8: android melee 9: mech turret 10: android turret
    // 11: mech defence 12: android defence 13: mech body 14: android body
    //next row of tree
    // 15: melee electric 16: melee steel 17: melee fire 18: melee water
    // 19: turret electric 20: turret steel 21: turret fire 22: turret water
    // 23: defend electric 24: defend steel 25: defend fire 26: defend water
    // 27: body electric 28: body steel 29: body fire 30: body water
    function _leftChild(uint8 _i) internal pure returns (uint8) {
        return 2*_i + 1;
    }
    function _rightChild(uint8 _i) internal pure returns (uint8) {
        return 2*_i + 2;
    }
    function _parent(uint8 _i) internal pure returns (uint8) {
        return (_i-1)/2;
    }


    uint8 constant PRESTIGE_INDEX = 0;
    uint8 constant PERK_COUNT = 30;

    event PrintPerk(string,uint8,uint8[32]);

    function _isValidPerkToAdd(uint8[32] _perks, uint8 _index) internal pure returns (bool) {
        // a previously unlocked perk is not a valid perk to add.
        if ((_index==PRESTIGE_INDEX) || (_perks[_index] > 0)) {
            return false;
        }
        // perk not valid if any ancestor not unlocked
        for (uint8 i = _parent(_index); i > PRESTIGE_INDEX; i = _parent(i)) {
            if (_perks[i] == 0) {
                return false;
            }
        }
        return true;
    }

    // sum of perks (excluding prestige)
    function _sumActivePerks(uint8[32] _perks) internal pure returns (uint256) {
        uint32 sum = 0;
        //sum from after prestige_index, to count+1 (for prestige index).
        for (uint8 i = PRESTIGE_INDEX+1; i < PERK_COUNT+1; i++) {
            sum += _perks[i];
        }
        return sum;
    }

    // you can unlock a new perk every two levels (including prestige when possible)
    function choosePerk(uint8 _i) external {
        require((_i >= PRESTIGE_INDEX) && (_i < PERK_COUNT+1));
        User storage currentUser = addressToUser[msg.sender];
        uint256 _numActivePerks = _sumActivePerks(currentUser.perks);
        bool canPrestige = (_numActivePerks == PERK_COUNT);

        //add prestige value to sum of perks
        _numActivePerks += currentUser.perks[PRESTIGE_INDEX] * PERK_COUNT;
        require(_numActivePerks < getLevel(currentUser.experience) / 2);

        if (_i == PRESTIGE_INDEX) {
            require(canPrestige);
            _prestige();
        } else {
            require(_isValidPerkToAdd(currentUser.perks, _i));
            _addPerk(_i);
        }
        PerkChosen(msg.sender, _i);
    }

    function _addPerk(uint8 perk) internal {
        addressToUser[msg.sender].perks[perk]++;
    }

    function _prestige() internal {
        User storage currentUser = addressToUser[msg.sender];
        for (uint8 i = 1; i < currentUser.perks.length; i++) {
            currentUser.perks[i] = 0;
        }
        currentUser.perks[PRESTIGE_INDEX]++;
    }

    event PerkChosen(address indexed upgradedUser, uint8 indexed perk);

}

// Central collection of storage on which all other contracts depend.
// Contains structs for parts, users and functions which control their
// transferrence.


// Auction contract, facilitating statically priced sales, as well as 
// inflationary and deflationary pricing for items.
// Relies heavily on the ERC721 interface and so most of the methods
// are tightly bound to that implementation
contract NFTAuctionBase is Pausable {

    ERC721AllImplementations public nftContract;
    uint256 public ownerCut;
    uint public minDuration;
    uint public maxDuration;

    // Represents an auction on an NFT (in this case, Robot part)
    struct Auction {
        // address of part owner
        address seller;
        // wei price of listing
        uint256 startPrice;
        // wei price of floor
        uint256 endPrice;
        // duration of sale in seconds.
        uint64 duration;
        // Time when sale started
        // Reset to 0 after sale concluded
        uint64 start;
    }

    function NFTAuctionBase() public {
        minDuration = 60 minutes;
        maxDuration = 30 days; // arbitrary
    }

    // map of all tokens and their auctions
    mapping (uint256 => Auction) tokenIdToAuction;

    event AuctionCreated(uint256 tokenId, uint256 startPrice, uint256 endPrice, uint64 duration, uint64 start);
    event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner);
    event AuctionCancelled(uint256 tokenId);

    // returns true if the token with id _partId is owned by the _claimant address
    function _owns(address _claimant, uint256 _partId) internal view returns (bool) {
        return nftContract.ownerOf(_partId) == _claimant;
    }

   // returns false if auction start time is 0, likely from uninitialised struct
    function _isActiveAuction(Auction _auction) internal pure returns (bool) {
        return _auction.start > 0;
    }
    
    // assigns ownership of the token with id = _partId to this contract
    // must have already been approved
    function _escrow(address, uint _partId) internal {
        // throws on transfer fail
        nftContract.takeOwnership(_partId);
    }

    // transfer the token with id = _partId to buying address
    function _transfer(address _purchasor, uint256 _partId) internal {
        // successful purchaseder must takeOwnership of _partId
        // nftContract.approve(_purchasor, _partId); 
               // actual transfer
                nftContract.transfer(_purchasor, _partId);

    }

    // creates
    function _newAuction(uint256 _partId, Auction _auction) internal {

        require(_auction.duration >= minDuration);
        require(_auction.duration <= maxDuration);

        tokenIdToAuction[_partId] = _auction;

        AuctionCreated(uint256(_partId),
            uint256(_auction.startPrice),
            uint256(_auction.endPrice),
            uint64(_auction.duration),
            uint64(_auction.start)
        );
    }

    function setMinDuration(uint _duration) external onlyOwner {
        minDuration = _duration;
    }

    function setMaxDuration(uint _duration) external onlyOwner {
        maxDuration = _duration;
    }

    /// Removes auction from public view, returns token to the seller
    function _cancelAuction(uint256 _partId, address _seller) internal {
        _removeAuction(_partId);
        _transfer(_seller, _partId);
        AuctionCancelled(_partId);
    }

    event PrintEvent(string, address, uint);

    // Calculates price and transfers purchase to owner. Part is NOT transferred to buyer.
    function _purchase(uint256 _partId, uint256 _purchaseAmount) internal returns (uint256) {

        Auction storage auction = tokenIdToAuction[_partId];

        // check that this token is being auctioned
        require(_isActiveAuction(auction));

        // enforce purchase >= the current price
        uint256 price = _currentPrice(auction);
        require(_purchaseAmount >= price);

        // Store seller before we delete auction.
        address seller = auction.seller;

        // Valid purchase. Remove auction to prevent reentrancy.
        _removeAuction(_partId);

        // Transfer proceeds to seller (if there are any!)
        if (price > 0) {
            
            // Calculate and take fee from purchase

            uint256 auctioneerCut = _computeFee(price);
            uint256 sellerProceeds = price - auctioneerCut;

            PrintEvent("Seller, proceeds", seller, sellerProceeds);

            // Pay the seller
            seller.transfer(sellerProceeds);
        }

        // Calculate excess funds and return to buyer.
        uint256 purchaseExcess = _purchaseAmount - price;

        PrintEvent("Sender, excess", msg.sender, purchaseExcess);
        // Return any excess funds. Reentrancy again prevented by deleting auction.
        msg.sender.transfer(purchaseExcess);

        AuctionSuccessful(_partId, price, msg.sender);

        return price;
    }

    // returns the current price of the token being auctioned in _auction
    function _currentPrice(Auction storage _auction) internal view returns (uint256) {
        uint256 secsElapsed = now - _auction.start;
        return _computeCurrentPrice(
            _auction.startPrice,
            _auction.endPrice,
            _auction.duration,
            secsElapsed
        );
    }

    // Checks if NFTPart is currently being auctioned.
    // function _isBeingAuctioned(Auction storage _auction) internal view returns (bool) {
    //     return (_auction.start > 0);
    // }

    // removes the auction of the part with id _partId
    function _removeAuction(uint256 _partId) internal {
        delete tokenIdToAuction[_partId];
    }

    // computes the current price of an deflating-price auction 
    function _computeCurrentPrice( uint256 _startPrice, uint256 _endPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256 _price) {
        _price = _startPrice;
        if (_secondsPassed >= _duration) {
            // Has been up long enough to hit endPrice.
            // Return this price floor.
            _price = _endPrice;
            // this is a statically price sale. Just return the price.
        }
        else if (_duration > 0) {
            // This auction contract supports auctioning from any valid price to any other valid price.
            // This means the price can dynamically increase upward, or downard.
            int256 priceDifference = int256(_endPrice) - int256(_startPrice);
            int256 currentPriceDifference = priceDifference * int256(_secondsPassed) / int256(_duration);
            int256 currentPrice = int256(_startPrice) + currentPriceDifference;

            _price = uint256(currentPrice);
        }
        return _price;
    }

    // Compute percentage fee of transaction

    function _computeFee (uint256 _price) internal view returns (uint256) {
        return _price * ownerCut / 10000; 
    }

}

// Clock auction for NFTParts.
// Only timed when pricing is dynamic (i.e. startPrice != endPrice).
// Else, this becomes an infinite duration statically priced sale,
// resolving when succesfully purchase for or cancelled.

contract DutchAuction is NFTAuctionBase, EtherbotsPrivileges {

    // The ERC-165 interface signature for ERC-721.
    bytes4 constant InterfaceSignature_ERC721 = bytes4(0xda671b9b);
 
    function DutchAuction(address _nftAddress, uint256 _fee) public {
        require(_fee <= 10000);
        ownerCut = _fee;

        ERC721AllImplementations candidateContract = ERC721AllImplementations(_nftAddress);
        require(candidateContract.supportsInterface(InterfaceSignature_ERC721));
        nftContract = candidateContract;
    }

    // Remove all ether from the contract. This will be marketplace fees.
    // Transfers to the NFT contract. 
    // Can be called by owner or NFT contract.

    function withdrawBalance() external {
        address nftAddress = address(nftContract);

        require(msg.sender == owner || msg.sender == nftAddress);

        nftAddress.transfer(this.balance);
    }

    event PrintEvent(string, address, uint);

    // Creates an auction and lists it.
    function createAuction( uint256 _partId, uint256 _startPrice, uint256 _endPrice, uint256 _duration, address _seller ) external whenNotPaused {
        // Sanity check that no inputs overflow how many bits we've allocated
        // to store them in the auction struct.
        require(_startPrice == uint256(uint128(_startPrice)));
        require(_endPrice == uint256(uint128(_endPrice)));
        require(_duration == uint256(uint64(_duration)));
        require(_startPrice >= _endPrice);

        require(msg.sender == address(nftContract));
        _escrow(_seller, _partId);
        Auction memory auction = Auction(
            _seller,
            uint128(_startPrice),
            uint128(_endPrice),
            uint64(_duration),
            uint64(now) //seconds uint 
        );
        PrintEvent("Auction Start", 0x0, auction.start);
        _newAuction(_partId, auction);
    }


    // SCRAPYARD PRICING LOGIC

    uint8 constant LAST_CONSIDERED = 5;
    uint8 public scrapCounter = 0;
    uint[5] public lastScrapPrices;
    
    // Purchases an open auction
    // Will transfer ownership if successful.
    
    function purchase(uint256 _partId) external payable whenNotPaused {
        address seller = tokenIdToAuction[_partId].seller;

        // _purchase will throw if the purchase or funds transfer fails
        uint256 price = _purchase(_partId, msg.value);
        _transfer(msg.sender, _partId);
        
        // If the seller is the scrapyard, track price information.
        if (seller == address(nftContract)) {

            lastScrapPrices[scrapCounter] = price;
            if (scrapCounter == LAST_CONSIDERED - 1) {
                scrapCounter = 0;
            } else {
                scrapCounter++;
            }
        }
    }

    function averageScrapPrice() public view returns (uint) {
        uint sum = 0;
        for (uint8 i = 0; i < LAST_CONSIDERED; i++) {
            sum += lastScrapPrices[i];
        }
        return sum / LAST_CONSIDERED;
    }

    // Allows a user to cancel an auction before it's resolved.
    // Returns the part to the seller.

    function cancelAuction(uint256 _partId) external {
        Auction storage auction = tokenIdToAuction[_partId];
        require(_isActiveAuction(auction));
        address seller = auction.seller;
        require(msg.sender == seller);
        _cancelAuction(_partId, seller);
    }

    // returns the current price of the auction of a token with id _partId
    function getCurrentPrice(uint256 _partId) external view returns (uint256) {
        Auction storage auction = tokenIdToAuction[_partId];
        require(_isActiveAuction(auction));
        return _currentPrice(auction);
    }

    //  Returns the details of an auction from its _partId.
    function getAuction(uint256 _partId) external view returns ( address seller, uint256 startPrice, uint256 endPrice, uint256 duration, uint256 startedAt ) {
        Auction storage auction = tokenIdToAuction[_partId];
        require(_isActiveAuction(auction));
        return ( auction.seller, auction.startPrice, auction.endPrice, auction.duration, auction.start);
    }

    // Allows owner to cancel an auction.
    // ONLY able to be used when contract is paused,
    // in the case of emergencies.
    // Parts returned to seller as it's equivalent to them 
    // calling cancel.
    function cancelAuctionWhenPaused(uint256 _partId) whenPaused onlyOwner external {
        Auction storage auction = tokenIdToAuction[_partId];
        require(_isActiveAuction(auction));
        _cancelAuction(_partId, auction.seller);
    }
}

contract EtherbotsAuction is PerkTree {

    // Sets the reference to the sale auction.

    function setAuctionAddress(address _address) external onlyOwner {
        require(_address != address(0));
        DutchAuction candidateContract = DutchAuction(_address);

        // Set the new contract address
        auction = candidateContract;
    }

    // list a part for auction.

    function createAuction(
        uint256 _partId,
        uint256 _startPrice,
        uint256 _endPrice,
        uint256 _duration ) external whenNotPaused 
    {


        // user must have current control of the part
        // will lose control if they delegate to the auction
        // therefore no duplicate auctions!
        require(owns(msg.sender, _partId));

        _approve(_partId, auction);

        // will throw if inputs are invalid
        // will clear transfer approval
        DutchAuction(auction).createAuction(_partId,_startPrice,_endPrice,_duration,msg.sender);
    }

    // transfer balance back to core contract
    function withdrawAuctionBalance() external onlyOwner {
        DutchAuction(auction).withdrawBalance();
    }

    // SCRAP FUNCTION
  
    // This takes scrapped parts and automatically relists them on the market.
    // Provides a good floor for entrance into the game, while keeping supply
    // constant as these parts were already in circulation.

    // uint public constant SCRAPYARD_STARTING_PRICE = 0.1 ether;
    uint scrapMinStartPrice = 0.05 ether; // settable minimum starting price for sanity
    uint scrapMinEndPrice = 0.005 ether;  // settable minimum ending price for sanity
    uint scrapAuctionDuration = 2 days;
    
    function setScrapMinStartPrice(uint _newMinStartPrice) external onlyOwner {
        scrapMinStartPrice = _newMinStartPrice;
    }
    function setScrapMinEndPrice(uint _newMinEndPrice) external onlyOwner {
        scrapMinEndPrice = _newMinEndPrice;
    }
    function setScrapAuctionDuration(uint _newScrapAuctionDuration) external onlyOwner {
        scrapAuctionDuration = _newScrapAuctionDuration;
    }
 
    function _createScrapPartAuction(uint _scrapPartId) internal {
        // if (scrapyard == address(this)) {
        _approve(_scrapPartId, auction);
        
        DutchAuction(auction).createAuction(
            _scrapPartId,
            _getNextAuctionPrice(), // gen next auction price
            scrapMinEndPrice,
            scrapAuctionDuration,
            address(this)
        );
        // }
    }

    function _getNextAuctionPrice() internal view returns (uint) {
        uint avg = DutchAuction(auction).averageScrapPrice();
        // add 30% to the average
        // prevent runaway pricing
        uint next = avg + ((30 * avg) / 100);
        if (next < scrapMinStartPrice) {
            next = scrapMinStartPrice;
        }
        return next;
    }

}

contract PerksRewards is EtherbotsAuction {
    ///  An internal method that creates a new part and stores it. This
    ///  method doesn't do any checking and should only be called when the
    ///  input data is known to be valid. Will generate both a Forge event
    ///  and a Transfer event.
   function _createPart(uint8[4] _partArray, address _owner) internal returns (uint) {
        uint32 newPartId = uint32(parts.length);
        assert(newPartId == parts.length);

        Part memory _part = Part({
            tokenId: newPartId,
            partType: _partArray[0],
            partSubType: _partArray[1],
            rarity: _partArray[2],
            element: _partArray[3],
            battlesLastDay: 0,
            experience: 0,
            forgeTime: uint32(now),
            battlesLastReset: uint32(now)
        });
        assert(newPartId == parts.push(_part) - 1);

        // emit the FORGING!!!
        Forge(_owner, newPartId, _part);

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        _transfer(0, _owner, newPartId);

        return newPartId;
    }

    uint public PART_REWARD_CHANCE = 995;
    // Deprecated subtypes contain the subtype IDs of legacy items
    // which are no longer available to be redeemed in game.
    // i.e. subtype ID 14 represents lambo body, presale exclusive.
    // a value of 0 represents that subtype (id within range)
    // as being deprecated for that part type (body, turret, etc)
    uint8[] public defenceElementBySubtypeIndex;
    uint8[] public meleeElementBySubtypeIndex;
    uint8[] public bodyElementBySubtypeIndex;
    uint8[] public turretElementBySubtypeIndex;
    // uint8[] public defenceElementBySubtypeIndex = [1,2,4,3,4,1,3,3,2,1,4];
    // uint8[] public meleeElementBySubtypeIndex = [3,1,3,2,3,4,2,2,1,1,1,1,4,4];
    // uint8[] public bodyElementBySubtypeIndex = [2,1,2,3,4,3,1,1,4,2,3,4,1,0,1]; // no more lambos :'(
    // uint8[] public turretElementBySubtypeIndex = [4,3,2,1,2,1,1,3,4,3,4];

    function setRewardChance(uint _newChance) external onlyOwner {
        require(_newChance > 980); // not too hot
        require(_newChance <= 1000); // not too cold
        PART_REWARD_CHANCE = _newChance; // just right
        // come at me goldilocks
    }
    // The following functions DON'T create parts, they add new parts
    // as possible rewards from the reward pool.


    function addDefenceParts(uint8[] _newElement) external onlyOwner {
        for (uint8 i = 0; i < _newElement.length; i++) {
            defenceElementBySubtypeIndex.push(_newElement[i]);
        }
        // require(defenceElementBySubtypeIndex.length < uint(uint8(-1)));
    }
    function addMeleeParts(uint8[] _newElement) external onlyOwner {
        for (uint8 i = 0; i < _newElement.length; i++) {
            meleeElementBySubtypeIndex.push(_newElement[i]);
        }
        // require(meleeElementBySubtypeIndex.length < uint(uint8(-1)));
    }
    function addBodyParts(uint8[] _newElement) external onlyOwner {
        for (uint8 i = 0; i < _newElement.length; i++) {
            bodyElementBySubtypeIndex.push(_newElement[i]);
        }
        // require(bodyElementBySubtypeIndex.length < uint(uint8(-1)));
    }
    function addTurretParts(uint8[] _newElement) external onlyOwner {
        for (uint8 i = 0; i < _newElement.length; i++) {
            turretElementBySubtypeIndex.push(_newElement[i]);
        }
        // require(turretElementBySubtypeIndex.length < uint(uint8(-1)));
    }
    // Deprecate subtypes. Once a subtype has been deprecated it can never be
    // undeprecated. Starting with lambo!
    function deprecateDefenceSubtype(uint8 _subtypeIndexToDeprecate) external onlyOwner {
        defenceElementBySubtypeIndex[_subtypeIndexToDeprecate] = 0;
    }

    function deprecateMeleeSubtype(uint8 _subtypeIndexToDeprecate) external onlyOwner {
        meleeElementBySubtypeIndex[_subtypeIndexToDeprecate] = 0;
    }

    function deprecateBodySubtype(uint8 _subtypeIndexToDeprecate) external onlyOwner {
        bodyElementBySubtypeIndex[_subtypeIndexToDeprecate] = 0;
    }

    function deprecateTurretSubtype(uint8 _subtypeIndexToDeprecate) external onlyOwner {
        turretElementBySubtypeIndex[_subtypeIndexToDeprecate] = 0;
    }

    // function _randomIndex(uint _rand, uint8 _startIx, uint8 _endIx, uint8 _modulo) internal pure returns (uint8) {
    //     require(_startIx < _endIx);
    //     bytes32 randBytes = bytes32(_rand);
    //     uint result = 0;
    //     for (uint8 i=_startIx; i<_endIx; i++) {
    //         result = result | uint8(randBytes[i]);
    //         result << 8;
    //     }
    //     uint8 resultInt = uint8(uint(result) % _modulo);
    //     return resultInt;
    // }


    // This function takes a random uint, an owner and randomly generates a valid part.
    // It then transfers that part to the owner.
    function _generateRandomPart(uint _rand, address _owner) internal {
        // random uint 20 in length - MAYBE 20.
        // first randomly gen a part type
        _rand = uint(keccak256(_rand));
        uint8[4] memory randomPart;
        randomPart[0] = uint8(_rand % 4) + 1;
        _rand = uint(keccak256(_rand));

        // randomPart[0] = _randomIndex(_rand,0,4,4) + 1; // 1, 2, 3, 4, => defence, melee, body, turret

        if (randomPart[0] == DEFENCE) {
            randomPart[1] = _getRandomPartSubtype(_rand,defenceElementBySubtypeIndex);
            randomPart[3] = _getElement(defenceElementBySubtypeIndex, randomPart[1]);

        } else if (randomPart[0] == MELEE) {
            randomPart[1] = _getRandomPartSubtype(_rand,meleeElementBySubtypeIndex);
            randomPart[3] = _getElement(meleeElementBySubtypeIndex, randomPart[1]);

        } else if (randomPart[0] == BODY) {
            randomPart[1] = _getRandomPartSubtype(_rand,bodyElementBySubtypeIndex);
            randomPart[3] = _getElement(bodyElementBySubtypeIndex, randomPart[1]);

        } else if (randomPart[0] == TURRET) {
            randomPart[1] = _getRandomPartSubtype(_rand,turretElementBySubtypeIndex);
            randomPart[3] = _getElement(turretElementBySubtypeIndex, randomPart[1]);

        }
        _rand = uint(keccak256(_rand));
        randomPart[2] = _getRarity(_rand);
        // randomPart[2] = _getRarity(_randomIndex(_rand,8,12,3)); // rarity
        _createPart(randomPart, _owner);
    }

    function _getRandomPartSubtype(uint _rand, uint8[] elementBySubtypeIndex) internal pure returns (uint8) {
        require(elementBySubtypeIndex.length < uint(uint8(-1)));
        uint8 subtypeLength = uint8(elementBySubtypeIndex.length);
        require(subtypeLength > 0);
        uint8 subtypeIndex = uint8(_rand % subtypeLength);
        // uint8 subtypeIndex = _randomIndex(_rand,4,8,subtypeLength);
        uint8 count = 0;
        while (elementBySubtypeIndex[subtypeIndex] == 0) {
            subtypeIndex++;
            count++;
            if (subtypeIndex == subtypeLength) {
                subtypeIndex = 0;
            }
            if (count > subtypeLength) {
                break;
            }
        }
        require(elementBySubtypeIndex[subtypeIndex] != 0);
        return subtypeIndex + 1;
    }


    function _getRarity(uint rand) pure internal returns (uint8) {
        uint16 rarity = uint16(rand % 1000);
        if (rarity >= 990) {  // 1% chance of gold
          return GOLD;
        } else if (rarity >= 970) { // 2% chance of shadow
          return SHADOW;
        } else {
          return STANDARD;
        }
    }

    function _getElement(uint8[] elementBySubtypeIndex, uint8 subtype) internal pure returns (uint8) {
        uint8 subtypeIndex = subtype - 1;
        return elementBySubtypeIndex[subtypeIndex];
    }

    mapping(address => uint[]) pendingPartCrates ;

    function getPendingPartCrateLength() external view returns (uint) {
        return pendingPartCrates[msg.sender].length;
    }

    /// Put shards together into a new part-crate
    function redeemShardsIntoPending() external {
        User storage user = addressToUser[msg.sender];
         while (user.numShards >= SHARDS_TO_PART) {
             user.numShards -= SHARDS_TO_PART;
             pendingPartCrates[msg.sender].push(block.number);
             // 256 blocks to redeem
         }
    }

    function openPendingPartCrates() external {
        uint[] memory crates = pendingPartCrates[msg.sender];
        for (uint i = 0; i < crates.length; i++) {
            uint pendingBlockNumber = crates[i];
            // can't open on the same timestamp
            require(block.number > pendingBlockNumber);

            var hash = block.blockhash(pendingBlockNumber);

            if (uint(hash) != 0) {
                // different results for all different crates, even on the same block/same user
                // randomness is already taken care of
                uint rand = uint(keccak256(hash, msg.sender, i)); // % (10 ** 20);
                _generateRandomPart(rand, msg.sender);
            } else {
                // Do nothing, no second chances to secure integrity of randomness.
            }
        }
        delete pendingPartCrates[msg.sender];
    }

    uint32 constant SHARDS_MAX = 10000;

    function _addShardsToUser(User storage _user, uint32 _shards) internal {
        uint32 updatedShards = _user.numShards + _shards;
        if (updatedShards > SHARDS_MAX) {
            updatedShards = SHARDS_MAX;
        }
        _user.numShards = updatedShards;
        ShardsAdded(msg.sender, _shards);
    }

    // FORGING / SCRAPPING
    event ShardsAdded(address caller, uint32 shards);
    event Scrap(address user, uint partId);

    uint32 constant SHARDS_TO_PART = 500;
    uint8 public scrapPercent = 60;
    uint8 public burnRate = 60; 

    function setScrapPercent(uint8 _newPercent) external onlyOwner {
        require((_newPercent >= 50) && (_newPercent <= 90));
        scrapPercent = _newPercent;
    }

    // function setScrapyard(address _scrapyard) external onlyOwner {
    //     scrapyard = _scrapyard;
    // }

    function setBurnRate(uint8 _rate) external onlyOwner {
        burnRate = _rate;
    }


    uint public scrapCount = 0;

    // scraps a part for shards
    function scrap(uint partId) external {
        require(owns(msg.sender, partId));
        User storage u = addressToUser[msg.sender];
        _addShardsToUser(u, (SHARDS_TO_PART * scrapPercent) / 100);
        Scrap(msg.sender, partId);
        // this doesn't need to be secure
        // no way to manipulate it apart from guaranteeing your parts are resold
        // or burnt
        if (uint(keccak256(scrapCount)) % 100 >= burnRate) {
            _transfer(msg.sender, address(this), partId);
            _createScrapPartAuction(partId);
        } else {
            _transfer(msg.sender, address(0), partId);
        }
        scrapCount++;
    }

}

contract Mint is PerksRewards {
    
    // Owner only function to give an address new parts.
    // Strictly capped at 5000.
    // This will ONLY be used for promotional purposes (i.e. providing items for Wax/OPSkins partnership)
    // which we don't benefit financially from, or giving users who win the prize of designing a part 
    // for the game, a single copy of that part.
    
    uint16 constant MINT_LIMIT = 5000;
    uint16 public partsMinted = 0;

    function mintParts(uint16 _count, address _owner) public onlyOwner {
        require(_count > 0 && _count <= 50);
        // check overflow
        require(partsMinted + _count > partsMinted);
        require(partsMinted + _count < MINT_LIMIT);
        
        addressToUser[_owner].numShards += SHARDS_TO_PART * _count;
        
        partsMinted += _count;
    }       

    function mintParticularPart(uint8[4] _partArray, address _owner) public onlyOwner {
        require(partsMinted < MINT_LIMIT);
        /* cannot create deprecated parts
        for (uint i = 0; i < deprecated.length; i++) {
            if (_partArray[2] == deprecated[i]) {
                revert();
            }
        } */
        _createPart(_partArray, _owner);
        partsMinted++;
    }

}




contract NewCratePreSale {
    
    // migration functions migrate the data from the previous contract in stages
    // all addresses are included for transparency and easy verification
    // however addresses with no robots (i.e. failed transaction and never bought properly) have been commented out.
    // to view the full list of state assignments, go to etherscan.io/address/{address} and you can view the verified
    mapping (address => uint[]) public userToRobots; 

    function _migrate(uint _index) external onlyOwner {
        bytes4 selector = bytes4(keccak256("setData()"));
        address a = migrators[_index];
        require(a.delegatecall(selector));
    }
    // source code - feel free to verify the migration
    address[6] migrators = [
        0x700FeBD9360ac0A0a72F371615427Bec4E4454E5, //0x97AE01893E42d6d33fd9851A28E5627222Af7BBB,
        0x72Cc898de0A4EAC49c46ccb990379099461342f6,
        0xc3cC48da3B8168154e0f14Bf0446C7a93613F0A7,
        0x4cC96f2Ddf6844323ae0d8461d418a4D473b9AC3,
        0xa52bFcb5FF599e29EE2B9130F1575BaBaa27de0A,
        0xe503b42AabdA22974e2A8B75Fa87E010e1B13584
    ];
    
    function NewCratePreSale() public payable {
        
            owner = msg.sender;
        // one time transfer of state from the previous contract
        // var previous = CratePreSale(0x3c7767011C443EfeF2187cf1F2a4c02062da3998); //MAINNET

        // oldAppreciationRateWei = previous.appreciationRateWei();
        oldAppreciationRateWei = 100000000000000;
        appreciationRateWei = oldAppreciationRateWei;
  
        // oldPrice = previous.currentPrice();
        oldPrice = 232600000000000000;
        currentPrice = oldPrice;

        // oldCratesSold = previous.cratesSold();
        oldCratesSold = 1075;
        cratesSold = oldCratesSold;

        // Migration Rationale
        // due to solidity issues with enumerability (contract calls cannot return dynamic arrays etc)
        // no need for trust -> can still use web3 to call the previous contract and check the state
        // will only change in the future if people send more eth
        // and will be obvious due to change in crate count. Any purchases on the old contract
        // after this contract is deployed will be fully refunded, and those robots bought will be voided. 
        // feel free to validate any address on the old etherscan:
        // https://etherscan.io/address/0x3c7767011C443EfeF2187cf1F2a4c02062da3998
        // can visit the exact contracts at the addresses listed above
    }

    // ------ STATE ------
    uint256 constant public MAX_CRATES_TO_SELL = 3900; // Max no. of robot crates to ever be sold
    uint256 constant public PRESALE_END_TIMESTAMP = 1518699600; // End date for the presale - no purchases can be made after this date - Midnight 16 Feb 2018 UTC

    uint256 public appreciationRateWei;
    uint32 public cratesSold;
    uint256 public currentPrice;

    // preserve these for later verification
    uint32 public oldCratesSold;
    uint256 public oldPrice;
    uint256 public oldAppreciationRateWei;
    // mapping (address => uint32) public userCrateCount; // replaced with more efficient method
    

    // store the unopened crates of this user
    // actually stores the blocknumber of each crate 
    mapping (address => uint[]) public addressToPurchasedBlocks;
    // store the number of expired crates for each user 
    // i.e. crates where the user failed to open the crate within 256 blocks (~1 hour)
    // these crates will be able to be opened post-launch
    mapping (address => uint) public expiredCrates;
    // store the part information of purchased crates



    function openAll() public {
        uint len = addressToPurchasedBlocks[msg.sender].length;
        require(len > 0);
        uint8 count = 0;
        // len > i to stop predicatable wraparound
        for (uint i = len - 1; i >= 0 && len > i; i--) {
            uint crateBlock = addressToPurchasedBlocks[msg.sender][i];
            require(block.number > crateBlock);
            // can't open on the same timestamp
            var hash = block.blockhash(crateBlock);
            if (uint(hash) != 0) {
                // different results for all different crates, even on the same block/same user
                // randomness is already taken care of
                uint rand = uint(keccak256(hash, msg.sender, i)) % (10 ** 20);
                userToRobots[msg.sender].push(rand);
                count++;
            } else {
                // all others will be expired
                expiredCrates[msg.sender] += (i + 1);
                break;
            }
        }
        CratesOpened(msg.sender, count);
        delete addressToPurchasedBlocks[msg.sender];
    }

    // ------ EVENTS ------
    event CratesPurchased(address indexed _from, uint8 _quantity);
    event CratesOpened(address indexed _from, uint8 _quantity);

    // ------ FUNCTIONS ------
    function getPrice() view public returns (uint256) {
        return currentPrice;
    }

    function getRobotCountForUser(address _user) external view returns(uint256) {
        return userToRobots[_user].length;
    }

    function getRobotForUserByIndex(address _user, uint _index) external view returns(uint) {
        return userToRobots[_user][_index];
    }

    function getRobotsForUser(address _user) view public returns (uint[]) {
        return userToRobots[_user];
    }

    function getPendingCratesForUser(address _user) external view returns(uint[]) {
        return addressToPurchasedBlocks[_user];
    }

    function getPendingCrateForUserByIndex(address _user, uint _index) external view returns(uint) {
        return addressToPurchasedBlocks[_user][_index];
    }

    function getExpiredCratesForUser(address _user) external view returns(uint) {
        return expiredCrates[_user];
    }

    function incrementPrice() private {
        // Decrease the rate of increase of the crate price
        // as the crates become more expensive
        // to avoid runaway pricing
        // (halving rate of increase at 0.1 ETH, 0.2 ETH, 0.3 ETH).
        if ( currentPrice == 100000000000000000 ) {
            appreciationRateWei = 200000000000000;
        } else if ( currentPrice == 200000000000000000) {
            appreciationRateWei = 100000000000000;
        } else if (currentPrice == 300000000000000000) {
            appreciationRateWei = 50000000000000;
        }
        currentPrice += appreciationRateWei;
    }

    function purchaseCrates(uint8 _cratesToBuy) public payable whenNotPaused {
        require(now < PRESALE_END_TIMESTAMP); // Check presale is still ongoing.
        require(_cratesToBuy <= 10); // Can only buy max 10 crates at a time. Don't be greedy!
        require(_cratesToBuy >= 1); // Sanity check. Also, you have to buy a crate. 
        require(cratesSold + _cratesToBuy <= MAX_CRATES_TO_SELL); // Check max crates sold is less than hard limit
        uint256 priceToPay = _calculatePayment(_cratesToBuy);
         require(msg.value >= priceToPay); // Check buyer sent sufficient funds to purchase
        if (msg.value > priceToPay) { //overpaid, return excess
            msg.sender.transfer(msg.value-priceToPay);
        }
        //all good, payment received. increment number sold, price, and generate crate receipts!
        cratesSold += _cratesToBuy;
      for (uint8 i = 0; i < _cratesToBuy; i++) {
            incrementPrice();
            addressToPurchasedBlocks[msg.sender].push(block.number);
        }

        CratesPurchased(msg.sender, _cratesToBuy);
    } 

    function _calculatePayment (uint8 _cratesToBuy) private view returns (uint256) {
        
        uint256 tempPrice = currentPrice;

        for (uint8 i = 1; i < _cratesToBuy; i++) {
            tempPrice += (currentPrice + (appreciationRateWei * i));
        } // for every crate over 1 bought, add current Price and a multiple of the appreciation rate
          // very small edge case of buying 10 when you the appreciation rate is about to halve
          // is compensated by the great reduction in gas by buying N at a time.
        
        return tempPrice;
    }


    //owner only withdrawal function for the presale
    function withdraw() onlyOwner public {
        owner.transfer(this.balance);
    }

    function addFunds() onlyOwner external payable {

    }

  event SetPaused(bool paused);

  // starts unpaused
  bool public paused = false;

  modifier whenNotPaused() {
    require(!paused);
    _;
  }

  modifier whenPaused() {
    require(paused);
    _;
  }

  function pause() external onlyOwner whenNotPaused returns (bool) {
    paused = true;
    SetPaused(paused);
    return true;
  }

  function unpause() external onlyOwner whenPaused returns (bool) {
    paused = false;
    SetPaused(paused);
    return true;
  }


  address public owner;

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




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

  function transferOwnership(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }
    
}
contract EtherbotsMigrations is Mint {

    event CratesOpened(address indexed _from, uint8 _quantity);
    event OpenedOldCrates(address indexed _from);
    event MigratedCrates(address indexed _from, uint16 _quantity, bool isMigrationComplete);

    address presale = 0xc23F76aEa00B775AADC8504CcB22468F4fD2261A;
    mapping(address => bool) public hasMigrated;
    mapping(address => bool) public hasOpenedOldCrates;
    mapping(address => uint[]) pendingCrates;
    mapping(address => uint16) public cratesMigrated;

  
    // Element: copy for MIGRATIONS ONLY.
    string constant private DEFENCE_ELEMENT_BY_ID = "12434133214";
    string constant private MELEE_ELEMENT_BY_ID = "31323422111144";
    string constant private BODY_ELEMENT_BY_ID = "212343114234111";
    string constant private TURRET_ELEMENT_BY_ID = "43212113434";

    // Once only function.
    // Transfers all pending and expired crates in the old contract
    // into pending crates in the current one.
    // Users can then open them on the new contract.
    // Should only rarely have to be called.
    // event oldpending(uint old);

    function openOldCrates() external {
        require(hasOpenedOldCrates[msg.sender] == false);
        // uint oldPendingCrates = NewCratePreSale(presale).getPendingCrateForUserByIndex(msg.sender,0); // getting unrecognised opcode here --!
        // oldpending(oldPendingCrates);
        // require(oldPendingCrates == 0);
        _migrateExpiredCrates();
        hasOpenedOldCrates[msg.sender] = true;
        OpenedOldCrates(msg.sender);
    }

    function migrate() external whenNotPaused {
        
        // Can't migrate twice .
        require(hasMigrated[msg.sender] == false);
        
        // require(NewCratePreSale(presale).getPendingCrateForUserByIndex(msg.sender,0) == 0);
        // No pending crates in the new contract allowed. Make sure you open them first.
        require(pendingCrates[msg.sender].length == 0);
        
        // If the user has old expired crates, don't let them migrate until they've
        // converted them to pending crates in the new contract.
        if (NewCratePreSale(presale).getExpiredCratesForUser(msg.sender) > 0) {
            require(hasOpenedOldCrates[msg.sender]); 
        }

        // have to make a ton of calls unfortunately 
        uint16 length = uint16(NewCratePreSale(presale).getRobotCountForUser(msg.sender));

        // gas limit will be exceeded with *whale* etherbot players!
        // let's migrate their robots in batches of ten.
        // they can afford it
        bool isMigrationComplete = false;
        var max = length - cratesMigrated[msg.sender];
        if (max > 9) {
            max = 9;
        } else { // final call - all robots will be migrated
            isMigrationComplete = true;
            hasMigrated[msg.sender] = true;
        }
        for (uint i = cratesMigrated[msg.sender]; i < cratesMigrated[msg.sender] + max; i++) {
            var robot = NewCratePreSale(presale).getRobotForUserByIndex(msg.sender, i);
            var robotString = uintToString(robot);
            // MigratedBot(robotString);

            _migrateRobot(robotString);
            
        }
        cratesMigrated[msg.sender] += max;
        MigratedCrates(msg.sender, cratesMigrated[msg.sender], isMigrationComplete);
    }

    function _migrateRobot(string robot) private {
        var (melee, defence, body, turret) = _convertBlueprint(robot);
        // blueprints event
        // blueprints(body, turret, melee, defence);
        _createPart(melee, msg.sender);
        _createPart(defence, msg.sender);
        _createPart(turret, msg.sender);
        _createPart(body, msg.sender);
    }

    function _getRarity(string original, uint8 low, uint8 high) pure private returns (uint8) {
        uint32 rarity = stringToUint32(substring(original,low,high));
        if (rarity >= 950) {
          return GOLD; 
        } else if (rarity >= 850) {
          return SHADOW;
        } else {
          return STANDARD; 
        }
    }
   
    function _getElement(string elementString, uint partId) pure private returns(uint8) {
        return stringToUint8(substring(elementString, partId-1,partId));
    }

    // Actually part type
    function _getPartId(string original, uint8 start, uint8 end, uint8 partCount) pure private returns(uint8) {
        return (stringToUint8(substring(original,start,end)) % partCount) + 1;
    }

    function userPendingCrateNumber(address _user) external view returns (uint) {
        return pendingCrates[_user].length;
    }    
    
    // convert old string representation of robot into 4 new ERC721 parts
  
    function _convertBlueprint(string original) pure private returns(uint8[4] body,uint8[4] melee, uint8[4] turret, uint8[4] defence ) {

        /* ------ CONVERSION TIME ------ */
        

        body[0] = BODY; 
        body[1] = _getPartId(original, 3, 5, 15);
        body[2] = _getRarity(original, 0, 3);
        body[3] = _getElement(BODY_ELEMENT_BY_ID, body[1]);
        
        turret[0] = TURRET;
        turret[1] = _getPartId(original, 8, 10, 11);
        turret[2] = _getRarity(original, 5, 8);
        turret[3] = _getElement(TURRET_ELEMENT_BY_ID, turret[1]);

        melee[0] = MELEE;
        melee[1] = _getPartId(original, 13, 15, 14);
        melee[2] = _getRarity(original, 10, 13);
        melee[3] = _getElement(MELEE_ELEMENT_BY_ID, melee[1]);

        defence[0] = DEFENCE;
        var len = bytes(original).length;
        // string of number does not have preceding 0's
        if (len == 20) {
            defence[1] = _getPartId(original, 18, 20, 11);
        } else if (len == 19) {
            defence[1] = _getPartId(original, 18, 19, 11);
        } else { //unlikely to have length less than 19
            defence[1] = uint8(1);
        }
        defence[2] = _getRarity(original, 15, 18);
        defence[3] = _getElement(DEFENCE_ELEMENT_BY_ID, defence[1]);

        // implicit return
    }

    // give one more chance
    function _migrateExpiredCrates() private {
        // get the number of expired crates
        uint expired = NewCratePreSale(presale).getExpiredCratesForUser(msg.sender);
        for (uint i = 0; i < expired; i++) {
            pendingCrates[msg.sender].push(block.number);
        }
    }
    // Users can open pending crates on the new contract.
    function openCrates() public whenNotPaused {
        uint[] memory pc = pendingCrates[msg.sender];
        require(pc.length > 0);
        uint8 count = 0;
        for (uint i = 0; i < pc.length; i++) {
            uint crateBlock = pc[i];
            require(block.number > crateBlock);
            // can't open on the same timestamp
            var hash = block.blockhash(crateBlock);
            if (uint(hash) != 0) {
                // different results for all different crates, even on the same block/same user
                // randomness is already taken care of
                uint rand = uint(keccak256(hash, msg.sender, i)) % (10 ** 20);
                _migrateRobot(uintToString(rand));
                count++;
            }
        }
        CratesOpened(msg.sender, count);
        delete pendingCrates[msg.sender];
    }

    
}

contract Battle {
    // This struct does not exist outside the context of a battle

    // the name of the battle type
    function name() external view returns (string);
    // the number of robots currently battling
    function playerCount() external view returns (uint count);
    // creates a new battle, with a submitted user string for initial input/
    function createBattle(address _creator, uint[] _partIds, bytes32 _commit, uint _revealLength) external payable returns (uint);
    // cancels the battle at battleID
    function cancelBattle(uint battleID) external;
    
    function winnerOf(uint battleId, uint index) external view returns (address);
    function loserOf(uint battleId, uint index) external view returns (address);

    event BattleCreated(uint indexed battleID, address indexed starter);
    event BattleStage(uint indexed battleID, uint8 moveNumber, uint8[2] attackerMovesDefenderMoves, uint16[2] attackerDamageDefenderDamage);
    event BattleEnded(uint indexed battleID, address indexed winner);
    event BattleConcluded(uint indexed battleID);
    event BattlePropertyChanged(string name, uint previous, uint value);
}
contract EtherbotsBattle is EtherbotsMigrations {

    // can never remove any of these contracts, can only add
    // once we publish a contract, you'll always be able to play by that ruleset
    // good for two player games which are non-susceptible to collusion
    // people can be trusted to choose the most beneficial outcome, which in this case
    // is the fairest form of gameplay.
    // fields which are vulnerable to collusion still have to be centrally controlled :(
    function addApprovedBattle(Battle _battle) external onlyOwner {
        approvedBattles.push(_battle);
    }

    function _isApprovedBattle() internal view returns (bool) {
        for (uint8 i = 0; i < approvedBattles.length; i++) {
            if (msg.sender == address(approvedBattles[i])) {
                return true;
            }
        }
        return false;
    }

    modifier onlyApprovedBattles(){
        require(_isApprovedBattle());
        _;
    }


    function createBattle(uint _battleId, uint[] partIds, bytes32 commit, uint revealLength) external payable {
        // sanity check to make sure _battleId is a valid battle
        require(_battleId < approvedBattles.length);
        //if parts are given, make sure they are owned
        if (partIds.length > 0) {
            require(ownsAll(msg.sender, partIds));
        }
        //battle can decide number of parts required for battle

        Battle battle = Battle(approvedBattles[_battleId]);
        // Transfer all to selected battle contract.
        for (uint i=0; i<partIds.length; i++) {
            _approve(partIds[i], address(battle));
        }
        uint newDuelId = battle.createBattle.value(msg.value)(msg.sender, partIds, commit, revealLength);
        NewDuel(_battleId, newDuelId);
    }

    event NewDuel(uint battleId, uint duelId);


    mapping(address => Reward[]) public pendingRewards;
    // actually probably just want a length getter here as default public mapping getters
    // are pretty expensive

    function getPendingBattleRewardsCount(address _user) external view returns (uint) {
        return pendingRewards[_user].length;
    } 

    struct Reward {
        uint blocknumber;
        int32 exp;
    }

    function addExperience(address _user, uint[] _partIds, int32[] _exps) external onlyApprovedBattles {
        address user = _user;
        require(_partIds.length == _exps.length);
        int32 sum = 0;
        for (uint i = 0; i < _exps.length; i++) {
            sum += _addPartExperience(_partIds[i], _exps[i]);
        }
        _addUserExperience(user, sum);
        _storeReward(user, sum);
    }

    // store sum.
    function _storeReward(address _user, int32 _battleExp) internal {
        pendingRewards[_user].push(Reward({
            blocknumber: 0,
            exp: _battleExp
        }));
    }

    /* function _getExpProportion(int _exp) returns(int) {
        // assume max/min of 1k, -1k
        return 1000 + _exp + 1; // makes it between (1, 2001)
    } */
    uint8 bestMultiple = 3;
    uint8 mediumMultiple = 2;
    uint8 worstMultiple = 1;
    uint8 minShards = 1;
    uint8 bestProbability = 97;
    uint8 mediumProbability = 85;
    function _getExpMultiple(int _exp) internal view returns (uint8, uint8) {
        if (_exp > 500) {
            return (bestMultiple,mediumMultiple);
        } else if (_exp > 0) {
            return (mediumMultiple,mediumMultiple);
        } else {
            return (worstMultiple,mediumMultiple);
        }
    }

    function setBest(uint8 _newBestMultiple) external onlyOwner {
        bestMultiple = _newBestMultiple;
    }
    function setMedium(uint8 _newMediumMultiple) external onlyOwner {
        mediumMultiple = _newMediumMultiple;
    }
    function setWorst(uint8 _newWorstMultiple) external onlyOwner {
        worstMultiple = _newWorstMultiple;
    }
    function setMinShards(uint8 _newMin) external onlyOwner {
        minShards = _newMin;
    }
    function setBestProbability(uint8 _newBestProb) external onlyOwner {
        bestProbability = _newBestProb;
    }
    function setMediumProbability(uint8 _newMinProb) external onlyOwner {
        mediumProbability = _newMinProb;
    }



    function _calculateShards(int _exp, uint rand) internal view returns (uint16) {
        var (a, b) = _getExpMultiple(_exp);
        uint16 shards;
        uint randPercent = rand % 100;
        if (randPercent > bestProbability) {
            shards = uint16(a * ((rand % 20) + 12) / b);
        } else if (randPercent > mediumProbability) {
            shards = uint16(a * ((rand % 10) + 6) / b);  
        } else {
            shards = uint16((a * (rand % 5)) / b);       
        }

        if (shards < minShards) {
            shards = minShards;
        }

        return shards;
    }

    // convert wins into pending battle crates
    // Not to pending old crates (migration), nor pending part crates (redeemShards)
    function convertReward() external {

        Reward[] storage rewards = pendingRewards[msg.sender];

        for (uint i = 0; i < rewards.length; i++) {
            if (rewards[i].blocknumber == 0) {
                rewards[i].blocknumber = block.number;
            }
        }

    }

    // in PerksRewards
    function redeemBattleCrates() external {
        uint8 count = 0;
        uint len = pendingRewards[msg.sender].length;
        require(len > 0);
        for (uint i = 0; i < len; i++) {
            Reward memory rewardStruct = pendingRewards[msg.sender][i];
            // can't open on the same timestamp
            require(block.number > rewardStruct.blocknumber);
            // ensure user has converted all pendingRewards
            require(rewardStruct.blocknumber != 0);

            var hash = block.blockhash(rewardStruct.blocknumber);

            if (uint(hash) != 0) {
                // different results for all different crates, even on the same block/same user
                // randomness is already taken care of
                uint rand = uint(keccak256(hash, msg.sender, i));
                _generateBattleReward(rand,rewardStruct.exp);
                count++;
            } else {
                // Do nothing, no second chances to secure integrity of randomness.
            }
        }
        CratesOpened(msg.sender, count);
        delete pendingRewards[msg.sender];
    }

    function _generateBattleReward(uint rand, int32 exp) internal {
        if (((rand % 1000) > PART_REWARD_CHANCE) && (exp > 0)) {
            _generateRandomPart(rand, msg.sender);
        } else {
            _addShardsToUser(addressToUser[msg.sender], _calculateShards(exp, rand));
        }
    }

    // don't need to do any scaling
    // should already have been done by previous stages
    function _addUserExperience(address user, int32 exp) internal {
        // never allow exp to drop below 0
        User memory u = addressToUser[user];
        if (exp < 0 && uint32(int32(u.experience) + exp) > u.experience) {
            u.experience = 0;
            return;
        } else if (exp > 0) {
            // check for overflow
            require(uint32(int32(u.experience) + exp) > u.experience);
        }
        addressToUser[user].experience = uint32(int32(u.experience) + exp);
        //_addUserReward(user, exp);
    }

    function setMinScaled(int8 _min) external onlyOwner {
        minScaled = _min;
    }

    int8 minScaled = 25;

    function _scaleExp(uint32 _battleCount, int32 _exp) internal view returns (int32) {
        if (_battleCount <= 10) {
            return _exp; // no drop off
        }
        int32 exp =  (_exp * 10)/int32(_battleCount);

        if (exp < minScaled) {
            return minScaled;
        }
        return exp;
    }

    function _addPartExperience(uint _id, int32 _baseExp) internal returns (int32) {
        // never allow exp to drop below 0
        Part storage p = parts[_id];
        if (now - p.battlesLastReset > 24 hours) {
            p.battlesLastReset = uint32(now);
            p.battlesLastDay = 0;
        }
        p.battlesLastDay++;
        int32 exp = _baseExp;
        if (exp > 0) {
            exp = _scaleExp(p.battlesLastDay, _baseExp);
        }

        if (exp < 0 && uint32(int32(p.experience) + exp) > p.experience) {
            // check for wrap-around
            p.experience = 0;
            return;
        } else if (exp > 0) {
            // check for overflow
            require(uint32(int32(p.experience) + exp) > p.experience);
        }

        parts[_id].experience = uint32(int32(parts[_id].experience) + exp);
        return exp;
    }

    function totalLevel(uint[] partIds) public view returns (uint32) {
        uint32 total = 0;
        for (uint i = 0; i < partIds.length; i++) {
            total += getLevel(parts[partIds[i]].experience);
        }
        return total;
    }

    //requires parts in order
    function hasOrderedRobotParts(uint[] partIds) external view returns(bool) {
        uint len = partIds.length;
        if (len != 4) {
            return false;
        }
        for (uint i = 0; i < len; i++) {
            if (parts[partIds[i]].partType != i+1) {
                return false;
            }
        }
        return true;
    }

}

contract EtherbotsCore is EtherbotsBattle {

    // The structure of Etherbots is modelled on CryptoKitties for obvious reasons:
    // ease of implementation, tried + tested etc.
    // it elides some features and includes some others.

    // The full system is implemented in the following manner:
    //
    // EtherbotsBase    | Storage and base types
    // EtherbotsAccess  | Access Control - who can change which state vars etc.
    // EtherbotsNFT     | ERC721 Implementation
    // EtherbotsBattle  | Battle interface contract: only one implementation currently, but could add more later.
    // EtherbotsAuction | Auction interface contract


    function EtherbotsCore() public {
        // Starts paused.
        paused = true;
        owner = msg.sender;
    }
    
    
    function() external payable {
    }

    function withdrawBalance() external onlyOwner {
        owner.transfer(this.balance);
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"_newElement","type":"uint8[]"}],"name":"addMeleeParts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newBestProb","type":"uint8"}],"name":"setBestProbability","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"cratesMigrated","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"hasOpenedOldCrates","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"_name","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_deedId","type":"uint256"}],"name":"approve","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"implementsERC721","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[],"name":"openCrates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"deedByIndex","outputs":[{"name":"_deedId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"openPendingPartCrates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newScrapAuctionDuration","type":"uint256"}],"name":"setScrapAuctionDuration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"meleeElementBySubtypeIndex","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"_tokenId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"partId","type":"uint256"}],"name":"scrap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"partIds","type":"uint256[]"}],"name":"hasOrderedRobotParts","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_subtypeIndexToDeprecate","type":"uint8"}],"name":"deprecateBodySubtype","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"partsMinted","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"redeemBattleCrates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_partId","type":"uint256"},{"name":"_startPrice","type":"uint256"},{"name":"_endPrice","type":"uint256"},{"name":"_duration","type":"uint256"}],"name":"createAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"partIndexToApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_count","type":"uint16"},{"name":"_owner","type":"address"}],"name":"mintParts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"deedOfOwnerByIndex","outputs":[{"name":"_deedId","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"partIds","type":"uint256[]"}],"name":"totalLevel","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_rate","type":"uint8"}],"name":"setBurnRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"uint256"}],"name":"pendingRewards","outputs":[{"name":"blocknumber","type":"uint256"},{"name":"exp","type":"int32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_deedId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_min","type":"int8"}],"name":"setMinScaled","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenIds","type":"uint256[]"}],"name":"transferAll","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenMetadata","outputs":[{"name":"infoUrl","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"getUserByAddress","outputs":[{"name":"","type":"uint32"},{"name":"","type":"uint8[32]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_start","type":"uint256"},{"name":"_numToSearch","type":"uint256"}],"name":"tokensOfOwnerWithinRange","outputs":[{"name":"ownerTokens","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"openOldCrates","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"getPartById","outputs":[{"name":"tokenId","type":"uint32"},{"name":"partType","type":"uint8"},{"name":"partSubType","type":"uint8"},{"name":"rarity","type":"uint8"},{"name":"element","type":"uint8"},{"name":"battlesLastDay","type":"uint32"},{"name":"experience","type":"uint32"},{"name":"forgeTime","type":"uint32"},{"name":"battlesLastReset","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_i","type":"uint8"}],"name":"choosePerk","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newElement","type":"uint8[]"}],"name":"addBodyParts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newMediumMultiple","type":"uint8"}],"name":"setMedium","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newMinProb","type":"uint8"}],"name":"setMediumProbability","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_partIds","type":"uint256[]"},{"name":"_exps","type":"int32[]"}],"name":"addExperience","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"owns","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"name":"ownerTokens","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"redeemShardsIntoPending","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"migrate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bodyElementBySubtypeIndex","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"countOfDeedsByOwner","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setAuctionAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"_smbol","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenIds","type":"uint256[]"}],"name":"approveMany","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_newMinEndPrice","type":"uint256"}],"name":"setScrapMinEndPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newMin","type":"uint8"}],"name":"setMinShards","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_subtypeIndexToDeprecate","type":"uint8"}],"name":"deprecateDefenceSubtype","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_battle","type":"address"}],"name":"addApprovedBattle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newBestMultiple","type":"uint8"}],"name":"setBest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transfer","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_battleId","type":"uint256"},{"name":"partIds","type":"uint256[]"},{"name":"commit","type":"bytes32"},{"name":"revealLength","type":"uint256"}],"name":"createBattle","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_tokenIds","type":"uint256[]"}],"name":"ownsAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_exp","type":"uint32"}],"name":"getLevel","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_deedId","type":"uint256"}],"name":"takeOwnership","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"getPartsOfOwner","outputs":[{"name":"","type":"bytes24[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"scrapPercent","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_deedId","type":"uint256"}],"name":"deedUri","outputs":[{"name":"_uri","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"convertReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"burnRate","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"ownerByIndex","outputs":[{"name":"_owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_start","type":"uint256"},{"name":"_numToSearch","type":"uint256"}],"name":"getPartsOfOwnerWithinRange","outputs":[{"name":"","type":"bytes24[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"countOfDeeds","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"userPendingCrateNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_subtypeIndexToDeprecate","type":"uint8"}],"name":"deprecateMeleeSubtype","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"countOfOwners","outputs":[{"name":"_count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"scrapCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newElement","type":"uint8[]"}],"name":"addTurretParts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newWorstMultiple","type":"uint8"}],"name":"setWorst","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_base","type":"string"}],"name":"setMetadataBase","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"defenceElementBySubtypeIndex","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"partIndexToOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"turretElementBySubtypeIndex","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"getPendingBattleRewardsCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPendingPartCrateLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"hasMigrated","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newChance","type":"uint256"}],"name":"setRewardChance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawAuctionBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newMinStartPrice","type":"uint256"}],"name":"setScrapMinStartPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newPercent","type":"uint8"}],"name":"setScrapPercent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_subtypeIndexToDeprecate","type":"uint8"}],"name":"deprecateTurretSubtype","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"PART_REWARD_CHANCE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"addressToUser","outputs":[{"name":"numShards","type":"uint32"},{"name":"experience","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_partArray","type":"uint8[4]"},{"name":"_owner","type":"address"}],"name":"mintParticularPart","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newElement","type":"uint8[]"}],"name":"addDefenceParts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"battleId","type":"uint256"},{"indexed":false,"name":"duelId","type":"uint256"}],"name":"NewDuel","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"_quantity","type":"uint8"}],"name":"CratesOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"}],"name":"OpenedOldCrates","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"_quantity","type":"uint16"},{"indexed":false,"name":"isMigrationComplete","type":"bool"}],"name":"MigratedCrates","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"caller","type":"address"},{"indexed":false,"name":"shards","type":"uint32"}],"name":"ShardsAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"partId","type":"uint256"}],"name":"Scrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"string"},{"indexed":false,"name":"","type":"uint8"},{"indexed":false,"name":"","type":"uint8[32]"}],"name":"PrintPerk","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"upgradedUser","type":"address"},{"indexed":true,"name":"perk","type":"uint8"}],"name":"PerkChosen","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":true,"name":"deedId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"approved","type":"address"},{"indexed":true,"name":"deedId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"partID","type":"uint256"},{"components":[{"name":"tokenId","type":"uint32"},{"name":"partType","type":"uint8"},{"name":"partSubType","type":"uint8"},{"name":"rarity","type":"uint8"},{"name":"element","type":"uint8"},{"name":"battlesLastDay","type":"uint32"},{"name":"experience","type":"uint32"},{"name":"forgeTime","type":"uint32"},{"name":"battlesLastReset","type":"uint32"}],"indexed":false,"name":"part","type":"tuple"}],"name":"Forge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newContract","type":"address"}],"name":"ContractUpgrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"paused","type":"bool"}],"name":"SetPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

606060409081526000805460a060020a60ff02191690558051908101604052601d81527f68747470733a2f2f6170692e6574686572626f74732e696f2f6170692f000000602082015260089080516200005d92916020019062000189565b5066b1a2bc2ec500006009556611c37937e08000600a556202a300600b556103e3600c5560128054603c60ff199182161761ff0019908116613c0017909255600060135560148054600160b060020a03191675c23f76aea00b775aadc8504ccb22468f4fd2261a0000179055601a8054630100000062010000600392909416919091179093166102001762ff000019169190911763ff00000019169190911764ff0000000019166461000000001765ff00000000001916655500000000001766ff0000000000001916661900000000000017905534156200013d57600080fd5b6000805460a060020a60ff0219600160a060020a033316600160a060020a031992831681179190911674010000000000000000000000000000000000000000179091161790556200022e565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001cc57805160ff1916838001178555620001fc565b82800160010185558215620001fc579182015b82811115620001fc578251825591602001919060010190620001df565b506200020a9291506200020e565b5090565b6200022b91905b808211156200020a576000815560010162000215565b90565b615e52806200023e6000396000f3006060604052600436106104465763ffffffff60e060020a600035041662c8bb45811461044857806301aef7551461046657806301ffc9a71461047f57806305d78739146104cb57806306edcd241461050157806306fdde0314610520578063095ea7b3146105aa5780631051db34146105c157806311f43157146105d4578063139020d1146105e757806318160ddd1461060f57806318f95486146106225780631e42698b1461063557806323b872dd1461064b578063293100a9146106735780632f745c591461069f57806331a06772146106c157806332fb082f146106d7578063360c9ed0146106f55780633832677d1461070e5780633dde1598146107215780633f4ba83a14610734578063431f21da14610747578063434f811b146107665780634584117e14610798578063532709101461069f5780635c629788146107be5780635c975abb146108265780635eb08d8a146108395780635fd8c710146108525780636099ecb2146108655780636352211e146108a6578063651738a3146108bc57806367025dcf146108d55780636914db601461092757806369c212f61461093d5780636b68dd4b146109a25780636ce76ae314610a055780636ea34ce414610a1857806370a0823114610a91578063731ac7ed14610ab057806375ec899a14610ac957806377289b5014610ae7578063787b586f14610b00578063794b0e6b14610b19578063818d4b5d14610b505780638456cb5914610b725780638462151c14610b855780638da5cb5b14610ba45780638e92ee6614610bb75780638fd3ab8014610bca5780639028f20b14610bdd57806392efd27714610bf357806393ac363814610c1257806395d89b4114610c3157806399bb813414610c445780639b7eeb1214610c645780639e3249ab14610c7a5780639f7d9f6214610c935780639fbf538f14610cac578063a7c591c414610ccb578063a9059cbb14610ce4578063ab0db22014610cfb578063ad94d90114610d18578063b2cad9b714610d75578063b2e6ceeb14610d91578063b74e47ac14610d9c578063b87e461c14610dbb578063b95d2a5314610927578063bbf48d6f14610dce578063bed9985014610de1578063c04d90d014610df4578063c2fce71814610e0a578063c34588ba1461060f578063c500ea3614610e2f578063c87c07de14610e4e578063cd9a1fa614610e67578063ce78421614610e7a578063ce813d8f14610e8d578063d2ed2d3014610eab578063d3811c0f14610ec4578063d3b6ac9714610ee2578063d3cdb97b14610ef8578063d45973f414610f0e578063d479832714610f24578063d489e18014610f43578063d7625c8814610f56578063d7e31d6714610f75578063d8eb3a9814610f8b578063dae6f08114610f9e578063dfdce77b14610fb4578063e4f843f914610fcd578063ed06fb9114610fe6578063edf5388614610ff9578063f2fde38b14611039578063f379491414611058578063f794e7f21461109b575b005b341561045357600080fd5b61044660048035602481019101356110b9565b341561047157600080fd5b61044660ff6004351661114c565b341561048a57600080fd5b6104b77fffffffff0000000000000000000000000000000000000000000000000000000060043516611189565b604051901515815260200160405180910390f35b34156104d657600080fd5b6104ea600160a060020a03600435166115a6565b60405161ffff909116815260200160405180910390f35b341561050c57600080fd5b6104b7600160a060020a03600435166115bc565b341561052b57600080fd5b6105336115d1565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561056f578082015183820152602001610557565b50505050905090810190601f16801561059c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610446600160a060020a0360043516602435611613565b34156105cc57600080fd5b6104b76116ad565b34156105df57600080fd5b6104466116b2565b34156105f257600080fd5b6105fd600435611610565b60405190815260200160405180910390f35b341561061a57600080fd5b6105fd611873565b341561062d57600080fd5b610446611879565b341561064057600080fd5b6104466004356119aa565b341561065657600080fd5b610446600160a060020a03600435811690602435166044356119ca565b341561067e57600080fd5b610689600435611a5e565b60405160ff909116815260200160405180910390f35b34156106aa57600080fd5b6105fd600160a060020a0360043516602435611a90565b34156106cc57600080fd5b610446600435611aa3565b34156106e257600080fd5b6104b76004803560248101910135611ba1565b341561070057600080fd5b61044660ff60043516611c21565b341561071957600080fd5b6104ea611c7d565b341561072c57600080fd5b610446611c87565b341561073f57600080fd5b6104b7611dfd565b341561075257600080fd5b610446600435602435604435606435611e96565b341561077157600080fd5b61077c600435611f62565b604051600160a060020a03909116815260200160405180910390f35b34156107a357600080fd5b61044661ffff60043516600160a060020a0360243516611f7d565b34156107c957600080fd5b61080d600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061204695505050505050565b60405163ffffffff909116815260200160405180910390f35b341561083157600080fd5b6104b76120aa565b341561084457600080fd5b61044660ff600435166120ba565b341561085d57600080fd5b6104466120f1565b341561087057600080fd5b610887600160a060020a0360043516602435612147565b604051918252600390810b900b60208201526040908101905180910390f35b34156108b157600080fd5b61077c600435612185565b34156108c757600080fd5b61044660043560000b6121a9565b61044660048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437509496506121ee95505050505050565b341561093257600080fd5b610533600435612300565b341561094857600080fd5b61095c600160a060020a0360043516612311565b60405163ffffffff83168152602081018261040080838360005b8381101561098e578082015183820152602001610976565b505050509050019250505060405180910390f35b34156109ad57600080fd5b6109c7600160a060020a03600435166024356044356123a4565b60405160208082528190810183818151815260200191508051906020019060200280838360008381101561098e578082015183820152602001610976565b3415610a1057600080fd5b6104466124e0565b3415610a2357600080fd5b610a2e600435612560565b60405163ffffffff998a16815260ff9889166020820152968816604080890191909152958816606088015293909616608086015290861660a0850152851660c084015292841660e083015291909216610100830152610120909101905180910390f35b3415610a9c57600080fd5b6105fd600160a060020a0360043516612684565b3415610abb57600080fd5b61044660ff6004351661269f565b3415610ad457600080fd5b6104466004803560248101910135612863565b3415610af257600080fd5b61044660ff600435166128f1565b3415610b0b57600080fd5b61044660ff60043516612928565b3415610b2457600080fd5b61044660048035600160a060020a03169060248035808201929081013591604435908101910135612967565b3415610b5b57600080fd5b6104b7600160a060020a03600435166024356129fa565b3415610b7d57600080fd5b6104b7612a1a565b3415610b9057600080fd5b6109c7600160a060020a0360043516612ab4565b3415610baf57600080fd5b61077c612add565b3415610bc257600080fd5b610446612aec565b3415610bd557600080fd5b610446612b73565b3415610be857600080fd5b610689600435612ed1565b3415610bfe57600080fd5b6105fd600160a060020a0360043516612edf565b3415610c1d57600080fd5b610446600160a060020a0360043516612eea565b3415610c3c57600080fd5b610533612f3e565b61044660048035600160a060020a03169060248035908101910135612f7f565b3415610c6f57600080fd5b61044660043561303a565b3415610c8557600080fd5b61044660ff6004351661305a565b3415610c9e57600080fd5b61044660ff60043516613095565b3415610cb757600080fd5b610446600160a060020a03600435166130c4565b3415610cd657600080fd5b61044660ff6004351661311d565b610446600160a060020a036004351660243561314e565b61044660048035906024803590810191013560443560643561322a565b3415610d2357600080fd5b6104b760048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437509496506133d495505050505050565b3415610d8057600080fd5b61080d63ffffffff60043516613450565b61044660043561347c565b3415610da757600080fd5b6109c7600160a060020a03600435166134c6565b3415610dc657600080fd5b6106896134e6565b3415610dd957600080fd5b6104466134ef565b3415610dec57600080fd5b610689613563565b3415610dff57600080fd5b61077c600435613571565b3415610e1557600080fd5b6109c7600160a060020a036004351660243560443561358c565b3415610e3a57600080fd5b6105fd600160a060020a036004351661370a565b3415610e5957600080fd5b61044660ff60043516613725565b3415610e7257600080fd5b6105fd613754565b3415610e8557600080fd5b6105fd613759565b3415610e9857600080fd5b610446600480356024810191013561375f565b3415610eb657600080fd5b61044660ff600435166137ed565b3415610ecf57600080fd5b6104466004803560248101910135613826565b3415610eed57600080fd5b61068960043561384d565b3415610f0357600080fd5b61077c60043561385b565b3415610f1957600080fd5b610689600435613876565b3415610f2f57600080fd5b6105fd600160a060020a0360043516613884565b3415610f4e57600080fd5b6105fd61389f565b3415610f6157600080fd5b6104b7600160a060020a03600435166138bb565b3415610f8057600080fd5b6104466004356138d0565b3415610f9657600080fd5b61044661390d565b3415610fa957600080fd5b610446600435613978565b3415610fbf57600080fd5b61044660ff60043516613998565b3415610fd857600080fd5b61044660ff600435166139ec565b3415610ff157600080fd5b6105fd613a1b565b341561100457600080fd5b611018600160a060020a0360043516613a21565b60405163ffffffff9283168152911660208201526040908101905180910390f35b341561104457600080fd5b610446600160a060020a0360043516613a45565b341561106357600080fd5b6104466004608481806080604051908101604052919082826080808284375093955050509135600160a060020a03169150613ad39050565b34156110a657600080fd5b6104466004803560248101910135613b2b565b6000805433600160a060020a039081169116146110d557600080fd5b5060005b60ff81168290101561114757600e8054600181016110f78382615b6e565b6000928352602092839020909282040190601f16858560ff861681811061111a57fe5b84546101009490940a60ff60209092029390930135811683029202199092161790915550506001016110d9565b505050565b60005433600160a060020a0390811691161461116757600080fd5b601a805460ff9092166401000000000264ff0000000019909216919091179055565b60006040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f74616b654f776e6572736869702875696e743235362900000000000000000000815260160160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390201818181818600160e060020a03191682600160e060020a031916148061143a57506040517f74616b654f776e6572736869702875696e743235362900000000000000000000815260160160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f646565644f664f776e65724279496e64657828616464726573732c75696e743281527f3536290000000000000000000000000000000000000000000000000000000000602082015260230160405180910390206040517f636f756e744f66446565647342794f776e6572286164647265737329000000008152601c0160405180910390206040517f636f756e744f66446565647328290000000000000000000000000000000000008152600e0160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390201818181818600160e060020a03191682600160e060020a031916145b806114ec57506040517f646565645572692875696e743235362900000000000000000000000000000000815260100160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d6528290000000000000000000000000000000000000000000000000000815260060160405180910390201818600160e060020a03191682600160e060020a031916145b8061159e57506040517f6f776e65724279496e6465782875696e74323536290000000000000000000000815260150160405180910390206040517f636f756e744f664f776e657273282900000000000000000000000000000000008152600f0160405180910390206040517f646565644279496e6465782829000000000000000000000000000000000000008152600d0160405180910390201818600160e060020a03191682600160e060020a031916145b90505b919050565b60186020526000908152604090205461ffff1681565b60166020526000908152604090205460ff1681565b6115d9615ba2565b60408051908101604052600981527f4574686572626f74730000000000000000000000000000000000000000000000602082015290505b90565b60005460a060020a900460ff161561162a57600080fd5b341561163557600080fd5b61163f33826129fa565b151561164a57600080fd5b600081815260056020526040908190208054600160a060020a031916600160a060020a03858116918217909255839290913316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925905160405180910390a45050565b600190565b6116ba615ba2565b60008054819081908190819060a060020a900460ff16156116da57600080fd5b6017600033600160a060020a0316600160a060020a0316815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561174957602002820191906000526020600020905b815481526020019060010190808311611735575b50505050509550600086511161175e57600080fd5b60009450600093505b85518410156118095785848151811061177c57fe5b9060200190602002015192504383901161179557600080fd5b8240915081156117fe5768056bc75e2d63100000823386604051928352600160a060020a0391909116606060020a02602083015260348201526054016040519081900390208115156117e357fe5b0690506117f76117f282613bb9565b613cea565b6001909401935b600190930192611767565b33600160a060020a03167fa724f68a4b67886764af4c4780d0d8bf6b9d3d93579e07d9f0d6c2c8184252bc8660405160ff909116815260200160405180910390a2600160a060020a033316600090815260176020526040812061186b91615bb4565b505050505050565b60025490565b611881615ba2565b6000806000806011600033600160a060020a0316600160a060020a031681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156118f657602002820191906000526020600020905b8154815260200190600101908083116118e2575b50505050509450600093505b84518410156119825784848151811061191757fe5b9060200190602002015192504383901161193057600080fd5b82409150811561197757813385604051928352600160a060020a0391909116606060020a026020830152603482015260540160405190819003902090506119778133613d46565b600190930192611902565b600160a060020a03331660009081526011602052604081206119a391615bb4565b5050505050565b60005433600160a060020a039081169116146119c557600080fd5b600b55565b60005460a060020a900460ff16156119e157600080fd5b600160a060020a03821615156119f657600080fd5b30600160a060020a031682600160a060020a031614151515611a1757600080fd5b60008181526005602052604090205433600160a060020a03908116911614611a3e57600080fd5b611a4883826129fa565b1515611a5357600080fd5b611147838383614159565b600e805482908110611a6c57fe5b9060005260206000209060209182820401919006915054906101000a900460ff1681565b6000611a9c838361422f565b9392505050565b6000611aaf33836129fa565b1515611aba57600080fd5b5033600160a060020a03166000908152600160205260409020601254611af290829060649060ff166101f40263ffffffff16046142ae565b7fa1bee4ee172df140536bfc9c59145139b284507b6253b143f5d44fd19c2982983383604051600160a060020a03909216825260208201526040908101905180910390a1601260019054906101000a900460ff1660ff166064601354604051908152602001604051908190039020811515611b6957fe5b0610611b8857611b7a333084614159565b611b838261432e565b611b94565b611b9433600084614159565b5050601380546001019055565b6000818160048214611bb65760009250611c19565b5060005b81811015611c1457600181016002868684818110611bd457fe5b90506020020135815481101515611be757fe5b600091825260209091200154640100000000900460ff1614611c0c5760009250611c19565b600101611bba565b600192505b505092915050565b60005433600160a060020a03908116911614611c3c57600080fd5b6000600f8260ff16815481101515611c5057fe5b90600052602060002090602091828204019190066101000a81548160ff021916908360ff16021790555050565b60145461ffff1681565b6000806000611c94615bd2565b600160a060020a03331660009081526019602052604081205490945092508380808511611cc057600080fd5b600093505b84841015611d9b57600160a060020a0333166000908152601960205260409020805485908110611cf157fe5b90600052602060002090600202016040805190810160405281548152600190910154600390810b810b900b6020820152925082514311611d3057600080fd5b82511515611d3d57600080fd5b82514091508115611d9057813385604051928352600160a060020a0391909116606060020a02602083015260348201526054016040519081900390209050611d898160208501516143d0565b6001909501945b600190930192611cc5565b33600160a060020a03167fa724f68a4b67886764af4c4780d0d8bf6b9d3d93579e07d9f0d6c2c8184252bc8760405160ff909116815260200160405180910390a2600160a060020a033316600090815260196020526040812061186b91615be9565b6000805433600160a060020a03908116911614611e1957600080fd5b60005460a060020a900460ff161515611e3157600080fd5b6000805474ff00000000000000000000000000000000000000001916908190557f3c70af01296aef045b2f5c9d3c30b05d4428fd257145b9c7fcd76418e65b59809060a060020a900460ff16604051901515815260200160405180910390a150600190565b60005460a060020a900460ff1615611ead57600080fd5b611eb733856129fa565b1515611ec257600080fd5b600654611ed9908590600160a060020a031661442f565b600654600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b1515611f4857600080fd5b6102c65a03f11515611f5957600080fd5b50505050505050565b600560205260009081526040902054600160a060020a031681565b60005433600160a060020a03908116911614611f9857600080fd5b60008261ffff16118015611fb1575060328261ffff1611155b1515611fbc57600080fd5b60145461ffff90811683810190911611611fd557600080fd5b60145461138861ffff918216840190911610611ff057600080fd5b600160a060020a03166000908152600160205260409020805463ffffffff19811661ffff8481166101f40263ffffffff93841601909216179091556014805461ffff198116908316909301909116919091179055565b600080805b83518110156120a357612097600285838151811061206557fe5b906020019060200201518154811061207957fe5b600091825260209091200154606060020a900463ffffffff16613450565b9091019060010161204b565b5092915050565b60005460a060020a900460ff1681565b60005433600160a060020a039081169116146120d557600080fd5b6012805460ff9092166101000261ff0019909216919091179055565b60005433600160a060020a0390811691161461210c57600080fd5b600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050151561214557600080fd5b565b60196020528160005260406000208181548110151561216257fe5b60009182526020909120600290910201805460019091015490925060030b905082565b600081815260036020526040902054600160a060020a03168015156115a157600080fd5b60005433600160a060020a039081169116146121c457600080fd5b601a805460009290920b60ff1666010000000000000266ff00000000000019909216919091179055565b60008054819060a060020a900460ff161561220857600080fd5b341561221357600080fd5b600160a060020a038416151561222857600080fd5b30600160a060020a031684600160a060020a03161415151561224957600080fd5b600654600160a060020a038581169116141561226457600080fd5b600091505b6007548210156122b057600780548390811061228157fe5b600091825260209091200154600160a060020a03858116911614156122a557600080fd5b600190910190612269565b6122ba33846133d4565b15156122c557600080fd5b5060005b82518110156122fa576122f233858584815181106122e357fe5b90602001906020020151614159565b6001016122c9565b50505050565b612308615ba2565b61159e8261445d565b600061231b615c0a565b600160a060020a0383166000908152600160208181526040928390208054640100000000900463ffffffff1693920191829190610400905190810160405291906104008301826000855b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161236557905050505050509050915091505b915091565b6123ac615ba2565b60006123b6615ba2565b60008060006123c3615ba2565b60006123ce8b612684565b9650866040518059106123de5750595b90808252806020026020018201604052509550861515612400578597506124d2565b600094508993505b888a0184101561246957600084815260036020526040902054600160a060020a038c81169116141561245e578386868151811061244157fe5b602090810290910101526001909401938685141561245e57612469565b600190930192612408565b8492508260405180591061247a5750595b90808252806020026020018201604052509150600090505b828110156124ce578581815181106124a657fe5b906020019060200201518282815181106124bc57fe5b60209081029091010152600101612492565b8197505b505050505050509392505050565b600160a060020a03331660009081526016602052604090205460ff161561250657600080fd5b61250e6146b3565b600160a060020a03331660008181526016602052604090819020805460ff191660011790557f7c851fc0fcc4001a619b2003815e0f20479a58d6531f22558cd0310326050096905160405180910390a2565b6000806000806000806000806000612576615c33565b600280548c90811061258457fe5b90600052602060002090016101206040519081016040908152915463ffffffff808216835260ff640100000000830481166020850152650100000000008304811694840194909452660100000000000082048416606084015267010000000000000082049093166080830152604060020a8104831660a0830152606060020a8104831660c08301527001000000000000000000000000000000008104831660e083015260a060020a90049091166101008201529050805181602001518260400151836060015184608001518560a001518660c001518760e00151886101000151995099509950995099509950995099509950509193959799909294969850565b600160a060020a031660009081526004602052604090205490565b6000808060ff84168190108015906126ba5750601f60ff8516105b15156126c557600080fd5b600160a060020a033316600090815260016020818152604092839020955061273a9291860191610400905190810160405291906104008301826000855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612702579050505050505061477e565b60018401548454601e60ff9283168102909216830194509114915060029061276f90640100000000900463ffffffff16613450565b63ffffffff1681151561277e57fe5b0463ffffffff168210151561279257600080fd5b60ff841615156127b5578015156127a857600080fd5b6127b06147c1565b612823565b61280f60018401602061040060405190810160405291906104008301826000855b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116127d6579050505050505085614849565b151561281a57600080fd5b612823846148ce565b8360ff1633600160a060020a03167fea78568c50f503c75aac3a8a91853f264679cc034bb197acbda82014fc33924760405160405180910390a350505050565b6000805433600160a060020a0390811691161461287f57600080fd5b5060005b60ff81168290101561114757600f8054600181016128a18382615b6e565b6000928352602092839020909282040190601f16858560ff86168181106128c457fe5b84546101009490940a60ff6020909202939093013581168302920219909216179091555050600101612883565b60005433600160a060020a0390811691161461290c57600080fd5b601a805460ff9092166101000261ff0019909216919091179055565b60005433600160a060020a0390811691161461294357600080fd5b601a805460ff909216650100000000000265ff000000000019909216919091179055565b6000806000612974614927565b151561297f57600080fd5b87925085841461298e57600080fd5b5060009050805b838110156129dc576129d08787838181106129ac57fe5b9050602002013586868481811015156129c157fe5b9050602002013560030b614983565b90910190600101612995565b6129e68383614b4a565b6129f08383614ca5565b5050505050505050565b600090815260036020526040902054600160a060020a0391821691161490565b6000805433600160a060020a03908116911614612a3657600080fd5b60005460a060020a900460ff1615612a4d57600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a908117918290557f3c70af01296aef045b2f5c9d3c30b05d4428fd257145b9c7fcd76418e65b5980910460ff16604051901515815260200160405180910390a150600190565b612abc615ba2565b6000612ac6611873565b9050612ad4836000836123a4565b91505b50919050565b600054600160a060020a031681565b600160a060020a03331660009081526001602052604090205b80546101f463ffffffff90911610612b7057805463ffffffff19811663ffffffff9182166101f3190190911617815533600160a060020a03166000908152601160205260409020805460018101612b5c8382615c7f565b506000918252602090912043910155612b05565b50565b6000806000806000612b83615ba2565b60005460a060020a900460ff1615612b9a57600080fd5b600160a060020a03331660009081526015602052604090205460ff1615612bc057600080fd5b600160a060020a03331660009081526017602052604090205415612be357600080fd5b601454600090620100009004600160a060020a031663f75b8d3c33836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515612c4457600080fd5b6102c65a03f11515612c5557600080fd5b505050604051805190501115612c8c57600160a060020a03331660009081526016602052604090205460ff161515612c8c57600080fd5b601454620100009004600160a060020a03166303339af53360006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515612ceb57600080fd5b6102c65a03f11515612cfc57600080fd5b5050506040518051600160a060020a033316600090815260186020526040812054919850965061ffff90811688039550600990861611159050612d425760099350612d6b565b600160a060020a0333166000908152601560205260409020805460ff1916600190811790915594505b600160a060020a03331660009081526018602052604090205461ffff1692505b600160a060020a03331660009081526018602052604090205461ffff908116850116831015612e5557601454620100009004600160a060020a031663c7d4f68e338560006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515612e1957600080fd5b6102c65a03f11515612e2a57600080fd5b505050604051805190509150612e3f82613bb9565b9050612e4a81613cea565b600190920191612d8b565b33600160a060020a031660008181526018602052604090819020805461ffff19811661ffff9182168901821617918290557f1187f75a7e264b6b37a720a11d5a8f468a83a013736c8974242d690703f1c57b9291169088905161ffff9092168252151560208201526040908101905180910390a2505050505050565b600f805482908110611a6c57fe5b600061159e82612684565b6000805433600160a060020a03908116911614612f0657600080fd5b600160a060020a0382161515612f1b57600080fd5b5060068054600160a060020a031916600160a060020a0392909216919091179055565b612f46615ba2565b60408051908101604052600681527f455448424f5400000000000000000000000000000000000000000000000000006020820152905090565b60008054819060a060020a900460ff1615612f9957600080fd5b600091505b828210156119a357838383818110612fb257fe5b905060200201359050612fc533826129fa565b1515612fd057600080fd5b600081815260056020526040908190208054600160a060020a031916600160a060020a03888116918217909255839290913316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925905160405180910390a4600190910190612f9e565b60005433600160a060020a0390811691161461305557600080fd5b600a55565b60005433600160a060020a0390811691161461307557600080fd5b601a805460ff90921663010000000263ff00000019909216919091179055565b60005433600160a060020a039081169116146130b057600080fd5b6000600d8260ff16815481101515611c5057fe5b60005433600160a060020a039081169116146130df57600080fd5b60078054600181016130f18382615c7f565b5060009182526020909120018054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461313857600080fd5b601a805460ff191660ff92909216919091179055565b6000805460a060020a900460ff161561316657600080fd5b341561317157600080fd5b600160a060020a038316151561318657600080fd5b30600160a060020a031683600160a060020a0316141515156131a757600080fd5b600654600160a060020a03848116911614156131c257600080fd5b5060005b60075481101561320a5760078054829081106131de57fe5b600091825260209091200154600160a060020a038481169116141561320257600080fd5b6001016131c6565b61321433836129fa565b151561321f57600080fd5b611147338484614159565b60075460009081908190881061323f57600080fd5b600086111561328a5761327f33888880806020026020016040519081016040528093929190818152602001838360200280828437506133d4945050505050565b151561328a57600080fd5b600780548990811061329857fe5b6000918252602082200154600160a060020a0316935091505b858210156132e0576132d58787848181106132c857fe5b905060200201358461442f565b6001909101906132b1565b82600160a060020a0316637ab14aae34338a8a8a8a60006040516020015260405160e060020a63ffffffff8916028152600160a060020a03861660048201908152604482018490526064820183905260806024830190815260848301869052909160a401866020870280828437820191505096505050505050506020604051808303818588803b151561337257600080fd5b6125ee5a03f1151561338357600080fd5b505050506040518051905090507ff0a582134eddd90003f142a09c4ca97e099c292be5d8366c0a2217dcbae4e234888260405191825260208201526040908101905180910390a15050505050505050565b60008060008351116133e557600080fd5b5060005b82518110156134465783600160a060020a03166003600085848151811061340c57fe5b906020019060200201518152602081019190915260400160002054600160a060020a03161461343e57600091506120a3565b6001016133e9565b5060019392505050565b6000806103e85b63ffffffff6103e885018116908216116120a3576001909101906103e8820201613457565b6000341561348957600080fd5b50600081815260036020526040902054600160a060020a03166134ac3383614d29565b15156134b757600080fd5b6134c2813384614159565b5050565b6134ce615ba2565b60006134d8611873565b9050612ad48360008361358c565b60125460ff1681565b600160a060020a0333166000908152601960205260408120905b81548110156134c257818181548110151561352057fe5b9060005260206000209060020201600001546000141561355b5743828281548110151561354957fe5b60009182526020909120600290910201555b600101613509565b601254610100900460ff1681565b600090815260036020526040902054600160a060020a031690565b613594615ba2565b60008061359f615ba2565b60006135aa88612684565b935060009250836040518059106135be5750595b908082528060200260200182016040525091508690505b8587018110156136ff57600081815260036020526040902054600160a060020a03898116911614156136f7576136cb60028281548110151561361357fe5b90600052602060002090016101206040519081016040908152915463ffffffff808216835260ff640100000000830481166020850152650100000000008304811694840194909452660100000000000082048416606084015267010000000000000082049093166080830152604060020a8104831660a0830152606060020a8104831660c08301527001000000000000000000000000000000008104831660e083015260a060020a9004909116610100820152614d49565b8284815181106136d757fe5b67ffffffffffffffff199092166020928302909101909101526001909201915b6001016135d5565b509695505050505050565b600160a060020a031660009081526017602052604090205490565b60005433600160a060020a0390811691161461374057600080fd5b6000600e8260ff16815481101515611c5057fe5b600090565b60135481565b6000805433600160a060020a0390811691161461377b57600080fd5b5060005b60ff81168290101561114757601080546001810161379d8382615b6e565b6000928352602092839020909282040190601f16858560ff86168181106137c057fe5b84546101009490940a60ff602090920293909301358116830292021990921617909155505060010161377f565b60005433600160a060020a0390811691161461380857600080fd5b601a805460ff909216620100000262ff000019909216919091179055565b60005433600160a060020a0390811691161461384157600080fd5b61114760088383615ca3565b600d805482908110611a6c57fe5b600360205260009081526040902054600160a060020a031681565b6010805482908110611a6c57fe5b600160a060020a031660009081526019602052604090205490565b600160a060020a03331660009081526011602052604090205490565b60156020526000908152604090205460ff1681565b60005433600160a060020a039081169116146138eb57600080fd5b6103d481116138f957600080fd5b6103e881111561390857600080fd5b600c55565b60005433600160a060020a0390811691161461392857600080fd5b600654600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b151561396757600080fd5b6102c65a03f1151561114757600080fd5b60005433600160a060020a0390811691161461399357600080fd5b600955565b60005433600160a060020a039081169116146139b357600080fd5b60328160ff16101580156139cb5750605a8160ff1611155b15156139d657600080fd5b6012805460ff191660ff92909216919091179055565b60005433600160a060020a03908116911614613a0757600080fd5b600060108260ff16815481101515611c5057fe5b600c5481565b60016020526000908152604090205463ffffffff8082169164010000000090041682565b60005433600160a060020a03908116911614613a6057600080fd5b600160a060020a0381161515613a7557600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614613aee57600080fd5b60145461138861ffff90911610613b0457600080fd5b613b0e8282614e72565b50506014805461ffff8082166001011661ffff1990911617905550565b6000805433600160a060020a03908116911614613b4757600080fd5b5060005b60ff81168290101561114757600d805460018101613b698382615b6e565b6000928352602092839020909282040190601f16858560ff8616818110613b8c57fe5b84546101009490940a60ff6020909202939093013581168302920219909216179091555050600101613b4b565b613bc1615ba2565b6000613bcb615ba2565b600080613bd6615ba2565b6000613be0615ba2565b6064965086604051805910613bf25750595b818152601f19601f830116810160200160405290509550600094505b8815613c5957600a89069350600a890498508360300160f860020a02868680600101975081518110613c3c57fe5b906020010190600160f860020a031916908160001a905350613c0e565b84604051805910613c675750595b818152601f19601f830116810160200160405290509250600091505b84821015613cdd578560018387030381518110613c9c57fe5b016020015160f860020a900460f860020a02838381518110613cba57fe5b906020010190600160f860020a031916908160001a905350600190910190613c83565b5090979650505050505050565b613cf2615d1d565b613cfa615d1d565b613d02615d1d565b613d0a615d1d565b613d138561511d565b9350935093509350613d258433614e72565b50613d308333614e72565b50613d3b8133614e72565b5061186b8233614e72565b613d4e615d1d565b8260405190815260200160405190819003902060ff6001600383160116825292508260405190815260200160405190819003902092506001815160ff161415613ea757613e0983600d805480602002602001604051908101604052809291908181526020018280548015613dff57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411613dd05790505b505050505061536e565b60ff16602080830191909152600d8054613e9a9281810201604051908101604052809291908181526020018280548015613e8057602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411613e515790505b5086935060019250613e90915050565b6020020151615432565b60ff166060820152614129565b6002815160ff161415613f7a57613f1083600e805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152600e8054613e9a9281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b6003815160ff16141561404d57613fe383600f805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152600f8054613e9a9281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b6004815160ff161415614129576140b6836010805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152601080546141209281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b60ff1660608201525b8260405190815260200160405190819003902092506141478361545a565b60ff1660408201526122fa8183614e72565b600160a060020a03808316600081815260046020908152604080832080546001019055858352600390915290208054600160a060020a03191690911790558316156141da57600160a060020a03831660009081526004602090815260408083208054600019019055838352600590915290208054600160a060020a03191690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60008060008061423e86612684565b851061424957600080fd5b60009250614255611873565b9150600090505b818110156142a557600081815260036020526040902054600160a060020a038781169116141561429d5784831415614296578093506142a5565b6001909201915b60010161425c565b50505092915050565b815463ffffffff90811682019061271090821611156142cc57506127105b825463ffffffff191663ffffffff82161783557fb0b2758328bb0b97c2bd520f8d23a040a5a36debb17fe9ecb48d2d215231a02d3383604051600160a060020a03909216825263ffffffff1660208201526040908101905180910390a1505050565b600654614345908290600160a060020a031661442f565b600654600160a060020a03166327ebe40a8261435f615496565b600a54600b543060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156143bf57600080fd5b6102c65a03f115156122fa57600080fd5b600c546103e883061180156143e8575060008160030b135b156143fc576143f78233613d46565b6134c2565b600160a060020a03331660009081526001602052604090206134c290614426600384900b85615521565b61ffff166142ae565b6000918252600560205260409091208054600160a060020a031916600160a060020a03909216919091179055565b614465615ba2565b61446d615c33565b600280548490811061447b57fe5b90600052602060002090016101206040519081016040908152915463ffffffff8082168352640100000000820460ff908116602080860191909152650100000000008404821686860152660100000000000084048216606086015267010000000000000084049091166080850152604060020a8304821660a0850152606060020a8304821660c08501527001000000000000000000000000000000008304821660e085015260a060020a909204166101008084019190915260088054939550612ad49461466d94919360026001841615909402600019019092169290920491601f83018290048202909101905190810160405280929190818152602001828054600181600116156101000203166002900480156145d95780601f106145ae576101008083540402835291602001916145d9565b820191906000526020600020905b8154815290600101906020018083116145bc57829003601f168201915b50505050506145ee846020015160ff16613bb9565b6040805190810160405280600181526020017f2f00000000000000000000000000000000000000000000000000000000000000815250614634866040015160ff16613bb9565b60408051908101604052600181527f2f0000000000000000000000000000000000000000000000000000000000000060208201526155ee565b61467d836060015160ff16613bb9565b602060405190810160405280600081525060206040519081016040528060008152506020604051908101604052600081526155ee565b6014546000908190620100009004600160a060020a031663f75b8d3c33836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561471657600080fd5b6102c65a03f1151561472757600080fd5b5050506040518051925060009150505b818110156134c257600160a060020a03331660009081526017602052604090208054600181016147678382615c7f565b506000918252602090912043910155600101614737565b60008060015b601f60ff821610156147b4578360ff82166020811061479f57fe5b602002015160ff169190910190600101614784565b5063ffffffff1692915050565b600160a060020a0333166000908152600160208190526040909120905b60208160ff16101561482b5760006001830160ff8316602081106147fe57fe5b602091828204019190066101000a81548160ff021916908360ff16021790555080806001019150506147de565b506001908101805460ff19811660ff91821690930116919091179055565b60008060ff83161580614872575060008460ff85166020811061486857fe5b602002015160ff16115b1561488057600091506120a3565b6148898361585e565b90505b600060ff82161115613446578360ff8216602081106148a757fe5b602002015160ff1615156148be57600091506120a3565b6148c78161585e565b905061488c565b600160a060020a0333166000908152600160208181526040909220019060ff83169081106148f857fe5b60208104919091018054601f9092166101000a60ff818102198416938290048116600101160291909117905550565b6000805b60075460ff8216101561497a576007805460ff831690811061494957fe5b60009182526020909120015433600160a060020a0390811691161415614972576001915061497f565b60010161492b565b600091505b5090565b600080600060028581548110151561499757fe5b600091825260209091200180549092506201518060a060020a90910463ffffffff16420311156149fe57815477ffffffff0000000000000000000000000000000000000000191660a060020a4263ffffffff1602176bffffffff0000000000000000191682555b508054600163ffffffff604060020a80840482169290920116026bffffffff000000000000000019909116178155826000600382900b1315614a56578154614a5390604060020a900463ffffffff168561586e565b90505b60008160030b128015614a7d5750815463ffffffff606060020a9091048116828101909116115b15614a9e5781546fffffffff00000000000000000000000019168255611c19565b60008160030b1315614acb57815463ffffffff606060020a909104811682810190911611614acb57600080fd5b80600286815481101515614adb57fe5b9060005260206000209001600001600c9054906101000a900463ffffffff1601600286815481101515614b0a57fe5b6000918252602090912001805463ffffffff92909216606060020a026fffffffff0000000000000000000000001990921691909117905591505092915050565b614b52615d37565b600160a060020a0383166000908152600160205260409081902090606090519081016040908152825463ffffffff80821684526401000000009091041660208084019190915291929181840191600184019190610400905190810160405291906104008301826000855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411614bbc579050505050505081525050905060008260030b128015614c1d5750806020015163ffffffff168282602001510163ffffffff16115b15614c2e5760006020820152611147565b60008260030b1315614c5c57806020015163ffffffff168282602001510163ffffffff1611614c5c57600080fd5b818160200151600160a060020a0385166000908152600160205260409020805463ffffffff93909201929092166401000000000267ffffffff0000000019909116179055505050565b600160a060020a0382166000908152601960205260409020805460018101614ccd8382615d5e565b916000526020600020906002020160006040805190810160405260008152600385900b60208201529190508151815560208201516001909101805460039290920b63ffffffff1663ffffffff1990921691909117905550505050565b600090815260056020526040902054600160a060020a0391821691161490565b6000815163ffffffff16604060020a02905060088167ffffffffffffffff19169060020a029050816020015160ff16604060020a021767ffffffffffffffff191661010002604082015160ff16604060020a021767ffffffffffffffff191661010002606082015160ff16604060020a021767ffffffffffffffff191661010002608082015160ff16604060020a021767ffffffffffffffff19166401000000000260a082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000260c082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000260e082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000261010082015163ffffffff16604060020a0281179050919050565b600080614e7d615c33565b600254915063ffffffff82168214614e9157fe5b61012060405190810160405263ffffffff8316815260208101865160ff168152602001866001602002015160ff168152602001604087015160ff168152602001606087015160ff16815260006020820181905260408201524263ffffffff166060820181905260809091015260028054919250600191808301614f148382615d8a565b600092835260209092208491018151815463ffffffff191663ffffffff919091161781556020820151815460ff919091166401000000000264ff00000000199091161781556040820151815460ff91909116650100000000000265ff0000000000199091161781556060820151815460ff9190911666010000000000000266ff000000000000199091161781556080820151815460ff919091166701000000000000000267ff000000000000001990911617815560a0820151815463ffffffff91909116604060020a026bffffffff00000000000000001990911617815560c0820151815463ffffffff91909116606060020a026fffffffff0000000000000000000000001990911617815560e0820151815463ffffffff919091167001000000000000000000000000000000000273ffffffff0000000000000000000000000000000019909116178155610100820151815477ffffffff0000000000000000000000000000000000000000191660a060020a63ffffffff9283160217909155929091039184169190911490506150a757fe5b7f99a9eb7df2127a857fe5fb402049b72268904b6cd21a7d573413effbfbf98e66848383604051600160a060020a03909316835263ffffffff90911660208301526040808301919091526060909101905180910390a161510f6000858463ffffffff16614159565b5063ffffffff169392505050565b615125615d1d565b61512d615d1d565b615135615d1d565b61513d615d1d565b60038085526000906151549087906005600f6158d6565b60ff166020860152615169866000600361590f565b60ff166040808701919091526151bc908051908101604052600f81527f323132333433313134323334313131000000000000000000000000000000000060208201528660015b602002015160ff1661596a565b60ff166060860152600483526151d7866008600a600b6158d6565b60ff1660208401526151ec866005600861590f565b60ff16604080850191909152615236908051908101604052600b81527f343332313231313334333400000000000000000000000000000000000000000060208201528460016151af565b60ff1660608401526002845261525186600d600f600e6158d6565b60ff16602085015261526686600a600d61590f565b60ff166040808601919091526152b0908051908101604052600e81527f333133323334323231313131343400000000000000000000000000000000000060208201528560016151af565b60ff166060850152600182528551905080601414156152e5576152d88660126014600b6158d6565b60ff166020830152615305565b80601314156152fd576152d88660126013600b6158d6565b600160208301525b61531286600f601261590f565b60ff1660408084019190915261535c908051908101604052600b81527f313234333431333332313400000000000000000000000000000000000000000060208201528360016151af565b60ff1660608301525092949193509190565b600080808060ff85511061538157600080fd5b84519250600060ff84161161539557600080fd5b8260ff16868115156153a357fe5b069150600090505b848260ff16815181106153ba57fe5b9060200190602002015160ff1615156153ff576001918201910160ff80831690841614156153e757600091505b8260ff168160ff1611156153fa576153ff565b6153ab565b848260ff168151811061540e57fe5b9060200190602002015160ff16151561542657600080fd5b50600101949350505050565b600060001982018360ff82168151811061544857fe5b90602001906020020151949350505050565b60006103e882066103de61ffff8216106154775760039150612ad7565b6103ca61ffff82161061548d5760029150612ad7565b60019150612ad7565b60065460009081908190600160a060020a03166325b56dd482604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156154e457600080fd5b6102c65a03f115156154f557600080fd5b5050506040518051925060649050601e8302048201905060095481101561551b57506009545b92915050565b60008060008060006155328761597d565b601a549195509350606487069150640100000000900460ff168111156155735760ff831660148706600c018560ff160281151561556b57fe5b0491506155bc565b601a5465010000000000900460ff168111156155a25760ff8316600a87066006018560ff160281151561556b57fe5b60ff8316600587068560ff16028115156155b857fe5b0491505b601a546301000000900460ff1661ffff831610156155e457601a546301000000900460ff1691505b5095945050505050565b6155f6615ba2565b6155fe615ba2565b615606615ba2565b61560e615ba2565b615616615ba2565b61561e615ba2565b615626615ba2565b61562e615ba2565b6000808e98508d97508c96508b95508a94508451865188518a518c510101010160405180591061565b5750595b818152601f19601f83011681016020016040529050935083925060009150600090505b88518110156156d75788818151811061569357fe5b016020015160f860020a900460f860020a028383806001019450815181106156b757fe5b906020010190600160f860020a031916908160001a90535060010161567e565b5060005b8751811015615734578781815181106156f057fe5b016020015160f860020a900460f860020a0283838060010194508151811061571457fe5b906020010190600160f860020a031916908160001a9053506001016156db565b5060005b86518110156157915786818151811061574d57fe5b016020015160f860020a900460f860020a0283838060010194508151811061577157fe5b906020010190600160f860020a031916908160001a905350600101615738565b5060005b85518110156157ee578581815181106157aa57fe5b016020015160f860020a900460f860020a028383806001019450815181106157ce57fe5b906020010190600160f860020a031916908160001a905350600101615795565b5060005b845181101561584b5784818151811061580757fe5b016020015160f860020a900460f860020a0283838060010194508151811061582b57fe5b906020010190600160f860020a031916908160001a9053506001016157f2565b50909d9c50505050505050505050505050565b60026000199190910160ff160490565b600080600a63ffffffff851611615887578291506120a3565b8360030b83600a0260030b81151561589b57fe5b059050601a60069054906101000a900460000b60000b8160030b1215611a9c57601a5466010000000000009004600090810b900b91506120a3565b60008160ff166158f56158f0878760ff168760ff166159d7565b615a73565b60ff1681151561590157fe5b066001019050949350505050565b60008061592b615926868660ff168660ff166159d7565b615a7a565b90506103b663ffffffff8216106159455760039150615962565b61035263ffffffff82161061595d5760029150615962565b600191505b509392505050565b6000611a9c6158f08460018503856159d7565b6000806101f48313156159a0575050601a5460ff8082169161010090041661239f565b60008313156159bc575050601a54610100900460ff168061239f565b5050601a5460ff62010000820481169161010090041661239f565b6159df615ba2565b6159e7615ba2565b6159ef615ba2565b6000869250858503604051805910615a045750595b818152601f19601f8301168101602001604052905091508590505b848110156155e457828181518110615a3357fe5b016020015160f860020a900460f860020a028287830381518110615a5357fe5b906020010190600160f860020a031916908160001a905350600101615a1f565b600061159e825b6000615a84615ba2565b50816000805b8251811015615962577f3000000000000000000000000000000000000000000000000000000000000000838281518110615ac057fe5b016020015160f860020a900460f860020a02600160f860020a03191610158015615b3157507f3900000000000000000000000000000000000000000000000000000000000000838281518110615b1257fe5b016020015160f860020a900460f860020a02600160f860020a03191611155b15615b66576030838281518110615b4457fe5b016020015160f860020a900460f860020a0260f860020a90040382600a020191505b600101615a8a565b81548183558181151161114757601f016020900481601f016020900483600052602060002091820191016111479190615dae565b60206040519081016040526000815290565b5080546000825590600052602060002090810190612b709190615dae565b604080519081016040526000808252602082015290565b5080546000825560020290600052602060002090810190612b709190615dc8565b6104006040519081016040526020815b600081526000199091019060200181615c1a5790505090565b6101206040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015290565b81548183558181151161114757600083815260209020611147918101908301615dae565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615ce45782800160ff19823516178555615d11565b82800160010185558215615d11579182015b82811115615d11578235825591602001919060010190615cf6565b5061497f929150615dae565b608060405190810160405260008152600360208201615c1a565b6104406040519081016040908152600080835260208301528101615d59615c0a565b905290565b815481835581811511611147576002028160020283600052602060002091820191016111479190615dc8565b81548183558181151161114757600083815260209020611147918101908301615df1565b61161091905b8082111561497f5760008155600101615db4565b61161091905b8082111561497f576000815560018101805463ffffffff19169055600201615dce565b61161091905b8082111561497f57805477ffffffffffffffffffffffffffffffffffffffffffffffff19168155600101615df75600a165627a7a723058207f063563e63c5eda5b27124329d52607b44bb025da896c34ebb70ac13a6503b80029

Deployed Bytecode

0x6060604052600436106104465763ffffffff60e060020a600035041662c8bb45811461044857806301aef7551461046657806301ffc9a71461047f57806305d78739146104cb57806306edcd241461050157806306fdde0314610520578063095ea7b3146105aa5780631051db34146105c157806311f43157146105d4578063139020d1146105e757806318160ddd1461060f57806318f95486146106225780631e42698b1461063557806323b872dd1461064b578063293100a9146106735780632f745c591461069f57806331a06772146106c157806332fb082f146106d7578063360c9ed0146106f55780633832677d1461070e5780633dde1598146107215780633f4ba83a14610734578063431f21da14610747578063434f811b146107665780634584117e14610798578063532709101461069f5780635c629788146107be5780635c975abb146108265780635eb08d8a146108395780635fd8c710146108525780636099ecb2146108655780636352211e146108a6578063651738a3146108bc57806367025dcf146108d55780636914db601461092757806369c212f61461093d5780636b68dd4b146109a25780636ce76ae314610a055780636ea34ce414610a1857806370a0823114610a91578063731ac7ed14610ab057806375ec899a14610ac957806377289b5014610ae7578063787b586f14610b00578063794b0e6b14610b19578063818d4b5d14610b505780638456cb5914610b725780638462151c14610b855780638da5cb5b14610ba45780638e92ee6614610bb75780638fd3ab8014610bca5780639028f20b14610bdd57806392efd27714610bf357806393ac363814610c1257806395d89b4114610c3157806399bb813414610c445780639b7eeb1214610c645780639e3249ab14610c7a5780639f7d9f6214610c935780639fbf538f14610cac578063a7c591c414610ccb578063a9059cbb14610ce4578063ab0db22014610cfb578063ad94d90114610d18578063b2cad9b714610d75578063b2e6ceeb14610d91578063b74e47ac14610d9c578063b87e461c14610dbb578063b95d2a5314610927578063bbf48d6f14610dce578063bed9985014610de1578063c04d90d014610df4578063c2fce71814610e0a578063c34588ba1461060f578063c500ea3614610e2f578063c87c07de14610e4e578063cd9a1fa614610e67578063ce78421614610e7a578063ce813d8f14610e8d578063d2ed2d3014610eab578063d3811c0f14610ec4578063d3b6ac9714610ee2578063d3cdb97b14610ef8578063d45973f414610f0e578063d479832714610f24578063d489e18014610f43578063d7625c8814610f56578063d7e31d6714610f75578063d8eb3a9814610f8b578063dae6f08114610f9e578063dfdce77b14610fb4578063e4f843f914610fcd578063ed06fb9114610fe6578063edf5388614610ff9578063f2fde38b14611039578063f379491414611058578063f794e7f21461109b575b005b341561045357600080fd5b61044660048035602481019101356110b9565b341561047157600080fd5b61044660ff6004351661114c565b341561048a57600080fd5b6104b77fffffffff0000000000000000000000000000000000000000000000000000000060043516611189565b604051901515815260200160405180910390f35b34156104d657600080fd5b6104ea600160a060020a03600435166115a6565b60405161ffff909116815260200160405180910390f35b341561050c57600080fd5b6104b7600160a060020a03600435166115bc565b341561052b57600080fd5b6105336115d1565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561056f578082015183820152602001610557565b50505050905090810190601f16801561059c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610446600160a060020a0360043516602435611613565b34156105cc57600080fd5b6104b76116ad565b34156105df57600080fd5b6104466116b2565b34156105f257600080fd5b6105fd600435611610565b60405190815260200160405180910390f35b341561061a57600080fd5b6105fd611873565b341561062d57600080fd5b610446611879565b341561064057600080fd5b6104466004356119aa565b341561065657600080fd5b610446600160a060020a03600435811690602435166044356119ca565b341561067e57600080fd5b610689600435611a5e565b60405160ff909116815260200160405180910390f35b34156106aa57600080fd5b6105fd600160a060020a0360043516602435611a90565b34156106cc57600080fd5b610446600435611aa3565b34156106e257600080fd5b6104b76004803560248101910135611ba1565b341561070057600080fd5b61044660ff60043516611c21565b341561071957600080fd5b6104ea611c7d565b341561072c57600080fd5b610446611c87565b341561073f57600080fd5b6104b7611dfd565b341561075257600080fd5b610446600435602435604435606435611e96565b341561077157600080fd5b61077c600435611f62565b604051600160a060020a03909116815260200160405180910390f35b34156107a357600080fd5b61044661ffff60043516600160a060020a0360243516611f7d565b34156107c957600080fd5b61080d600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061204695505050505050565b60405163ffffffff909116815260200160405180910390f35b341561083157600080fd5b6104b76120aa565b341561084457600080fd5b61044660ff600435166120ba565b341561085d57600080fd5b6104466120f1565b341561087057600080fd5b610887600160a060020a0360043516602435612147565b604051918252600390810b900b60208201526040908101905180910390f35b34156108b157600080fd5b61077c600435612185565b34156108c757600080fd5b61044660043560000b6121a9565b61044660048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437509496506121ee95505050505050565b341561093257600080fd5b610533600435612300565b341561094857600080fd5b61095c600160a060020a0360043516612311565b60405163ffffffff83168152602081018261040080838360005b8381101561098e578082015183820152602001610976565b505050509050019250505060405180910390f35b34156109ad57600080fd5b6109c7600160a060020a03600435166024356044356123a4565b60405160208082528190810183818151815260200191508051906020019060200280838360008381101561098e578082015183820152602001610976565b3415610a1057600080fd5b6104466124e0565b3415610a2357600080fd5b610a2e600435612560565b60405163ffffffff998a16815260ff9889166020820152968816604080890191909152958816606088015293909616608086015290861660a0850152851660c084015292841660e083015291909216610100830152610120909101905180910390f35b3415610a9c57600080fd5b6105fd600160a060020a0360043516612684565b3415610abb57600080fd5b61044660ff6004351661269f565b3415610ad457600080fd5b6104466004803560248101910135612863565b3415610af257600080fd5b61044660ff600435166128f1565b3415610b0b57600080fd5b61044660ff60043516612928565b3415610b2457600080fd5b61044660048035600160a060020a03169060248035808201929081013591604435908101910135612967565b3415610b5b57600080fd5b6104b7600160a060020a03600435166024356129fa565b3415610b7d57600080fd5b6104b7612a1a565b3415610b9057600080fd5b6109c7600160a060020a0360043516612ab4565b3415610baf57600080fd5b61077c612add565b3415610bc257600080fd5b610446612aec565b3415610bd557600080fd5b610446612b73565b3415610be857600080fd5b610689600435612ed1565b3415610bfe57600080fd5b6105fd600160a060020a0360043516612edf565b3415610c1d57600080fd5b610446600160a060020a0360043516612eea565b3415610c3c57600080fd5b610533612f3e565b61044660048035600160a060020a03169060248035908101910135612f7f565b3415610c6f57600080fd5b61044660043561303a565b3415610c8557600080fd5b61044660ff6004351661305a565b3415610c9e57600080fd5b61044660ff60043516613095565b3415610cb757600080fd5b610446600160a060020a03600435166130c4565b3415610cd657600080fd5b61044660ff6004351661311d565b610446600160a060020a036004351660243561314e565b61044660048035906024803590810191013560443560643561322a565b3415610d2357600080fd5b6104b760048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437509496506133d495505050505050565b3415610d8057600080fd5b61080d63ffffffff60043516613450565b61044660043561347c565b3415610da757600080fd5b6109c7600160a060020a03600435166134c6565b3415610dc657600080fd5b6106896134e6565b3415610dd957600080fd5b6104466134ef565b3415610dec57600080fd5b610689613563565b3415610dff57600080fd5b61077c600435613571565b3415610e1557600080fd5b6109c7600160a060020a036004351660243560443561358c565b3415610e3a57600080fd5b6105fd600160a060020a036004351661370a565b3415610e5957600080fd5b61044660ff60043516613725565b3415610e7257600080fd5b6105fd613754565b3415610e8557600080fd5b6105fd613759565b3415610e9857600080fd5b610446600480356024810191013561375f565b3415610eb657600080fd5b61044660ff600435166137ed565b3415610ecf57600080fd5b6104466004803560248101910135613826565b3415610eed57600080fd5b61068960043561384d565b3415610f0357600080fd5b61077c60043561385b565b3415610f1957600080fd5b610689600435613876565b3415610f2f57600080fd5b6105fd600160a060020a0360043516613884565b3415610f4e57600080fd5b6105fd61389f565b3415610f6157600080fd5b6104b7600160a060020a03600435166138bb565b3415610f8057600080fd5b6104466004356138d0565b3415610f9657600080fd5b61044661390d565b3415610fa957600080fd5b610446600435613978565b3415610fbf57600080fd5b61044660ff60043516613998565b3415610fd857600080fd5b61044660ff600435166139ec565b3415610ff157600080fd5b6105fd613a1b565b341561100457600080fd5b611018600160a060020a0360043516613a21565b60405163ffffffff9283168152911660208201526040908101905180910390f35b341561104457600080fd5b610446600160a060020a0360043516613a45565b341561106357600080fd5b6104466004608481806080604051908101604052919082826080808284375093955050509135600160a060020a03169150613ad39050565b34156110a657600080fd5b6104466004803560248101910135613b2b565b6000805433600160a060020a039081169116146110d557600080fd5b5060005b60ff81168290101561114757600e8054600181016110f78382615b6e565b6000928352602092839020909282040190601f16858560ff861681811061111a57fe5b84546101009490940a60ff60209092029390930135811683029202199092161790915550506001016110d9565b505050565b60005433600160a060020a0390811691161461116757600080fd5b601a805460ff9092166401000000000264ff0000000019909216919091179055565b60006040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f74616b654f776e6572736869702875696e743235362900000000000000000000815260160160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390201818181818600160e060020a03191682600160e060020a031916148061143a57506040517f74616b654f776e6572736869702875696e743235362900000000000000000000815260160160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f646565644f664f776e65724279496e64657828616464726573732c75696e743281527f3536290000000000000000000000000000000000000000000000000000000000602082015260230160405180910390206040517f636f756e744f66446565647342794f776e6572286164647265737329000000008152601c0160405180910390206040517f636f756e744f66446565647328290000000000000000000000000000000000008152600e0160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390201818181818600160e060020a03191682600160e060020a031916145b806114ec57506040517f646565645572692875696e743235362900000000000000000000000000000000815260100160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d6528290000000000000000000000000000000000000000000000000000815260060160405180910390201818600160e060020a03191682600160e060020a031916145b8061159e57506040517f6f776e65724279496e6465782875696e74323536290000000000000000000000815260150160405180910390206040517f636f756e744f664f776e657273282900000000000000000000000000000000008152600f0160405180910390206040517f646565644279496e6465782829000000000000000000000000000000000000008152600d0160405180910390201818600160e060020a03191682600160e060020a031916145b90505b919050565b60186020526000908152604090205461ffff1681565b60166020526000908152604090205460ff1681565b6115d9615ba2565b60408051908101604052600981527f4574686572626f74730000000000000000000000000000000000000000000000602082015290505b90565b60005460a060020a900460ff161561162a57600080fd5b341561163557600080fd5b61163f33826129fa565b151561164a57600080fd5b600081815260056020526040908190208054600160a060020a031916600160a060020a03858116918217909255839290913316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925905160405180910390a45050565b600190565b6116ba615ba2565b60008054819081908190819060a060020a900460ff16156116da57600080fd5b6017600033600160a060020a0316600160a060020a0316815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561174957602002820191906000526020600020905b815481526020019060010190808311611735575b50505050509550600086511161175e57600080fd5b60009450600093505b85518410156118095785848151811061177c57fe5b9060200190602002015192504383901161179557600080fd5b8240915081156117fe5768056bc75e2d63100000823386604051928352600160a060020a0391909116606060020a02602083015260348201526054016040519081900390208115156117e357fe5b0690506117f76117f282613bb9565b613cea565b6001909401935b600190930192611767565b33600160a060020a03167fa724f68a4b67886764af4c4780d0d8bf6b9d3d93579e07d9f0d6c2c8184252bc8660405160ff909116815260200160405180910390a2600160a060020a033316600090815260176020526040812061186b91615bb4565b505050505050565b60025490565b611881615ba2565b6000806000806011600033600160a060020a0316600160a060020a031681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156118f657602002820191906000526020600020905b8154815260200190600101908083116118e2575b50505050509450600093505b84518410156119825784848151811061191757fe5b9060200190602002015192504383901161193057600080fd5b82409150811561197757813385604051928352600160a060020a0391909116606060020a026020830152603482015260540160405190819003902090506119778133613d46565b600190930192611902565b600160a060020a03331660009081526011602052604081206119a391615bb4565b5050505050565b60005433600160a060020a039081169116146119c557600080fd5b600b55565b60005460a060020a900460ff16156119e157600080fd5b600160a060020a03821615156119f657600080fd5b30600160a060020a031682600160a060020a031614151515611a1757600080fd5b60008181526005602052604090205433600160a060020a03908116911614611a3e57600080fd5b611a4883826129fa565b1515611a5357600080fd5b611147838383614159565b600e805482908110611a6c57fe5b9060005260206000209060209182820401919006915054906101000a900460ff1681565b6000611a9c838361422f565b9392505050565b6000611aaf33836129fa565b1515611aba57600080fd5b5033600160a060020a03166000908152600160205260409020601254611af290829060649060ff166101f40263ffffffff16046142ae565b7fa1bee4ee172df140536bfc9c59145139b284507b6253b143f5d44fd19c2982983383604051600160a060020a03909216825260208201526040908101905180910390a1601260019054906101000a900460ff1660ff166064601354604051908152602001604051908190039020811515611b6957fe5b0610611b8857611b7a333084614159565b611b838261432e565b611b94565b611b9433600084614159565b5050601380546001019055565b6000818160048214611bb65760009250611c19565b5060005b81811015611c1457600181016002868684818110611bd457fe5b90506020020135815481101515611be757fe5b600091825260209091200154640100000000900460ff1614611c0c5760009250611c19565b600101611bba565b600192505b505092915050565b60005433600160a060020a03908116911614611c3c57600080fd5b6000600f8260ff16815481101515611c5057fe5b90600052602060002090602091828204019190066101000a81548160ff021916908360ff16021790555050565b60145461ffff1681565b6000806000611c94615bd2565b600160a060020a03331660009081526019602052604081205490945092508380808511611cc057600080fd5b600093505b84841015611d9b57600160a060020a0333166000908152601960205260409020805485908110611cf157fe5b90600052602060002090600202016040805190810160405281548152600190910154600390810b810b900b6020820152925082514311611d3057600080fd5b82511515611d3d57600080fd5b82514091508115611d9057813385604051928352600160a060020a0391909116606060020a02602083015260348201526054016040519081900390209050611d898160208501516143d0565b6001909501945b600190930192611cc5565b33600160a060020a03167fa724f68a4b67886764af4c4780d0d8bf6b9d3d93579e07d9f0d6c2c8184252bc8760405160ff909116815260200160405180910390a2600160a060020a033316600090815260196020526040812061186b91615be9565b6000805433600160a060020a03908116911614611e1957600080fd5b60005460a060020a900460ff161515611e3157600080fd5b6000805474ff00000000000000000000000000000000000000001916908190557f3c70af01296aef045b2f5c9d3c30b05d4428fd257145b9c7fcd76418e65b59809060a060020a900460ff16604051901515815260200160405180910390a150600190565b60005460a060020a900460ff1615611ead57600080fd5b611eb733856129fa565b1515611ec257600080fd5b600654611ed9908590600160a060020a031661442f565b600654600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b1515611f4857600080fd5b6102c65a03f11515611f5957600080fd5b50505050505050565b600560205260009081526040902054600160a060020a031681565b60005433600160a060020a03908116911614611f9857600080fd5b60008261ffff16118015611fb1575060328261ffff1611155b1515611fbc57600080fd5b60145461ffff90811683810190911611611fd557600080fd5b60145461138861ffff918216840190911610611ff057600080fd5b600160a060020a03166000908152600160205260409020805463ffffffff19811661ffff8481166101f40263ffffffff93841601909216179091556014805461ffff198116908316909301909116919091179055565b600080805b83518110156120a357612097600285838151811061206557fe5b906020019060200201518154811061207957fe5b600091825260209091200154606060020a900463ffffffff16613450565b9091019060010161204b565b5092915050565b60005460a060020a900460ff1681565b60005433600160a060020a039081169116146120d557600080fd5b6012805460ff9092166101000261ff0019909216919091179055565b60005433600160a060020a0390811691161461210c57600080fd5b600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050151561214557600080fd5b565b60196020528160005260406000208181548110151561216257fe5b60009182526020909120600290910201805460019091015490925060030b905082565b600081815260036020526040902054600160a060020a03168015156115a157600080fd5b60005433600160a060020a039081169116146121c457600080fd5b601a805460009290920b60ff1666010000000000000266ff00000000000019909216919091179055565b60008054819060a060020a900460ff161561220857600080fd5b341561221357600080fd5b600160a060020a038416151561222857600080fd5b30600160a060020a031684600160a060020a03161415151561224957600080fd5b600654600160a060020a038581169116141561226457600080fd5b600091505b6007548210156122b057600780548390811061228157fe5b600091825260209091200154600160a060020a03858116911614156122a557600080fd5b600190910190612269565b6122ba33846133d4565b15156122c557600080fd5b5060005b82518110156122fa576122f233858584815181106122e357fe5b90602001906020020151614159565b6001016122c9565b50505050565b612308615ba2565b61159e8261445d565b600061231b615c0a565b600160a060020a0383166000908152600160208181526040928390208054640100000000900463ffffffff1693920191829190610400905190810160405291906104008301826000855b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161236557905050505050509050915091505b915091565b6123ac615ba2565b60006123b6615ba2565b60008060006123c3615ba2565b60006123ce8b612684565b9650866040518059106123de5750595b90808252806020026020018201604052509550861515612400578597506124d2565b600094508993505b888a0184101561246957600084815260036020526040902054600160a060020a038c81169116141561245e578386868151811061244157fe5b602090810290910101526001909401938685141561245e57612469565b600190930192612408565b8492508260405180591061247a5750595b90808252806020026020018201604052509150600090505b828110156124ce578581815181106124a657fe5b906020019060200201518282815181106124bc57fe5b60209081029091010152600101612492565b8197505b505050505050509392505050565b600160a060020a03331660009081526016602052604090205460ff161561250657600080fd5b61250e6146b3565b600160a060020a03331660008181526016602052604090819020805460ff191660011790557f7c851fc0fcc4001a619b2003815e0f20479a58d6531f22558cd0310326050096905160405180910390a2565b6000806000806000806000806000612576615c33565b600280548c90811061258457fe5b90600052602060002090016101206040519081016040908152915463ffffffff808216835260ff640100000000830481166020850152650100000000008304811694840194909452660100000000000082048416606084015267010000000000000082049093166080830152604060020a8104831660a0830152606060020a8104831660c08301527001000000000000000000000000000000008104831660e083015260a060020a90049091166101008201529050805181602001518260400151836060015184608001518560a001518660c001518760e00151886101000151995099509950995099509950995099509950509193959799909294969850565b600160a060020a031660009081526004602052604090205490565b6000808060ff84168190108015906126ba5750601f60ff8516105b15156126c557600080fd5b600160a060020a033316600090815260016020818152604092839020955061273a9291860191610400905190810160405291906104008301826000855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612702579050505050505061477e565b60018401548454601e60ff9283168102909216830194509114915060029061276f90640100000000900463ffffffff16613450565b63ffffffff1681151561277e57fe5b0463ffffffff168210151561279257600080fd5b60ff841615156127b5578015156127a857600080fd5b6127b06147c1565b612823565b61280f60018401602061040060405190810160405291906104008301826000855b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116127d6579050505050505085614849565b151561281a57600080fd5b612823846148ce565b8360ff1633600160a060020a03167fea78568c50f503c75aac3a8a91853f264679cc034bb197acbda82014fc33924760405160405180910390a350505050565b6000805433600160a060020a0390811691161461287f57600080fd5b5060005b60ff81168290101561114757600f8054600181016128a18382615b6e565b6000928352602092839020909282040190601f16858560ff86168181106128c457fe5b84546101009490940a60ff6020909202939093013581168302920219909216179091555050600101612883565b60005433600160a060020a0390811691161461290c57600080fd5b601a805460ff9092166101000261ff0019909216919091179055565b60005433600160a060020a0390811691161461294357600080fd5b601a805460ff909216650100000000000265ff000000000019909216919091179055565b6000806000612974614927565b151561297f57600080fd5b87925085841461298e57600080fd5b5060009050805b838110156129dc576129d08787838181106129ac57fe5b9050602002013586868481811015156129c157fe5b9050602002013560030b614983565b90910190600101612995565b6129e68383614b4a565b6129f08383614ca5565b5050505050505050565b600090815260036020526040902054600160a060020a0391821691161490565b6000805433600160a060020a03908116911614612a3657600080fd5b60005460a060020a900460ff1615612a4d57600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a908117918290557f3c70af01296aef045b2f5c9d3c30b05d4428fd257145b9c7fcd76418e65b5980910460ff16604051901515815260200160405180910390a150600190565b612abc615ba2565b6000612ac6611873565b9050612ad4836000836123a4565b91505b50919050565b600054600160a060020a031681565b600160a060020a03331660009081526001602052604090205b80546101f463ffffffff90911610612b7057805463ffffffff19811663ffffffff9182166101f3190190911617815533600160a060020a03166000908152601160205260409020805460018101612b5c8382615c7f565b506000918252602090912043910155612b05565b50565b6000806000806000612b83615ba2565b60005460a060020a900460ff1615612b9a57600080fd5b600160a060020a03331660009081526015602052604090205460ff1615612bc057600080fd5b600160a060020a03331660009081526017602052604090205415612be357600080fd5b601454600090620100009004600160a060020a031663f75b8d3c33836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515612c4457600080fd5b6102c65a03f11515612c5557600080fd5b505050604051805190501115612c8c57600160a060020a03331660009081526016602052604090205460ff161515612c8c57600080fd5b601454620100009004600160a060020a03166303339af53360006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515612ceb57600080fd5b6102c65a03f11515612cfc57600080fd5b5050506040518051600160a060020a033316600090815260186020526040812054919850965061ffff90811688039550600990861611159050612d425760099350612d6b565b600160a060020a0333166000908152601560205260409020805460ff1916600190811790915594505b600160a060020a03331660009081526018602052604090205461ffff1692505b600160a060020a03331660009081526018602052604090205461ffff908116850116831015612e5557601454620100009004600160a060020a031663c7d4f68e338560006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515612e1957600080fd5b6102c65a03f11515612e2a57600080fd5b505050604051805190509150612e3f82613bb9565b9050612e4a81613cea565b600190920191612d8b565b33600160a060020a031660008181526018602052604090819020805461ffff19811661ffff9182168901821617918290557f1187f75a7e264b6b37a720a11d5a8f468a83a013736c8974242d690703f1c57b9291169088905161ffff9092168252151560208201526040908101905180910390a2505050505050565b600f805482908110611a6c57fe5b600061159e82612684565b6000805433600160a060020a03908116911614612f0657600080fd5b600160a060020a0382161515612f1b57600080fd5b5060068054600160a060020a031916600160a060020a0392909216919091179055565b612f46615ba2565b60408051908101604052600681527f455448424f5400000000000000000000000000000000000000000000000000006020820152905090565b60008054819060a060020a900460ff1615612f9957600080fd5b600091505b828210156119a357838383818110612fb257fe5b905060200201359050612fc533826129fa565b1515612fd057600080fd5b600081815260056020526040908190208054600160a060020a031916600160a060020a03888116918217909255839290913316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925905160405180910390a4600190910190612f9e565b60005433600160a060020a0390811691161461305557600080fd5b600a55565b60005433600160a060020a0390811691161461307557600080fd5b601a805460ff90921663010000000263ff00000019909216919091179055565b60005433600160a060020a039081169116146130b057600080fd5b6000600d8260ff16815481101515611c5057fe5b60005433600160a060020a039081169116146130df57600080fd5b60078054600181016130f18382615c7f565b5060009182526020909120018054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461313857600080fd5b601a805460ff191660ff92909216919091179055565b6000805460a060020a900460ff161561316657600080fd5b341561317157600080fd5b600160a060020a038316151561318657600080fd5b30600160a060020a031683600160a060020a0316141515156131a757600080fd5b600654600160a060020a03848116911614156131c257600080fd5b5060005b60075481101561320a5760078054829081106131de57fe5b600091825260209091200154600160a060020a038481169116141561320257600080fd5b6001016131c6565b61321433836129fa565b151561321f57600080fd5b611147338484614159565b60075460009081908190881061323f57600080fd5b600086111561328a5761327f33888880806020026020016040519081016040528093929190818152602001838360200280828437506133d4945050505050565b151561328a57600080fd5b600780548990811061329857fe5b6000918252602082200154600160a060020a0316935091505b858210156132e0576132d58787848181106132c857fe5b905060200201358461442f565b6001909101906132b1565b82600160a060020a0316637ab14aae34338a8a8a8a60006040516020015260405160e060020a63ffffffff8916028152600160a060020a03861660048201908152604482018490526064820183905260806024830190815260848301869052909160a401866020870280828437820191505096505050505050506020604051808303818588803b151561337257600080fd5b6125ee5a03f1151561338357600080fd5b505050506040518051905090507ff0a582134eddd90003f142a09c4ca97e099c292be5d8366c0a2217dcbae4e234888260405191825260208201526040908101905180910390a15050505050505050565b60008060008351116133e557600080fd5b5060005b82518110156134465783600160a060020a03166003600085848151811061340c57fe5b906020019060200201518152602081019190915260400160002054600160a060020a03161461343e57600091506120a3565b6001016133e9565b5060019392505050565b6000806103e85b63ffffffff6103e885018116908216116120a3576001909101906103e8820201613457565b6000341561348957600080fd5b50600081815260036020526040902054600160a060020a03166134ac3383614d29565b15156134b757600080fd5b6134c2813384614159565b5050565b6134ce615ba2565b60006134d8611873565b9050612ad48360008361358c565b60125460ff1681565b600160a060020a0333166000908152601960205260408120905b81548110156134c257818181548110151561352057fe5b9060005260206000209060020201600001546000141561355b5743828281548110151561354957fe5b60009182526020909120600290910201555b600101613509565b601254610100900460ff1681565b600090815260036020526040902054600160a060020a031690565b613594615ba2565b60008061359f615ba2565b60006135aa88612684565b935060009250836040518059106135be5750595b908082528060200260200182016040525091508690505b8587018110156136ff57600081815260036020526040902054600160a060020a03898116911614156136f7576136cb60028281548110151561361357fe5b90600052602060002090016101206040519081016040908152915463ffffffff808216835260ff640100000000830481166020850152650100000000008304811694840194909452660100000000000082048416606084015267010000000000000082049093166080830152604060020a8104831660a0830152606060020a8104831660c08301527001000000000000000000000000000000008104831660e083015260a060020a9004909116610100820152614d49565b8284815181106136d757fe5b67ffffffffffffffff199092166020928302909101909101526001909201915b6001016135d5565b509695505050505050565b600160a060020a031660009081526017602052604090205490565b60005433600160a060020a0390811691161461374057600080fd5b6000600e8260ff16815481101515611c5057fe5b600090565b60135481565b6000805433600160a060020a0390811691161461377b57600080fd5b5060005b60ff81168290101561114757601080546001810161379d8382615b6e565b6000928352602092839020909282040190601f16858560ff86168181106137c057fe5b84546101009490940a60ff602090920293909301358116830292021990921617909155505060010161377f565b60005433600160a060020a0390811691161461380857600080fd5b601a805460ff909216620100000262ff000019909216919091179055565b60005433600160a060020a0390811691161461384157600080fd5b61114760088383615ca3565b600d805482908110611a6c57fe5b600360205260009081526040902054600160a060020a031681565b6010805482908110611a6c57fe5b600160a060020a031660009081526019602052604090205490565b600160a060020a03331660009081526011602052604090205490565b60156020526000908152604090205460ff1681565b60005433600160a060020a039081169116146138eb57600080fd5b6103d481116138f957600080fd5b6103e881111561390857600080fd5b600c55565b60005433600160a060020a0390811691161461392857600080fd5b600654600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b151561396757600080fd5b6102c65a03f1151561114757600080fd5b60005433600160a060020a0390811691161461399357600080fd5b600955565b60005433600160a060020a039081169116146139b357600080fd5b60328160ff16101580156139cb5750605a8160ff1611155b15156139d657600080fd5b6012805460ff191660ff92909216919091179055565b60005433600160a060020a03908116911614613a0757600080fd5b600060108260ff16815481101515611c5057fe5b600c5481565b60016020526000908152604090205463ffffffff8082169164010000000090041682565b60005433600160a060020a03908116911614613a6057600080fd5b600160a060020a0381161515613a7557600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614613aee57600080fd5b60145461138861ffff90911610613b0457600080fd5b613b0e8282614e72565b50506014805461ffff8082166001011661ffff1990911617905550565b6000805433600160a060020a03908116911614613b4757600080fd5b5060005b60ff81168290101561114757600d805460018101613b698382615b6e565b6000928352602092839020909282040190601f16858560ff8616818110613b8c57fe5b84546101009490940a60ff6020909202939093013581168302920219909216179091555050600101613b4b565b613bc1615ba2565b6000613bcb615ba2565b600080613bd6615ba2565b6000613be0615ba2565b6064965086604051805910613bf25750595b818152601f19601f830116810160200160405290509550600094505b8815613c5957600a89069350600a890498508360300160f860020a02868680600101975081518110613c3c57fe5b906020010190600160f860020a031916908160001a905350613c0e565b84604051805910613c675750595b818152601f19601f830116810160200160405290509250600091505b84821015613cdd578560018387030381518110613c9c57fe5b016020015160f860020a900460f860020a02838381518110613cba57fe5b906020010190600160f860020a031916908160001a905350600190910190613c83565b5090979650505050505050565b613cf2615d1d565b613cfa615d1d565b613d02615d1d565b613d0a615d1d565b613d138561511d565b9350935093509350613d258433614e72565b50613d308333614e72565b50613d3b8133614e72565b5061186b8233614e72565b613d4e615d1d565b8260405190815260200160405190819003902060ff6001600383160116825292508260405190815260200160405190819003902092506001815160ff161415613ea757613e0983600d805480602002602001604051908101604052809291908181526020018280548015613dff57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411613dd05790505b505050505061536e565b60ff16602080830191909152600d8054613e9a9281810201604051908101604052809291908181526020018280548015613e8057602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411613e515790505b5086935060019250613e90915050565b6020020151615432565b60ff166060820152614129565b6002815160ff161415613f7a57613f1083600e805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152600e8054613e9a9281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b6003815160ff16141561404d57613fe383600f805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152600f8054613e9a9281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b6004815160ff161415614129576140b6836010805480602002602001604051908101604052809291908181526020018280548015613dff576000918252602091829020805460ff168452908202830192909160019101808411613dd0579050505050505061536e565b60ff16602080830191909152601080546141209281810201604051908101604052809291908181526020018280548015613e80576000918252602091829020805460ff168452908202830192909160019101808411613e51575087945060019350613e9092505050565b60ff1660608201525b8260405190815260200160405190819003902092506141478361545a565b60ff1660408201526122fa8183614e72565b600160a060020a03808316600081815260046020908152604080832080546001019055858352600390915290208054600160a060020a03191690911790558316156141da57600160a060020a03831660009081526004602090815260408083208054600019019055838352600590915290208054600160a060020a03191690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60008060008061423e86612684565b851061424957600080fd5b60009250614255611873565b9150600090505b818110156142a557600081815260036020526040902054600160a060020a038781169116141561429d5784831415614296578093506142a5565b6001909201915b60010161425c565b50505092915050565b815463ffffffff90811682019061271090821611156142cc57506127105b825463ffffffff191663ffffffff82161783557fb0b2758328bb0b97c2bd520f8d23a040a5a36debb17fe9ecb48d2d215231a02d3383604051600160a060020a03909216825263ffffffff1660208201526040908101905180910390a1505050565b600654614345908290600160a060020a031661442f565b600654600160a060020a03166327ebe40a8261435f615496565b600a54600b543060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156143bf57600080fd5b6102c65a03f115156122fa57600080fd5b600c546103e883061180156143e8575060008160030b135b156143fc576143f78233613d46565b6134c2565b600160a060020a03331660009081526001602052604090206134c290614426600384900b85615521565b61ffff166142ae565b6000918252600560205260409091208054600160a060020a031916600160a060020a03909216919091179055565b614465615ba2565b61446d615c33565b600280548490811061447b57fe5b90600052602060002090016101206040519081016040908152915463ffffffff8082168352640100000000820460ff908116602080860191909152650100000000008404821686860152660100000000000084048216606086015267010000000000000084049091166080850152604060020a8304821660a0850152606060020a8304821660c08501527001000000000000000000000000000000008304821660e085015260a060020a909204166101008084019190915260088054939550612ad49461466d94919360026001841615909402600019019092169290920491601f83018290048202909101905190810160405280929190818152602001828054600181600116156101000203166002900480156145d95780601f106145ae576101008083540402835291602001916145d9565b820191906000526020600020905b8154815290600101906020018083116145bc57829003601f168201915b50505050506145ee846020015160ff16613bb9565b6040805190810160405280600181526020017f2f00000000000000000000000000000000000000000000000000000000000000815250614634866040015160ff16613bb9565b60408051908101604052600181527f2f0000000000000000000000000000000000000000000000000000000000000060208201526155ee565b61467d836060015160ff16613bb9565b602060405190810160405280600081525060206040519081016040528060008152506020604051908101604052600081526155ee565b6014546000908190620100009004600160a060020a031663f75b8d3c33836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561471657600080fd5b6102c65a03f1151561472757600080fd5b5050506040518051925060009150505b818110156134c257600160a060020a03331660009081526017602052604090208054600181016147678382615c7f565b506000918252602090912043910155600101614737565b60008060015b601f60ff821610156147b4578360ff82166020811061479f57fe5b602002015160ff169190910190600101614784565b5063ffffffff1692915050565b600160a060020a0333166000908152600160208190526040909120905b60208160ff16101561482b5760006001830160ff8316602081106147fe57fe5b602091828204019190066101000a81548160ff021916908360ff16021790555080806001019150506147de565b506001908101805460ff19811660ff91821690930116919091179055565b60008060ff83161580614872575060008460ff85166020811061486857fe5b602002015160ff16115b1561488057600091506120a3565b6148898361585e565b90505b600060ff82161115613446578360ff8216602081106148a757fe5b602002015160ff1615156148be57600091506120a3565b6148c78161585e565b905061488c565b600160a060020a0333166000908152600160208181526040909220019060ff83169081106148f857fe5b60208104919091018054601f9092166101000a60ff818102198416938290048116600101160291909117905550565b6000805b60075460ff8216101561497a576007805460ff831690811061494957fe5b60009182526020909120015433600160a060020a0390811691161415614972576001915061497f565b60010161492b565b600091505b5090565b600080600060028581548110151561499757fe5b600091825260209091200180549092506201518060a060020a90910463ffffffff16420311156149fe57815477ffffffff0000000000000000000000000000000000000000191660a060020a4263ffffffff1602176bffffffff0000000000000000191682555b508054600163ffffffff604060020a80840482169290920116026bffffffff000000000000000019909116178155826000600382900b1315614a56578154614a5390604060020a900463ffffffff168561586e565b90505b60008160030b128015614a7d5750815463ffffffff606060020a9091048116828101909116115b15614a9e5781546fffffffff00000000000000000000000019168255611c19565b60008160030b1315614acb57815463ffffffff606060020a909104811682810190911611614acb57600080fd5b80600286815481101515614adb57fe5b9060005260206000209001600001600c9054906101000a900463ffffffff1601600286815481101515614b0a57fe5b6000918252602090912001805463ffffffff92909216606060020a026fffffffff0000000000000000000000001990921691909117905591505092915050565b614b52615d37565b600160a060020a0383166000908152600160205260409081902090606090519081016040908152825463ffffffff80821684526401000000009091041660208084019190915291929181840191600184019190610400905190810160405291906104008301826000855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411614bbc579050505050505081525050905060008260030b128015614c1d5750806020015163ffffffff168282602001510163ffffffff16115b15614c2e5760006020820152611147565b60008260030b1315614c5c57806020015163ffffffff168282602001510163ffffffff1611614c5c57600080fd5b818160200151600160a060020a0385166000908152600160205260409020805463ffffffff93909201929092166401000000000267ffffffff0000000019909116179055505050565b600160a060020a0382166000908152601960205260409020805460018101614ccd8382615d5e565b916000526020600020906002020160006040805190810160405260008152600385900b60208201529190508151815560208201516001909101805460039290920b63ffffffff1663ffffffff1990921691909117905550505050565b600090815260056020526040902054600160a060020a0391821691161490565b6000815163ffffffff16604060020a02905060088167ffffffffffffffff19169060020a029050816020015160ff16604060020a021767ffffffffffffffff191661010002604082015160ff16604060020a021767ffffffffffffffff191661010002606082015160ff16604060020a021767ffffffffffffffff191661010002608082015160ff16604060020a021767ffffffffffffffff19166401000000000260a082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000260c082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000260e082015163ffffffff16604060020a021767ffffffffffffffff19166401000000000261010082015163ffffffff16604060020a0281179050919050565b600080614e7d615c33565b600254915063ffffffff82168214614e9157fe5b61012060405190810160405263ffffffff8316815260208101865160ff168152602001866001602002015160ff168152602001604087015160ff168152602001606087015160ff16815260006020820181905260408201524263ffffffff166060820181905260809091015260028054919250600191808301614f148382615d8a565b600092835260209092208491018151815463ffffffff191663ffffffff919091161781556020820151815460ff919091166401000000000264ff00000000199091161781556040820151815460ff91909116650100000000000265ff0000000000199091161781556060820151815460ff9190911666010000000000000266ff000000000000199091161781556080820151815460ff919091166701000000000000000267ff000000000000001990911617815560a0820151815463ffffffff91909116604060020a026bffffffff00000000000000001990911617815560c0820151815463ffffffff91909116606060020a026fffffffff0000000000000000000000001990911617815560e0820151815463ffffffff919091167001000000000000000000000000000000000273ffffffff0000000000000000000000000000000019909116178155610100820151815477ffffffff0000000000000000000000000000000000000000191660a060020a63ffffffff9283160217909155929091039184169190911490506150a757fe5b7f99a9eb7df2127a857fe5fb402049b72268904b6cd21a7d573413effbfbf98e66848383604051600160a060020a03909316835263ffffffff90911660208301526040808301919091526060909101905180910390a161510f6000858463ffffffff16614159565b5063ffffffff169392505050565b615125615d1d565b61512d615d1d565b615135615d1d565b61513d615d1d565b60038085526000906151549087906005600f6158d6565b60ff166020860152615169866000600361590f565b60ff166040808701919091526151bc908051908101604052600f81527f323132333433313134323334313131000000000000000000000000000000000060208201528660015b602002015160ff1661596a565b60ff166060860152600483526151d7866008600a600b6158d6565b60ff1660208401526151ec866005600861590f565b60ff16604080850191909152615236908051908101604052600b81527f343332313231313334333400000000000000000000000000000000000000000060208201528460016151af565b60ff1660608401526002845261525186600d600f600e6158d6565b60ff16602085015261526686600a600d61590f565b60ff166040808601919091526152b0908051908101604052600e81527f333133323334323231313131343400000000000000000000000000000000000060208201528560016151af565b60ff166060850152600182528551905080601414156152e5576152d88660126014600b6158d6565b60ff166020830152615305565b80601314156152fd576152d88660126013600b6158d6565b600160208301525b61531286600f601261590f565b60ff1660408084019190915261535c908051908101604052600b81527f313234333431333332313400000000000000000000000000000000000000000060208201528360016151af565b60ff1660608301525092949193509190565b600080808060ff85511061538157600080fd5b84519250600060ff84161161539557600080fd5b8260ff16868115156153a357fe5b069150600090505b848260ff16815181106153ba57fe5b9060200190602002015160ff1615156153ff576001918201910160ff80831690841614156153e757600091505b8260ff168160ff1611156153fa576153ff565b6153ab565b848260ff168151811061540e57fe5b9060200190602002015160ff16151561542657600080fd5b50600101949350505050565b600060001982018360ff82168151811061544857fe5b90602001906020020151949350505050565b60006103e882066103de61ffff8216106154775760039150612ad7565b6103ca61ffff82161061548d5760029150612ad7565b60019150612ad7565b60065460009081908190600160a060020a03166325b56dd482604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156154e457600080fd5b6102c65a03f115156154f557600080fd5b5050506040518051925060649050601e8302048201905060095481101561551b57506009545b92915050565b60008060008060006155328761597d565b601a549195509350606487069150640100000000900460ff168111156155735760ff831660148706600c018560ff160281151561556b57fe5b0491506155bc565b601a5465010000000000900460ff168111156155a25760ff8316600a87066006018560ff160281151561556b57fe5b60ff8316600587068560ff16028115156155b857fe5b0491505b601a546301000000900460ff1661ffff831610156155e457601a546301000000900460ff1691505b5095945050505050565b6155f6615ba2565b6155fe615ba2565b615606615ba2565b61560e615ba2565b615616615ba2565b61561e615ba2565b615626615ba2565b61562e615ba2565b6000808e98508d97508c96508b95508a94508451865188518a518c510101010160405180591061565b5750595b818152601f19601f83011681016020016040529050935083925060009150600090505b88518110156156d75788818151811061569357fe5b016020015160f860020a900460f860020a028383806001019450815181106156b757fe5b906020010190600160f860020a031916908160001a90535060010161567e565b5060005b8751811015615734578781815181106156f057fe5b016020015160f860020a900460f860020a0283838060010194508151811061571457fe5b906020010190600160f860020a031916908160001a9053506001016156db565b5060005b86518110156157915786818151811061574d57fe5b016020015160f860020a900460f860020a0283838060010194508151811061577157fe5b906020010190600160f860020a031916908160001a905350600101615738565b5060005b85518110156157ee578581815181106157aa57fe5b016020015160f860020a900460f860020a028383806001019450815181106157ce57fe5b906020010190600160f860020a031916908160001a905350600101615795565b5060005b845181101561584b5784818151811061580757fe5b016020015160f860020a900460f860020a0283838060010194508151811061582b57fe5b906020010190600160f860020a031916908160001a9053506001016157f2565b50909d9c50505050505050505050505050565b60026000199190910160ff160490565b600080600a63ffffffff851611615887578291506120a3565b8360030b83600a0260030b81151561589b57fe5b059050601a60069054906101000a900460000b60000b8160030b1215611a9c57601a5466010000000000009004600090810b900b91506120a3565b60008160ff166158f56158f0878760ff168760ff166159d7565b615a73565b60ff1681151561590157fe5b066001019050949350505050565b60008061592b615926868660ff168660ff166159d7565b615a7a565b90506103b663ffffffff8216106159455760039150615962565b61035263ffffffff82161061595d5760029150615962565b600191505b509392505050565b6000611a9c6158f08460018503856159d7565b6000806101f48313156159a0575050601a5460ff8082169161010090041661239f565b60008313156159bc575050601a54610100900460ff168061239f565b5050601a5460ff62010000820481169161010090041661239f565b6159df615ba2565b6159e7615ba2565b6159ef615ba2565b6000869250858503604051805910615a045750595b818152601f19601f8301168101602001604052905091508590505b848110156155e457828181518110615a3357fe5b016020015160f860020a900460f860020a028287830381518110615a5357fe5b906020010190600160f860020a031916908160001a905350600101615a1f565b600061159e825b6000615a84615ba2565b50816000805b8251811015615962577f3000000000000000000000000000000000000000000000000000000000000000838281518110615ac057fe5b016020015160f860020a900460f860020a02600160f860020a03191610158015615b3157507f3900000000000000000000000000000000000000000000000000000000000000838281518110615b1257fe5b016020015160f860020a900460f860020a02600160f860020a03191611155b15615b66576030838281518110615b4457fe5b016020015160f860020a900460f860020a0260f860020a90040382600a020191505b600101615a8a565b81548183558181151161114757601f016020900481601f016020900483600052602060002091820191016111479190615dae565b60206040519081016040526000815290565b5080546000825590600052602060002090810190612b709190615dae565b604080519081016040526000808252602082015290565b5080546000825560020290600052602060002090810190612b709190615dc8565b6104006040519081016040526020815b600081526000199091019060200181615c1a5790505090565b6101206040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082015290565b81548183558181151161114757600083815260209020611147918101908301615dae565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615ce45782800160ff19823516178555615d11565b82800160010185558215615d11579182015b82811115615d11578235825591602001919060010190615cf6565b5061497f929150615dae565b608060405190810160405260008152600360208201615c1a565b6104406040519081016040908152600080835260208301528101615d59615c0a565b905290565b815481835581811511611147576002028160020283600052602060002091820191016111479190615dc8565b81548183558181151161114757600083815260209020611147918101908301615df1565b61161091905b8082111561497f5760008155600101615db4565b61161091905b8082111561497f576000815560018101805463ffffffff19169055600201615dce565b61161091905b8082111561497f57805477ffffffffffffffffffffffffffffffffffffffffffffffff19168155600101615df75600a165627a7a723058207f063563e63c5eda5b27124329d52607b44bb025da896c34ebb70ac13a6503b80029

Swarm Source

bzzr://7f063563e63c5eda5b27124329d52607b44bb025da896c34ebb70ac13a6503b8
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.