Contract 0x211f01e59b425253c0a0e9a7bf612605b42ce82c

 

TxHash Block Age From To Value [TxFee]
0xb1edfe5557a3247fdf1bfe96b6cbcf1b22cab947705f9d3b0c2f00b1493b900f72361171 day 8 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.00031286112
0x610083a0187823c4bf7fa4cb9f042e205355628c16b4958c28684e976f02ab2372361171 day 8 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.0005806316
0x2b8fa29eea7ca354738ef99a882fb0a04c138c3b21fdebb56bae739bce8ff85172359401 day 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000464766
0x5cb726a4ba53ee31321013d075c5103d64522c126a2dc922e33afb583d0af9fa72317212 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000169146
0xf79707575304b38f86f107d38a7ea4a8ed8d1a0ccf3a572e3650f801d9d8cc8e72315392 days 10 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000384076
0x8cd6d3b95e831849ec1681b0b72df8c4ec8b759a58fc804ca0f629c4d8f4b62072315372 days 10 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000620499
0x3ba74dd7abcd2e6ec731f8b75ec2c8a38db6aa101a183ecfc5cb2af45ac9454a72315342 days 10 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000395263
0x2a03e8e387c2d21eb478ce22333468c163dee28a8a8e3425a004e25f3ae8a21e72275043 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.00021405
0x222245f902771921ab3c26a62f18547c734b0fba3fff3367b903e71a947ede5d72252673 days 22 hrs ago0xf035561dce033ded865e15e69db06cffc88d9213 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000242517
0xa2aa9caada38e3edf7452b18904725ddeec1dc8c06860b95f56602aa133be5bb72212724 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000341548
0x41d6f8aacda3b238aadff2536faf511948b4eff4b24a7d03f00457c7f495f0d072212654 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000309844
0x4e8f584584831789b4152d7d6e4775b072ccf92da298f9c1f446457cb967461d72185095 days 13 hrs ago0xb3b5104063a5e1facf6503d9ed4923622ddaf6cc IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.00044434
0x8fff03818726a565c1e3ac03931a1dfcb25a7b387313d5f928164373456b7ea372171105 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000112764
0x3d82a084bbfaa4fca4f09639314bd6ca3a29c365e920c1d4369b230d0e9ac04b72169145 days 22 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000215598
0x39d1879f3b0377f843672fab8ee5f7af9dd00d085bbf3d2d72ab585f170d016972129206 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000178375
0xe91c3da5cf0a2383e7384c3aaa023adac510cc1ebc47ff33b0738c60614c962a72065358 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000341548
0x1addf326a2cd312147465f4a82bcf08ae08533b53cd8e3d6118a94d44aa163ad72065238 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000309844
0x6ed95a616747fe00d2441999dbe4128ed6bdbb4c200ad6784ec29546988653b472023269 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000084573
0x0a5319c001849107a556c18456773f3625df58475bc39c332143ef6cecc1146072021459 days 10 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000179665
0xe206f2ec674e18c69476dc82b6aeddb7390496169438caea415540db1dda6e2a719764110 days 9 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.0001427
0xf8a2aefe982d13e899e00269f3a8d33b3b4bbbfc609476ff719fe36a1a392904719026711 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000341548
0x50c9c4e6022ae35709ed4c3f8f513e299897a0ae3cd33d6dca8459d7cc9205b5719026411 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000309844
0x60872098c9cad117b4d90980bcefaaed00563de46d8b2d073619f45cbf1e5b33718534812 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000112764
0xf896e4bdff3dbb5696a2bec63bea3cbe9654017390427b483c8d78ec2fbb0910718515312 days 22 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.000143732
0x9c14f5363a9706b413c6395375e9398545dd84b2d27957c78272a441f280f9ce718044913 days 21 hrs ago0x133b5b851cc62de33a02c928f6ac112cd42d1d83 IN  0x211f01e59b425253c0a0e9a7bf612605b42ce82c0 Ether0.0001427
[ Download CSV Export 

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

Parent TxHash Block Age From To Value
0x7fbdbfcc95df12ab74a984a385ac03c5512ab1e0b7a7a9cf7a0145dc92ee09b772111037 days 7 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0xc968a4f3ccecbbaa99c48371f05586d84672eef249bfb8dc52e6910d8cf1f098711939526 days 6 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x166dae8cb8c97052a9c158e81e1634a45d302a15d4d82309acd36277259d2094710594628 days 21 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x010afb8548a5d1a3a3d62f58ca0a5a13299742060.03 Ether
0xcda56d1a2cbb82c524a855e0c3364f9c6831aed983bc73762e696a886db36648709297831 days 7 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.07 Ether
0x16eb66831d37f98dfb39b179d5794e5d5070f86d7a44cc1dda10d311231ce320707569134 days 9 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x1e2795da10d18adae737d35b94e72cd1d8f67a9721a2672e4e748cec484b82e9704973939 days 56 mins ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x010afb8548a5d1a3a3d62f58ca0a5a13299742060.02 Ether
0x590e58731c1d5979c19c644d42ac88b52ed6a7cd8d1f693215191a060cd01430704779739 days 9 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0xf035561dce033ded865e15e69db06cffc88d92130.01 Ether
0x3a565d053091e75bdab28481a89badc812326d08a392ffd0b9a9933daba88ea5702650943 days 5 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x909c529d62bc2c302d241e18d4a37be2f8c1443b2b874087c95770ef44ae3c69701027446 days 2 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0xf035561dce033ded865e15e69db06cffc88d92130.01 Ether
0x67f6d04301cb9fe3120767445ce15b3f678de37f509acd5313f4f6c6eafb9565701025746 days 2 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0xf035561dce033ded865e15e69db06cffc88d92130.01 Ether
0xe97a5ea69ffc46f4007250acc0348c36fac10ae11a924174733ecb9153a39dc6700832846 days 10 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x7baefd3ef84970077ffb5d8d7aa70ea55dba97a80.02 Ether
0xb1f660fb8b63ccc18df374c983dcebc0b0c345cefb64ca9008de9d8ff756b7eb700831446 days 10 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x7baefd3ef84970077ffb5d8d7aa70ea55dba97a80.01 Ether
0x3749bd8fb50f6b46250e6797d59f6af5fff21ff168d933c783a13d7e0348f3a8700800946 days 12 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0xab6afa507adfac8a2c22c85716cb74156c897d4b0.01 Ether
0x09bd3679d73d07d6d61145dae67f194c13a63e6960c14084c3d5499f15a80435700019947 days 21 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0xc79fb188d52c56e6ad4b0d4ade8f8f4ec43cc4810a514a2b569ff2a8b05de26c699773248 days 7 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x494c3c3dbf93613173996893e8770b6a8cd3558c8efd4768c5b43d8dd8208dc8699717348 days 10 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x498b859d2e59958e209d7dd262324c8d31b12b120.01 Ether
0x503451b2c7872a5888ef4ce813adc0fdc5ef4dd7950e0876277fb47dd1b0bce5698624650 days 6 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x010afb8548a5d1a3a3d62f58ca0a5a13299742060.02 Ether
0xe1134f245bb0dca5c641322a21d176e7b5c0437a8fbdf3db70a75fd3f6f70bea698623350 days 6 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x010afb8548a5d1a3a3d62f58ca0a5a13299742060.02 Ether
0x9804634987b20c6e3f1dd07b48fb437bd1f1b924c7c171808cd51796b3a12a6b698598450 days 7 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x7baefd3ef84970077ffb5d8d7aa70ea55dba97a80.01 Ether
0xb4e3a300df9340f265e60c3307f5e4a04cf747df45eeb3605ce9fcee4e9baa30698543750 days 9 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0xf035561dce033ded865e15e69db06cffc88d92130.01 Ether
0x270155a14832bba6f9afb8ebe79373a647ab3287e9984d91f929ecd11f4dc775698030251 days 6 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x145b1458992c2abfb8b28ba3d80a17cc54867583f7ffcae4dd6c1710b29e991f698029751 days 6 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0xd41c464eb0ac4c395f56478c04fed47c5e76d8ade2eddec41a6dec3751adf00f698029151 days 6 hrs ago0xb7faddf3ecd2402a7e48cea6d2637d90eeb5a7e60x211f01e59b425253c0a0e9a7bf612605b42ce82c0.03 Ether
0x7a1386258a7388d66daa404f29d3ec95a39fe6f2d138afcdf97e91f663ac183e697490852 days 4 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x498b859d2e59958e209d7dd262324c8d31b12b120.01 Ether
0xd4ddcbeafab00c38c9abc719b9c213df73417ade2c97942482471703272519b3697466452 days 5 hrs ago0x211f01e59b425253c0a0e9a7bf612605b42ce82c0x010afb8548a5d1a3a3d62f58ca0a5a13299742060.01 Ether
[ Download CSV Export 
Warning: The compiled contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) Solidity Compiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: Kleros
Compiler Version: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimizer):  200


Contract Source Code
/**
 *  @title Kleros
 *  @author Clément Lesaege - <[email protected]>
 *  This code implements a simple version of Kleros.
 *  Bug Bounties: This code hasn't undertaken a bug bounty program yet.
 */

pragma solidity ^0.4.24;


contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
}

/// @dev The token controller contract must implement these functions
contract TokenController {
    /// @notice Called when `_owner` sends ether to the MiniMe Token contract
    /// @param _owner The address that sent the ether to create tokens
    /// @return True if the ether is accepted, false if it throws
    function proxyPayment(address _owner) public payable returns(bool);

    /// @notice Notifies the controller about a token transfer allowing the
    ///  controller to react if desired
    /// @param _from The origin of the transfer
    /// @param _to The destination of the transfer
    /// @param _amount The amount of the transfer
    /// @return False if the controller does not authorize the transfer
    function onTransfer(address _from, address _to, uint _amount) public returns(bool);

    /// @notice Notifies the controller about an approval allowing the
    ///  controller to react if desired
    /// @param _owner The address that calls `approve()`
    /// @param _spender The spender in the `approve()` call
    /// @param _amount The amount in the `approve()` call
    /// @return False if the controller does not authorize the approval
    function onApprove(address _owner, address _spender, uint _amount) public
        returns(bool);
}

contract Controlled {
    /// @notice The address of the controller is the only address that can call
    ///  a function with this modifier
    modifier onlyController { require(msg.sender == controller); _; }

    address public controller;

    function Controlled() public { controller = msg.sender;}

    /// @notice Changes the controller of the contract
    /// @param _newController The new controller of the contract
    function changeController(address _newController) public onlyController {
        controller = _newController;
    }
}

/// @dev The actual token contract, the default controller is the msg.sender
///  that deploys the contract, so usually this token will be deployed by a
///  token controller contract, which Giveth will call a "Campaign"
contract Pinakion is Controlled {

    string public name;                //The Token's name: e.g. DigixDAO Tokens
    uint8 public decimals;             //Number of decimals of the smallest unit
    string public symbol;              //An identifier: e.g. REP
    string public version = 'MMT_0.2'; //An arbitrary versioning scheme


    /// @dev `Checkpoint` is the structure that attaches a block number to a
    ///  given value, the block number attached is the one that last changed the
    ///  value
    struct  Checkpoint {

        // `fromBlock` is the block number that the value was generated from
        uint128 fromBlock;

        // `value` is the amount of tokens at a specific block number
        uint128 value;
    }

    // `parentToken` is the Token address that was cloned to produce this token;
    //  it will be 0x0 for a token that was not cloned
    Pinakion public parentToken;

    // `parentSnapShotBlock` is the block number from the Parent Token that was
    //  used to determine the initial distribution of the Clone Token
    uint public parentSnapShotBlock;

    // `creationBlock` is the block number that the Clone Token was created
    uint public creationBlock;

    // `balances` is the map that tracks the balance of each address, in this
    //  contract when the balance changes the block number that the change
    //  occurred is also included in the map
    mapping (address => Checkpoint[]) balances;

    // `allowed` tracks any extra transfer rights as in all ERC20 tokens
    mapping (address => mapping (address => uint256)) allowed;

    // Tracks the history of the `totalSupply` of the token
    Checkpoint[] totalSupplyHistory;

    // Flag that determines if the token is transferable or not.
    bool public transfersEnabled;

    // The factory used to create new clone tokens
    MiniMeTokenFactory public tokenFactory;

////////////////
// Constructor
////////////////

    /// @notice Constructor to create a Pinakion
    /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
    ///  will create the Clone token contracts, the token factory needs to be
    ///  deployed first
    /// @param _parentToken Address of the parent token, set to 0x0 if it is a
    ///  new token
    /// @param _parentSnapShotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token, set to 0 if it
    ///  is a new token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    function Pinakion(
        address _tokenFactory,
        address _parentToken,
        uint _parentSnapShotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) public {
        tokenFactory = MiniMeTokenFactory(_tokenFactory);
        name = _tokenName;                                 // Set the name
        decimals = _decimalUnits;                          // Set the decimals
        symbol = _tokenSymbol;                             // Set the symbol
        parentToken = Pinakion(_parentToken);
        parentSnapShotBlock = _parentSnapShotBlock;
        transfersEnabled = _transfersEnabled;
        creationBlock = block.number;
    }


///////////////////
// ERC20 Methods
///////////////////

    /// @notice Send `_amount` tokens to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _amount) public returns (bool success) {
        require(transfersEnabled);
        doTransfer(msg.sender, _to, _amount);
        return true;
    }

    /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
    ///  is approved by `_from`
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function transferFrom(address _from, address _to, uint256 _amount
    ) public returns (bool success) {

        // The controller of this contract can move tokens around at will,
        //  this is important to recognize! Confirm that you trust the
        //  controller of this contract, which in most situations should be
        //  another open source smart contract or 0x0
        if (msg.sender != controller) {
            require(transfersEnabled);

            // The standard ERC 20 transferFrom functionality
            require(allowed[_from][msg.sender] >= _amount);
            allowed[_from][msg.sender] -= _amount;
        }
        doTransfer(_from, _to, _amount);
        return true;
    }

    /// @dev This is the actual transfer function in the token contract, it can
    ///  only be called by other functions in this contract.
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function doTransfer(address _from, address _to, uint _amount
    ) internal {

           if (_amount == 0) {
               Transfer(_from, _to, _amount);    // Follow the spec to louch the event when transfer 0
               return;
           }

           require(parentSnapShotBlock < block.number);

           // Do not allow transfer to 0x0 or the token contract itself
           require((_to != 0) && (_to != address(this)));

           // If the amount being transfered is more than the balance of the
           //  account the transfer throws
           var previousBalanceFrom = balanceOfAt(_from, block.number);

           require(previousBalanceFrom >= _amount);

           // Alerts the token controller of the transfer
           if (isContract(controller)) {
               require(TokenController(controller).onTransfer(_from, _to, _amount));
           }

           // First update the balance array with the new value for the address
           //  sending the tokens
           updateValueAtNow(balances[_from], previousBalanceFrom - _amount);

           // Then update the balance array with the new value for the address
           //  receiving the tokens
           var previousBalanceTo = balanceOfAt(_to, block.number);
           require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
           updateValueAtNow(balances[_to], previousBalanceTo + _amount);

           // An event to make the transfer easy to find on the blockchain
           Transfer(_from, _to, _amount);

    }

    /// @param _owner The address that's balance is being requested
    /// @return The balance of `_owner` at the current block
    function balanceOf(address _owner) public constant returns (uint256 balance) {
        return balanceOfAt(_owner, block.number);
    }

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
    ///  its behalf. This is the standard version to allow backward compatibility.
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the approval was successful
    function approve(address _spender, uint256 _amount) public returns (bool success) {
        require(transfersEnabled);

        // Alerts the token controller of the approve function call
        if (isContract(controller)) {
            require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
        }

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

    /// @dev This function makes it easy to read the `allowed[]` map
    /// @param _owner The address of the account that owns the token
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens of _owner that _spender is allowed
    ///  to spend
    function allowance(address _owner, address _spender
    ) public constant returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }

    /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
    ///  its behalf, and then a function is triggered in the contract that is
    ///  being approved, `_spender`. This allows users to use their tokens to
    ///  interact with contracts in one function call instead of two
    /// @param _spender The address of the contract able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the function call was successful
    function approveAndCall(address _spender, uint256 _amount, bytes _extraData
    ) public returns (bool success) {
        require(approve(_spender, _amount));

        ApproveAndCallFallBack(_spender).receiveApproval(
            msg.sender,
            _amount,
            this,
            _extraData
        );

        return true;
    }

    /// @dev This function makes it easy to get the total number of tokens
    /// @return The total number of tokens
    function totalSupply() public constant returns (uint) {
        return totalSupplyAt(block.number);
    }


////////////////
// Query balance and totalSupply in History
////////////////

    /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
    /// @param _owner The address from which the balance will be retrieved
    /// @param _blockNumber The block number when the balance is queried
    /// @return The balance at `_blockNumber`
    function balanceOfAt(address _owner, uint _blockNumber) public constant
        returns (uint) {

        // These next few lines are used when the balance of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.balanceOfAt` be queried at the
        //  genesis block for that token as this contains initial balance of
        //  this token
        if ((balances[_owner].length == 0)
            || (balances[_owner][0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
            } else {
                // Has no parent
                return 0;
            }

        // This will return the expected balance during normal situations
        } else {
            return getValueAt(balances[_owner], _blockNumber);
        }
    }

    /// @notice Total amount of tokens at a specific `_blockNumber`.
    /// @param _blockNumber The block number when the totalSupply is queried
    /// @return The total amount of tokens at `_blockNumber`
    function totalSupplyAt(uint _blockNumber) public constant returns(uint) {

        // These next few lines are used when the totalSupply of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.totalSupplyAt` be queried at the
        //  genesis block for this token as that contains totalSupply of this
        //  token at this block number.
        if ((totalSupplyHistory.length == 0)
            || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
            } else {
                return 0;
            }

        // This will return the expected totalSupply during normal situations
        } else {
            return getValueAt(totalSupplyHistory, _blockNumber);
        }
    }

////////////////
// Clone Token Method
////////////////

    /// @notice Creates a new clone token with the initial distribution being
    ///  this token at `_snapshotBlock`
    /// @param _cloneTokenName Name of the clone token
    /// @param _cloneDecimalUnits Number of decimals of the smallest unit
    /// @param _cloneTokenSymbol Symbol of the clone token
    /// @param _snapshotBlock Block when the distribution of the parent token is
    ///  copied to set the initial distribution of the new clone token;
    ///  if the block is zero than the actual block, the current block is used
    /// @param _transfersEnabled True if transfers are allowed in the clone
    /// @return The address of the new MiniMeToken Contract
    function createCloneToken(
        string _cloneTokenName,
        uint8 _cloneDecimalUnits,
        string _cloneTokenSymbol,
        uint _snapshotBlock,
        bool _transfersEnabled
        ) public returns(address) {
        if (_snapshotBlock == 0) _snapshotBlock = block.number;
        Pinakion cloneToken = tokenFactory.createCloneToken(
            this,
            _snapshotBlock,
            _cloneTokenName,
            _cloneDecimalUnits,
            _cloneTokenSymbol,
            _transfersEnabled
            );

        cloneToken.changeController(msg.sender);

        // An event to make the token easy to find on the blockchain
        NewCloneToken(address(cloneToken), _snapshotBlock);
        return address(cloneToken);
    }

////////////////
// Generate and destroy tokens
////////////////

    /// @notice Generates `_amount` tokens that are assigned to `_owner`
    /// @param _owner The address that will be assigned the new tokens
    /// @param _amount The quantity of tokens generated
    /// @return True if the tokens are generated correctly
    function generateTokens(address _owner, uint _amount
    ) public onlyController returns (bool) {
        uint curTotalSupply = totalSupply();
        require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
        uint previousBalanceTo = balanceOf(_owner);
        require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
        updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
        updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
        Transfer(0, _owner, _amount);
        return true;
    }


    /// @notice Burns `_amount` tokens from `_owner`
    /// @param _owner The address that will lose the tokens
    /// @param _amount The quantity of tokens to burn
    /// @return True if the tokens are burned correctly
    function destroyTokens(address _owner, uint _amount
    ) onlyController public returns (bool) {
        uint curTotalSupply = totalSupply();
        require(curTotalSupply >= _amount);
        uint previousBalanceFrom = balanceOf(_owner);
        require(previousBalanceFrom >= _amount);
        updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
        updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
        Transfer(_owner, 0, _amount);
        return true;
    }

////////////////
// Enable tokens transfers
////////////////


    /// @notice Enables token holders to transfer their tokens freely if true
    /// @param _transfersEnabled True if transfers are allowed in the clone
    function enableTransfers(bool _transfersEnabled) public onlyController {
        transfersEnabled = _transfersEnabled;
    }

////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////

    /// @dev `getValueAt` retrieves the number of tokens at a given block number
    /// @param checkpoints The history of values being queried
    /// @param _block The block number to retrieve the value at
    /// @return The number of tokens being queried
    function getValueAt(Checkpoint[] storage checkpoints, uint _block
    ) constant internal returns (uint) {
        if (checkpoints.length == 0) return 0;

        // Shortcut for the actual value
        if (_block >= checkpoints[checkpoints.length-1].fromBlock)
            return checkpoints[checkpoints.length-1].value;
        if (_block < checkpoints[0].fromBlock) return 0;

        // Binary search of the value in the array
        uint min = 0;
        uint max = checkpoints.length-1;
        while (max > min) {
            uint mid = (max + min + 1)/ 2;
            if (checkpoints[mid].fromBlock<=_block) {
                min = mid;
            } else {
                max = mid-1;
            }
        }
        return checkpoints[min].value;
    }

    /// @dev `updateValueAtNow` used to update the `balances` map and the
    ///  `totalSupplyHistory`
    /// @param checkpoints The history of data being updated
    /// @param _value The new number of tokens
    function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
    ) internal  {
        if ((checkpoints.length == 0)
        || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
               Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
               newCheckPoint.fromBlock =  uint128(block.number);
               newCheckPoint.value = uint128(_value);
           } else {
               Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
               oldCheckPoint.value = uint128(_value);
           }
    }

    /// @dev Internal function to determine if an address is a contract
    /// @param _addr The address being queried
    /// @return True if `_addr` is a contract
    function isContract(address _addr) constant internal returns(bool) {
        uint size;
        if (_addr == 0) return false;
        assembly {
            size := extcodesize(_addr)
        }
        return size>0;
    }

    /// @dev Helper function to return a min betwen the two uints
    function min(uint a, uint b) pure internal returns (uint) {
        return a < b ? a : b;
    }

    /// @notice The fallback function: If the contract's controller has not been
    ///  set to 0, then the `proxyPayment` method is called which relays the
    ///  ether and creates tokens as described in the token controller contract
    function () public payable {
        require(isContract(controller));
        require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
    }

//////////
// Safety Methods
//////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyController {
        if (_token == 0x0) {
            controller.transfer(this.balance);
            return;
        }

        Pinakion token = Pinakion(_token);
        uint balance = token.balanceOf(this);
        token.transfer(controller, balance);
        ClaimedTokens(_token, controller, balance);
    }

////////////////
// Events
////////////////
    event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
    event Transfer(address indexed _from, address indexed _to, uint256 _amount);
    event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _amount
        );

}


////////////////
// MiniMeTokenFactory
////////////////

/// @dev This contract is used to generate clone contracts from a contract.
///  In solidity this is the way to create a contract from a contract of the
///  same class
contract MiniMeTokenFactory {

    /// @notice Update the DApp by creating a new token with new functionalities
    ///  the msg.sender becomes the controller of this clone token
    /// @param _parentToken Address of the token being cloned
    /// @param _snapshotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    /// @return The address of the new token contract
    function createCloneToken(
        address _parentToken,
        uint _snapshotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) public returns (Pinakion) {
        Pinakion newToken = new Pinakion(
            this,
            _parentToken,
            _snapshotBlock,
            _tokenName,
            _decimalUnits,
            _tokenSymbol,
            _transfersEnabled
            );

        newToken.changeController(msg.sender);
        return newToken;
    }
}

contract RNG{

    /** @dev Contribute to the reward of a random number.
     *  @param _block Block the random number is linked to.
     */
    function contribute(uint _block) public payable;

    /** @dev Request a random number.
     *  @param _block Block linked to the request.
     */
    function requestRN(uint _block) public payable {
        contribute(_block);
    }

    /** @dev Get the random number.
     *  @param _block Block the random number is linked to.
     *  @return RN Random Number. If the number is not ready or has not been required 0 instead.
     */
    function getRN(uint _block) public returns (uint RN);

    /** @dev Get a uncorrelated random number. Act like getRN but give a different number for each sender.
     *  This is to prevent users from getting correlated numbers.
     *  @param _block Block the random number is linked to.
     *  @return RN Random Number. If the number is not ready or has not been required 0 instead.
     */
    function getUncorrelatedRN(uint _block) public returns (uint RN) {
        uint baseRN=getRN(_block);
        if (baseRN==0)
            return 0;
        else
            return uint(keccak256(msg.sender,baseRN));
    }

 }

/** Simple Random Number Generator returning the blockhash.
 *  Allows saving the random number for use in the future.
 *  It allows the contract to still access the blockhash even after 256 blocks.
 *  The first party to call the save function gets the reward.
 */
contract BlockHashRNG is RNG {

    mapping (uint => uint) public randomNumber; // randomNumber[block] is the random number for this block, 0 otherwise.
    mapping (uint => uint) public reward; // reward[block] is the amount to be paid to the party w.



    /** @dev Contribute to the reward of a random number.
     *  @param _block Block the random number is linked to.
     */
    function contribute(uint _block) public payable { reward[_block]+=msg.value; }


    /** @dev Return the random number. If it has not been saved and is still computable compute it.
     *  @param _block Block the random number is linked to.
     *  @return RN Random Number. If the number is not ready or has not been requested 0 instead.
     */
    function getRN(uint _block) public returns (uint RN) {
        RN=randomNumber[_block];
        if (RN==0){
            saveRN(_block);
            return randomNumber[_block];
        }
        else
            return RN;
    }

    /** @dev Save the random number for this blockhash and give the reward to the caller.
     *  @param _block Block the random number is linked to.
     */
    function saveRN(uint _block) public {
        if (blockhash(_block) != 0x0)
            randomNumber[_block] = uint(blockhash(_block));
        if (randomNumber[_block] != 0) { // If the number is set.
            uint rewardToSend = reward[_block];
            reward[_block] = 0;
            msg.sender.send(rewardToSend); // Note that the use of send is on purpose as we don't want to block in case msg.sender has a fallback issue.
        }
    }

}


/** Random Number Generator returning the blockhash with a backup behaviour.
 *  Allows saving the random number for use in the future. 
 *  It allows the contract to still access the blockhash even after 256 blocks.
 *  The first party to call the save function gets the reward.
 *  If no one calls the contract within 256 blocks, the contract fallback in returning the blockhash of the previous block.
 */
contract BlockHashRNGFallback is BlockHashRNG {
    
    /** @dev Save the random number for this blockhash and give the reward to the caller.
     *  @param _block Block the random number is linked to.
     */
    function saveRN(uint _block) public {
        if (_block<block.number && randomNumber[_block]==0) {// If the random number is not already set and can be.
            if (blockhash(_block)!=0x0) // Normal case.
                randomNumber[_block]=uint(blockhash(_block));
            else // The contract was not called in time. Fallback to returning previous blockhash.
                randomNumber[_block]=uint(blockhash(block.number-1));
        }
        if (randomNumber[_block] != 0) { // If the random number is set.
            uint rewardToSend=reward[_block];
            reward[_block]=0;
            msg.sender.send(rewardToSend); // Note that the use of send is on purpose as we don't want to block in case the msg.sender has a fallback issue.
        }
    }
    
}

/** @title Arbitrable
 *  Arbitrable abstract contract.
 *  When developing arbitrable contracts, we need to:
 *  -Define the action taken when a ruling is received by the contract. We should do so in executeRuling.
 *  -Allow dispute creation. For this a function must:
 *      -Call arbitrator.createDispute.value(_fee)(_choices,_extraData);
 *      -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions);
 */
contract Arbitrable{
    Arbitrator public arbitrator;
    bytes public arbitratorExtraData; // Extra data to require particular dispute and appeal behaviour.

    modifier onlyArbitrator {require(msg.sender==address(arbitrator)); _;}

    /** @dev To be raised when a ruling is given.
     *  @param _arbitrator The arbitrator giving the ruling.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling The ruling which was given.
     */
    event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling);

    /** @dev To be emmited when meta-evidence is submitted.
     *  @param _metaEvidenceID Unique identifier of meta-evidence.
     *  @param _evidence A link to the meta-evidence JSON.
     */
    event MetaEvidence(uint indexed _metaEvidenceID, string _evidence);

    /** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _metaEvidenceID Unique identifier of meta-evidence.
     */
    event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID);

    /** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations).
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party.
     *  @param _evidence A URI to the evidence JSON file whose name should be its keccak256 hash followed by .json.
     */
    event Evidence(Arbitrator indexed _arbitrator, uint indexed _disputeID, address _party, string _evidence);

    /** @dev Constructor. Choose the arbitrator.
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _arbitratorExtraData Extra data for the arbitrator.
     */
    constructor(Arbitrator _arbitrator, bytes _arbitratorExtraData) public {
        arbitrator = _arbitrator;
        arbitratorExtraData = _arbitratorExtraData;
    }

    /** @dev Give a ruling for a dispute. Must be called by the arbitrator.
     *  The purpose of this function is to ensure that the address calling it has the right to rule on the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision".
     */
    function rule(uint _disputeID, uint _ruling) public onlyArbitrator {
        emit Ruling(Arbitrator(msg.sender),_disputeID,_ruling);

        executeRuling(_disputeID,_ruling);
    }


    /** @dev Execute a ruling of a dispute.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision".
     */
    function executeRuling(uint _disputeID, uint _ruling) internal;
}

/** @title Arbitrator
 *  Arbitrator abstract contract.
 *  When developing arbitrator contracts we need to:
 *  -Define the functions for dispute creation (createDispute) and appeal (appeal). Don't forget to store the arbitrated contract and the disputeID (which should be unique, use nbDisputes).
 *  -Define the functions for cost display (arbitrationCost and appealCost).
 *  -Allow giving rulings. For this a function must call arbitrable.rule(disputeID,ruling).
 */
contract Arbitrator{

    enum DisputeStatus {Waiting, Appealable, Solved}

    modifier requireArbitrationFee(bytes _extraData) {require(msg.value>=arbitrationCost(_extraData)); _;}
    modifier requireAppealFee(uint _disputeID, bytes _extraData) {require(msg.value>=appealCost(_disputeID, _extraData)); _;}

    /** @dev To be raised when a dispute can be appealed.
     *  @param _disputeID ID of the dispute.
     */
    event AppealPossible(uint _disputeID);

    /** @dev To be raised when a dispute is created.
     *  @param _disputeID ID of the dispute.
     *  @param _arbitrable The contract which created the dispute.
     */
    event DisputeCreation(uint indexed _disputeID, Arbitrable _arbitrable);

    /** @dev To be raised when the current ruling is appealed.
     *  @param _disputeID ID of the dispute.
     *  @param _arbitrable The contract which created the dispute.
     */
    event AppealDecision(uint indexed _disputeID, Arbitrable _arbitrable);

    /** @dev Create a dispute. Must be called by the arbitrable contract.
     *  Must be paid at least arbitrationCost(_extraData).
     *  @param _choices Amount of choices the arbitrator can make in this dispute.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return disputeID ID of the dispute created.
     */
    function createDispute(uint _choices, bytes _extraData) public requireArbitrationFee(_extraData) payable returns(uint disputeID)  {}

    /** @dev Compute the cost of arbitration. It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return fee Amount to be paid.
     */
    function arbitrationCost(bytes _extraData) public constant returns(uint fee);

    /** @dev Appeal a ruling. Note that it has to be called before the arbitrator contract calls rule.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Can be used to give extra info on the appeal.
     */
    function appeal(uint _disputeID, bytes _extraData) public requireAppealFee(_disputeID,_extraData) payable {
        emit AppealDecision(_disputeID, Arbitrable(msg.sender));
    }

    /** @dev Compute the cost of appeal. It is recommended not to increase it often, as it can be higly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return fee Amount to be paid.
     */
    function appealCost(uint _disputeID, bytes _extraData) public constant returns(uint fee);

    /** @dev Return the status of a dispute.
     *  @param _disputeID ID of the dispute to rule.
     *  @return status The status of the dispute.
     */
    function disputeStatus(uint _disputeID) public constant returns(DisputeStatus status);

    /** @dev Return the current ruling of a dispute. This is useful for parties to know if they should appeal.
     *  @param _disputeID ID of the dispute.
     *  @return ruling The ruling which has been given or the one which will be given if there is no appeal.
     */
    function currentRuling(uint _disputeID) public constant returns(uint ruling);

}



contract Kleros is Arbitrator, ApproveAndCallFallBack {

    // **************************** //
    // *    Contract variables    * //
    // **************************** //

    // Variables which should not change after initialization.
    Pinakion public pinakion;
    uint public constant NON_PAYABLE_AMOUNT = (2**256 - 2) / 2; // An astronomic amount, practically can't be paid.

    // Variables which will subject to the governance mechanism.
    // Note they will only be able to be changed during the activation period (because a session assumes they don't change after it).
    RNG public rng; // Random Number Generator used to draw jurors.
    uint public arbitrationFeePerJuror = 0.05 ether; // The fee which will be paid to each juror.
    uint16 public defaultNumberJuror = 3; // Number of drawn jurors unless specified otherwise.
    uint public minActivatedToken = 0.1 * 1e18; // Minimum of tokens to be activated (in basic units).
    uint[5] public timePerPeriod; // The minimum time each period lasts (seconds).
    uint public alpha = 2000; // alpha in ‱ (1 / 10 000).
    uint constant ALPHA_DIVISOR = 1e4; // Amount we need to divided alpha in ‱ to get the float value of alpha.
    uint public maxAppeals = 5; // Number of times a dispute can be appealed. When exceeded appeal cost becomes NON_PAYABLE_AMOUNT.
    // Initially, the governor will be an address controlled by the Kleros team. At a later stage,
    // the governor will be switched to a governance contract with liquid voting.
    address public governor; // Address of the governor contract.

    // Variables changing during day to day interaction.
    uint public session = 1;      // Current session of the court.
    uint public lastPeriodChange; // The last time we changed of period (seconds).
    uint public segmentSize;      // Size of the segment of activated tokens.
    uint public rnBlock;          // The block linked with the RN which is requested.
    uint public randomNumber;     // Random number of the session.

    enum Period {
        Activation, // When juror can deposit their tokens and parties give evidences.
        Draw,       // When jurors are drawn at random, note that this period is fast.
        Vote,       // Where jurors can vote on disputes.
        Appeal,     // When parties can appeal the rulings.
        Execution   // When where token redistribution occurs and Kleros call the arbitrated contracts.
    }

    Period public period;

    struct Juror {
        uint balance;      // The amount of tokens the contract holds for this juror.
        uint atStake;      // Total number of tokens the jurors can loose in disputes they are drawn in. Those tokens are locked. Note that we can have atStake > balance but it should be statistically unlikely and does not pose issues.
        uint lastSession;  // Last session the tokens were activated.
        uint segmentStart; // Start of the segment of activated tokens.
        uint segmentEnd;   // End of the segment of activated tokens.
    }

    mapping (address => Juror) public jurors;

    struct Vote {
        address account; // The juror who casted the vote.
        uint ruling;     // The ruling which was given.
    }

    struct VoteCounter {
        uint winningChoice; // The choice which currently has the highest amount of votes. Is 0 in case of a tie.
        uint winningCount;  // The number of votes for winningChoice. Or for the choices which are tied.
        mapping (uint => uint) voteCount; // voteCount[choice] is the number of votes for choice.
    }

    enum DisputeState {
        Open,       // The dispute is opened but the outcome is not available yet (this include when jurors voted but appeal is still possible).
        Resolving,  // The token repartition has started. Note that if it's done in just one call, this state is skipped.
        Executable, // The arbitrated contract can be called to enforce the decision.
        Executed    // Everything has been done and the dispute can't be interacted with anymore.
    }

    struct Dispute {
        Arbitrable arbitrated;       // Contract to be arbitrated.
        uint session;                // First session the dispute was schedule.
        uint appeals;                // Number of appeals.
        uint choices;                // The number of choices available to the jurors.
        uint16 initialNumberJurors;  // The initial number of jurors.
        uint arbitrationFeePerJuror; // The fee which will be paid to each juror.
        DisputeState state;          // The state of the dispute.
        Vote[][] votes;              // The votes in the form vote[appeals][voteID].
        VoteCounter[] voteCounter;   // The vote counters in the form voteCounter[appeals].
        mapping (address => uint) lastSessionVote; // Last session a juror has voted on this dispute. Is 0 if he never did.
        uint currentAppealToRepartition; // The current appeal we are repartitioning.
        AppealsRepartitioned[] appealsRepartitioned; // Track a partially repartitioned appeal in the form AppealsRepartitioned[appeal].
    }

    enum RepartitionStage { // State of the token repartition if oneShotTokenRepartition would throw because there are too many votes.
        Incoherent,
        Coherent,
        AtStake,
        Complete
    }

    struct AppealsRepartitioned {
        uint totalToRedistribute;   // Total amount of tokens we have to redistribute.
        uint nbCoherent;            // Number of coherent jurors for session.
        uint currentIncoherentVote; // Current vote for the incoherent loop.
        uint currentCoherentVote;   // Current vote we need to count.
        uint currentAtStakeVote;    // Current vote we need to count.
        RepartitionStage stage;     // Use with multipleShotTokenRepartition if oneShotTokenRepartition would throw.
    }

    Dispute[] public disputes;

    // **************************** //
    // *          Events          * //
    // **************************** //

    /** @dev Emitted when we pass to a new period.
     *  @param _period The new period.
     *  @param _session The current session.
     */
    event NewPeriod(Period _period, uint indexed _session);

    /** @dev Emitted when a juror wins or loses tokens.
      * @param _account The juror affected.
      * @param _disputeID The ID of the dispute.
      * @param _amount The amount of parts of token which was won. Can be negative for lost amounts.
      */
    event TokenShift(address indexed _account, uint _disputeID, int _amount);

    /** @dev Emited when a juror wins arbitration fees.
      * @param _account The account affected.
      * @param _disputeID The ID of the dispute.
      * @param _amount The amount of weis which was won.
      */
    event ArbitrationReward(address indexed _account, uint _disputeID, uint _amount);

    // **************************** //
    // *         Modifiers        * //
    // **************************** //
    modifier onlyBy(address _account) {require(msg.sender == _account); _;}
    modifier onlyDuring(Period _period) {require(period == _period); _;}
    modifier onlyGovernor() {require(msg.sender == governor); _;}


    /** @dev Constructor.
     *  @param _pinakion The address of the pinakion contract.
     *  @param _rng The random number generator which will be used.
     *  @param _timePerPeriod The minimal time for each period (seconds).
     *  @param _governor Address of the governor contract.
     */
    constructor(Pinakion _pinakion, RNG _rng, uint[5] _timePerPeriod, address _governor) public {
        pinakion = _pinakion;
        rng = _rng;
        lastPeriodChange = now;
        timePerPeriod = _timePerPeriod;
        governor = _governor;
    }

    // **************************** //
    // *  Functions interacting   * //
    // *  with Pinakion contract  * //
    // **************************** //

    /** @dev Callback of approveAndCall - transfer pinakions of a juror in the contract. Should be called by the pinakion contract. TRUSTED.
     *  @param _from The address making the transfer.
     *  @param _amount Amount of tokens to transfer to Kleros (in basic units).
     */
    function receiveApproval(address _from, uint _amount, address, bytes) public onlyBy(pinakion) {
        require(pinakion.transferFrom(_from, this, _amount));

        jurors[_from].balance += _amount;
    }

    /** @dev Withdraw tokens. Note that we can't withdraw the tokens which are still atStake. 
     *  Jurors can't withdraw their tokens if they have deposited some during this session.
     *  This is to prevent jurors from withdrawing tokens they could loose.
     *  @param _value The amount to withdraw.
     */
    function withdraw(uint _value) public {
        Juror storage juror = jurors[msg.sender];
        require(juror.atStake <= juror.balance); // Make sure that there is no more at stake than owned to avoid overflow.
        require(_value <= juror.balance-juror.atStake);
        require(juror.lastSession != session);

        juror.balance -= _value;
        require(pinakion.transfer(msg.sender,_value));
    }

    // **************************** //
    // *      Court functions     * //
    // *    Modifying the state   * //
    // **************************** //

    /** @dev To call to go to a new period. TRUSTED.
     */
    function passPeriod() public {
        require(now-lastPeriodChange >= timePerPeriod[uint8(period)]);

        if (period == Period.Activation) {
            rnBlock = block.number + 1;
            rng.requestRN(rnBlock);
            period = Period.Draw;
        } else if (period == Period.Draw) {
            randomNumber = rng.getUncorrelatedRN(rnBlock);
            require(randomNumber != 0);
            period = Period.Vote;
        } else if (period == Period.Vote) {
            period = Period.Appeal;
        } else if (period == Period.Appeal) {
            period = Period.Execution;
        } else if (period == Period.Execution) {
            period = Period.Activation;
            ++session;
            segmentSize = 0;
            rnBlock = 0;
            randomNumber = 0;
        }


        lastPeriodChange = now;
        NewPeriod(period, session);
    }


    /** @dev Deposit tokens in order to have chances of being drawn. Note that once tokens are deposited, 
     *  there is no possibility of depositing more.
     *  @param _value Amount of tokens (in basic units) to deposit.
     */
    function activateTokens(uint _value) public onlyDuring(Period.Activation) {
        Juror storage juror = jurors[msg.sender];
        require(_value <= juror.balance);
        require(_value >= minActivatedToken);
        require(juror.lastSession != session); // Verify that tokens were not already activated for this session.

        juror.lastSession = session;
        juror.segmentStart = segmentSize;
        segmentSize += _value;
        juror.segmentEnd = segmentSize;

    }

    /** @dev Vote a ruling. Juror must input the draw ID he was drawn.
     *  Note that the complexity is O(d), where d is amount of times the juror was drawn.
     *  Since being drawn multiple time is a rare occurrence and that a juror can always vote with less weight than it has, it is not a problem.
     *  But note that it can lead to arbitration fees being kept by the contract and never distributed.
     *  @param _disputeID The ID of the dispute the juror was drawn.
     *  @param _ruling The ruling given.
     *  @param _draws The list of draws the juror was drawn. Draw numbering starts at 1 and the numbers should be increasing.
     */
    function voteRuling(uint _disputeID, uint _ruling, uint[] _draws) public onlyDuring(Period.Vote) {
        Dispute storage dispute = disputes[_disputeID];
        Juror storage juror = jurors[msg.sender];
        VoteCounter storage voteCounter = dispute.voteCounter[dispute.appeals];
        require(dispute.lastSessionVote[msg.sender] != session); // Make sure juror hasn't voted yet.
        require(_ruling <= dispute.choices);
        // Note that it throws if the draws are incorrect.
        require(validDraws(msg.sender, _disputeID, _draws));

        dispute.lastSessionVote[msg.sender] = session;
        voteCounter.voteCount[_ruling] += _draws.length;
        if (voteCounter.winningCount < voteCounter.voteCount[_ruling]) {
            voteCounter.winningCount = voteCounter.voteCount[_ruling];
            voteCounter.winningChoice = _ruling;
        } else if (voteCounter.winningCount==voteCounter.voteCount[_ruling] && _draws.length!=0) { // Verify draw length to be non-zero to avoid the possibility of setting tie by casting 0 votes.
            voteCounter.winningChoice = 0; // It's currently a tie.
        }
        for (uint i = 0; i < _draws.length; ++i) {
            dispute.votes[dispute.appeals].push(Vote({
                account: msg.sender,
                ruling: _ruling
            }));
        }

        juror.atStake += _draws.length * getStakePerDraw();
        uint feeToPay = _draws.length * dispute.arbitrationFeePerJuror;
        msg.sender.transfer(feeToPay);
        ArbitrationReward(msg.sender, _disputeID, feeToPay);
    }

    /** @dev Steal part of the tokens and the arbitration fee of a juror who failed to vote.
     *  Note that a juror who voted but without all his weight can't be penalized.
     *  It is possible to not penalize with the maximum weight.
     *  But note that it can lead to arbitration fees being kept by the contract and never distributed.
     *  @param _jurorAddress Address of the juror to steal tokens from.
     *  @param _disputeID The ID of the dispute the juror was drawn.
     *  @param _draws The list of draws the juror was drawn. Numbering starts at 1 and the numbers should be increasing.
     */
    function penalizeInactiveJuror(address _jurorAddress, uint _disputeID, uint[] _draws) public {
        Dispute storage dispute = disputes[_disputeID];
        Juror storage inactiveJuror = jurors[_jurorAddress];
        require(period > Period.Vote);
        require(dispute.lastSessionVote[_jurorAddress] != session); // Verify the juror hasn't voted.
        dispute.lastSessionVote[_jurorAddress] = session; // Update last session to avoid penalizing multiple times.
        require(validDraws(_jurorAddress, _disputeID, _draws));
        uint penality = _draws.length * minActivatedToken * 2 * alpha / ALPHA_DIVISOR;
        penality = (penality < inactiveJuror.balance) ? penality : inactiveJuror.balance; // Make sure the penality is not higher than the balance.
        inactiveJuror.balance -= penality;
        TokenShift(_jurorAddress, _disputeID, -int(penality));
        jurors[msg.sender].balance += penality / 2; // Give half of the penalty to the caller.
        TokenShift(msg.sender, _disputeID, int(penality / 2));
        jurors[governor].balance += penality / 2; // The other half to the governor.
        TokenShift(governor, _disputeID, int(penality / 2));
        msg.sender.transfer(_draws.length*dispute.arbitrationFeePerJuror); // Give the arbitration fees to the caller.
    }

    /** @dev Execute all the token repartition.
     *  Note that this function could consume to much gas if there is too much votes. 
     *  It is O(v), where v is the number of votes for this dispute.
     *  In the next version, there will also be a function to execute it in multiple calls 
     *  (but note that one shot execution, if possible, is less expensive).
     *  @param _disputeID ID of the dispute.
     */
    function oneShotTokenRepartition(uint _disputeID) public onlyDuring(Period.Execution) {
        Dispute storage dispute = disputes[_disputeID];
        require(dispute.state == DisputeState.Open);
        require(dispute.session+dispute.appeals <= session);

        uint winningChoice = dispute.voteCounter[dispute.appeals].winningChoice;
        uint amountShift = getStakePerDraw();
        for (uint i = 0; i <= dispute.appeals; ++i) {
            // If the result is not a tie, some parties are incoherent. Note that 0 (refuse to arbitrate) winning is not a tie.
            // Result is a tie if the winningChoice is 0 (refuse to arbitrate) and the choice 0 is not the most voted choice.
            // Note that in case of a "tie" among some choices including 0, parties who did not vote 0 are considered incoherent.
            if (winningChoice!=0 || (dispute.voteCounter[dispute.appeals].voteCount[0] == dispute.voteCounter[dispute.appeals].winningCount)) {
                uint totalToRedistribute = 0;
                uint nbCoherent = 0;
                // First loop to penalize the incoherent votes.
                for (uint j = 0; j < dispute.votes[i].length; ++j) {
                    Vote storage vote = dispute.votes[i][j];
                    if (vote.ruling != winningChoice) {
                        Juror storage juror = jurors[vote.account];
                        uint penalty = amountShift<juror.balance ? amountShift : juror.balance;
                        juror.balance -= penalty;
                        TokenShift(vote.account, _disputeID, int(-penalty));
                        totalToRedistribute += penalty;
                    } else {
                        ++nbCoherent;
                    }
                }
                if (nbCoherent == 0) { // No one was coherent at this stage. Give the tokens to the governor.
                    jurors[governor].balance += totalToRedistribute;
                    TokenShift(governor, _disputeID, int(totalToRedistribute));
                } else { // otherwise, redistribute them.
                    uint toRedistribute = totalToRedistribute / nbCoherent; // Note that few fractions of tokens can be lost but due to the high amount of decimals we don't care.
                    // Second loop to redistribute.
                    for (j = 0; j < dispute.votes[i].length; ++j) {
                        vote = dispute.votes[i][j];
                        if (vote.ruling == winningChoice) {
                            juror = jurors[vote.account];
                            juror.balance += toRedistribute;
                            TokenShift(vote.account, _disputeID, int(toRedistribute));
                        }
                    }
                }
            }
            // Third loop to lower the atStake in order to unlock tokens.
            for (j = 0; j < dispute.votes[i].length; ++j) {
                vote = dispute.votes[i][j];
                juror = jurors[vote.account];
                juror.atStake -= amountShift; // Note that it can't underflow due to amountShift not changing between vote and redistribution.
            }
        }
        dispute.state = DisputeState.Executable; // Since it was solved in one shot, go directly to the executable step.
    }

    /** @dev Execute token repartition on a dispute for a specific number of votes.
     *  This should only be called if oneShotTokenRepartition will throw because there are too many votes (will use too much gas).
     *  Note that There are 3 iterations per vote. e.g. A dispute with 1 appeal (2 sessions) and 3 votes per session will have 18 iterations
     *  @param _disputeID ID of the dispute.
     *  @param _maxIterations the maxium number of votes to repartition in this iteration
     */
    function multipleShotTokenRepartition(uint _disputeID, uint _maxIterations) public onlyDuring(Period.Execution) {
        Dispute storage dispute = disputes[_disputeID];
        require(dispute.state <= DisputeState.Resolving);
        require(dispute.session+dispute.appeals <= session);
        dispute.state = DisputeState.Resolving; // Mark as resolving so oneShotTokenRepartition cannot be called on dispute.

        uint winningChoice = dispute.voteCounter[dispute.appeals].winningChoice;
        uint amountShift = getStakePerDraw();
        uint currentIterations = 0; // Total votes we have repartitioned this iteration.
        for (uint i = dispute.currentAppealToRepartition; i <= dispute.appeals; ++i) {
            // Allocate space for new AppealsRepartitioned.
            if (dispute.appealsRepartitioned.length < i+1) {
                dispute.appealsRepartitioned.length++;
            }

            // If the result is a tie, no parties are incoherent and no need to move tokens. Note that 0 (refuse to arbitrate) winning is not a tie.
            if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
                // If ruling is a tie we can skip to at stake.
                dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
            }

            // First loop to penalize the incoherent votes.
            if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Incoherent) {
                for (uint j = dispute.appealsRepartitioned[i].currentIncoherentVote; j < dispute.votes[i].length; ++j) {
                    if (currentIterations >= _maxIterations) {
                        return;
                    }
                    Vote storage vote = dispute.votes[i][j];
                    if (vote.ruling != winningChoice) {
                        Juror storage juror = jurors[vote.account];
                        uint penalty = amountShift<juror.balance ? amountShift : juror.balance;
                        juror.balance -= penalty;
                        TokenShift(vote.account, _disputeID, int(-penalty));
                        dispute.appealsRepartitioned[i].totalToRedistribute += penalty;
                    } else {
                        ++dispute.appealsRepartitioned[i].nbCoherent;
                    }

                    ++dispute.appealsRepartitioned[i].currentIncoherentVote;
                    ++currentIterations;
                }

                dispute.appealsRepartitioned[i].stage = RepartitionStage.Coherent;
            }

            // Second loop to reward coherent voters
            if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Coherent) {
                if (dispute.appealsRepartitioned[i].nbCoherent == 0) { // No one was coherent at this stage. Give the tokens to the governor.
                    jurors[governor].balance += dispute.appealsRepartitioned[i].totalToRedistribute;
                    TokenShift(governor, _disputeID, int(dispute.appealsRepartitioned[i].totalToRedistribute));
                    dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
                } else { // Otherwise, redistribute them.
                    uint toRedistribute = dispute.appealsRepartitioned[i].totalToRedistribute / dispute.appealsRepartitioned[i].nbCoherent; // Note that few fractions of tokens can be lost but due to the high amount of decimals we don't care.
                    // Second loop to redistribute.
                    for (j = dispute.appealsRepartitioned[i].currentCoherentVote; j < dispute.votes[i].length; ++j) {
                        if (currentIterations >= _maxIterations) {
                            return;
                        }
                        vote = dispute.votes[i][j];
                        if (vote.ruling == winningChoice) {
                            juror = jurors[vote.account];
                            juror.balance += toRedistribute;
                            TokenShift(vote.account, _disputeID, int(toRedistribute));
                        }

                        ++currentIterations;
                        ++dispute.appealsRepartitioned[i].currentCoherentVote;
                    }

                    dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
                }
            }

            if (dispute.appealsRepartitioned[i].stage == RepartitionStage.AtStake) {
                // Third loop to lower the atStake in order to unlock tokens.
                for (j = dispute.appealsRepartitioned[i].currentAtStakeVote; j < dispute.votes[i].length; ++j) {
                    if (currentIterations >= _maxIterations) {
                        return;
                    }
                    vote = dispute.votes[i][j];
                    juror = jurors[vote.account];
                    juror.atStake -= amountShift; // Note that it can't underflow due to amountShift not changing between vote and redistribution.

                    ++currentIterations;
                    ++dispute.appealsRepartitioned[i].currentAtStakeVote;
                }

                dispute.appealsRepartitioned[i].stage = RepartitionStage.Complete;
            }

            if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Complete) {
                ++dispute.currentAppealToRepartition;
            }
        }

        dispute.state = DisputeState.Executable;
    }

    // **************************** //
    // *      Court functions     * //
    // *     Constant and Pure    * //
    // **************************** //

    /** @dev Return the amount of jurors which are or will be drawn in the dispute.
     *  The number of jurors is doubled and 1 is added at each appeal. We have proven the formula by recurrence.
     *  This avoid having a variable number of jurors which would be updated in order to save gas.
     *  @param _disputeID The ID of the dispute we compute the amount of jurors.
     *  @return nbJurors The number of jurors which are drawn.
     */
    function amountJurors(uint _disputeID) public view returns (uint nbJurors) {
        Dispute storage dispute = disputes[_disputeID];
        return (dispute.initialNumberJurors + 1) * 2**dispute.appeals - 1;
    }

    /** @dev Must be used to verify that a juror has been draw at least _draws.length times.
     *  We have to require the user to specify the draws that lead the juror to be drawn.
     *  Because doing otherwise (looping through all draws) could consume too much gas.
     *  @param _jurorAddress Address of the juror we want to verify draws.
     *  @param _disputeID The ID of the dispute the juror was drawn.
     *  @param _draws The list of draws the juror was drawn. It draw numbering starts at 1 and the numbers should be increasing.
     *  Note that in most cases this list will just contain 1 number.
     *  @param valid true if the draws are valid.
     */
    function validDraws(address _jurorAddress, uint _disputeID, uint[] _draws) public view returns (bool valid) {
        uint draw = 0;
        Juror storage juror = jurors[_jurorAddress];
        Dispute storage dispute = disputes[_disputeID];
        uint nbJurors = amountJurors(_disputeID);

        if (juror.lastSession != session) return false; // Make sure that the tokens were deposited for this session.
        if (dispute.session+dispute.appeals != session) return false; // Make sure there is currently a dispute.
        if (period <= Period.Draw) return false; // Make sure that jurors are already drawn.
        for (uint i = 0; i < _draws.length; ++i) {
            if (_draws[i] <= draw) return false; // Make sure that draws are always increasing to avoid someone inputing the same multiple times.
            draw = _draws[i];
            if (draw > nbJurors) return false;
            uint position = uint(keccak256(randomNumber, _disputeID, draw)) % segmentSize; // Random position on the segment for draw.
            require(position >= juror.segmentStart);
            require(position < juror.segmentEnd);
        }

        return true;
    }

    // **************************** //
    // *   Arbitrator functions   * //
    // *   Modifying the state    * //
    // **************************** //

    /** @dev Create a dispute. Must be called by the arbitrable contract.
     *  Must be paid at least arbitrationCost().
     *  @param _choices Amount of choices the arbitrator can make in this dispute.
     *  @param _extraData Null for the default number. Otherwise, first 16 bytes will be used to return the number of jurors.
     *  @return disputeID ID of the dispute created.
     */
    function createDispute(uint _choices, bytes _extraData) public payable returns (uint disputeID) {
        uint16 nbJurors = extraDataToNbJurors(_extraData);
        require(msg.value >= arbitrationCost(_extraData));

        disputeID = disputes.length++;
        Dispute storage dispute = disputes[disputeID];
        dispute.arbitrated = Arbitrable(msg.sender);
        if (period < Period.Draw) // If drawing did not start schedule it for the current session.
            dispute.session = session;
        else // Otherwise schedule it for the next one.
            dispute.session = session+1;
        dispute.choices = _choices;
        dispute.initialNumberJurors = nbJurors;
        dispute.arbitrationFeePerJuror = arbitrationFeePerJuror; // We store it as the general fee can be changed through the governance mechanism.
        dispute.votes.length++;
        dispute.voteCounter.length++;

        DisputeCreation(disputeID, Arbitrable(msg.sender));
        return disputeID;
    }

    /** @dev Appeal a ruling. Note that it has to be called before the arbitrator contract calls rule.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Standard but not used by this contract.
     */
    function appeal(uint _disputeID, bytes _extraData) public payable onlyDuring(Period.Appeal) {
        super.appeal(_disputeID,_extraData);
        Dispute storage dispute = disputes[_disputeID];
        require(msg.value >= appealCost(_disputeID, _extraData));
        require(dispute.session+dispute.appeals == session); // Dispute of the current session.
        require(dispute.arbitrated == msg.sender);
        
        dispute.appeals++;
        dispute.votes.length++;
        dispute.voteCounter.length++;
    }

    /** @dev Execute the ruling of a dispute which is in the state executable. UNTRUSTED.
     *  @param disputeID ID of the dispute to execute the ruling.
     */
    function executeRuling(uint disputeID) public {
        Dispute storage dispute = disputes[disputeID];
        require(dispute.state == DisputeState.Executable);

        dispute.state = DisputeState.Executed;
        dispute.arbitrated.rule(disputeID, dispute.voteCounter[dispute.appeals].winningChoice);
    }

    // **************************** //
    // *   Arbitrator functions   * //
    // *    Constant and pure     * //
    // **************************** //

    /** @dev Compute the cost of arbitration. It is recommended not to increase it often, 
     *  as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _extraData Null for the default number. Other first 16 bits will be used to return the number of jurors.
     *  @return fee Amount to be paid.
     */
    function arbitrationCost(bytes _extraData) public view returns (uint fee) {
        return extraDataToNbJurors(_extraData) * arbitrationFeePerJuror;
    }

    /** @dev Compute the cost of appeal. It is recommended not to increase it often, 
     *  as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Is not used there.
     *  @return fee Amount to be paid.
     */
    function appealCost(uint _disputeID, bytes _extraData) public view returns (uint fee) {
        Dispute storage dispute = disputes[_disputeID];

        if(dispute.appeals >= maxAppeals) return NON_PAYABLE_AMOUNT;

        return (2*amountJurors(_disputeID) + 1) * dispute.arbitrationFeePerJuror;
    }

    /** @dev Compute the amount of jurors to be drawn.
     *  @param _extraData Null for the default number. Other first 16 bits will be used to return the number of jurors.
     *  Note that it does not check that the number of jurors is odd, but users are advised to choose a odd number of jurors.
     */
    function extraDataToNbJurors(bytes _extraData) internal view returns (uint16 nbJurors) {
        if (_extraData.length < 2)
            return defaultNumberJuror;
        else
            return (uint16(_extraData[0]) << 8) + uint16(_extraData[1]);
    }

    /** @dev Compute the minimum activated pinakions in alpha.
     *  Note there may be multiple draws for a single user on a single dispute.
     */
    function getStakePerDraw() public view returns (uint minActivatedTokenInAlpha) {
        return (alpha * minActivatedToken) / ALPHA_DIVISOR;
    }


    // **************************** //
    // *     Constant getters     * //
    // **************************** //

    /** @dev Getter for account in Vote.
     *  @param _disputeID ID of the dispute.
     *  @param _appeals Which appeal (or 0 for the initial session).
     *  @param _voteID The ID of the vote for this appeal (or initial session).
     *  @return account The address of the voter.
     */
    function getVoteAccount(uint _disputeID, uint _appeals, uint _voteID) public view returns (address account) {
        return disputes[_disputeID].votes[_appeals][_voteID].account;
    }

    /** @dev Getter for ruling in Vote.
     *  @param _disputeID ID of the dispute.
     *  @param _appeals Which appeal (or 0 for the initial session).
     *  @param _voteID The ID of the vote for this appeal (or initial session).
     *  @return ruling The ruling given by the voter.
     */
    function getVoteRuling(uint _disputeID, uint _appeals, uint _voteID) public view returns (uint ruling) {
        return disputes[_disputeID].votes[_appeals][_voteID].ruling;
    }

    /** @dev Getter for winningChoice in VoteCounter.
     *  @param _disputeID ID of the dispute.
     *  @param _appeals Which appeal (or 0 for the initial session).
     *  @return winningChoice The currently winning choice (or 0 if it's tied). Note that 0 can also be return if the majority refuses to arbitrate.
     */
    function getWinningChoice(uint _disputeID, uint _appeals) public view returns (uint winningChoice) {
        return disputes[_disputeID].voteCounter[_appeals].winningChoice;
    }

    /** @dev Getter for winningCount in VoteCounter.
     *  @param _disputeID ID of the dispute.
     *  @param _appeals Which appeal (or 0 for the initial session).
     *  @return winningCount The amount of votes the winning choice (or those who are tied) has.
     */
    function getWinningCount(uint _disputeID, uint _appeals) public view returns (uint winningCount) {
        return disputes[_disputeID].voteCounter[_appeals].winningCount;
    }

    /** @dev Getter for voteCount in VoteCounter.
     *  @param _disputeID ID of the dispute.
     *  @param _appeals Which appeal (or 0 for the initial session).
     *  @param _choice The choice.
     *  @return voteCount The amount of votes the winning choice (or those who are tied) has.
     */
    function getVoteCount(uint _disputeID, uint _appeals, uint _choice) public view returns (uint voteCount) {
        return disputes[_disputeID].voteCounter[_appeals].voteCount[_choice];
    }

    /** @dev Getter for lastSessionVote in Dispute.
     *  @param _disputeID ID of the dispute.
     *  @param _juror The juror we want to get the last session he voted.
     *  @return lastSessionVote The last session the juror voted.
     */
    function getLastSessionVote(uint _disputeID, address _juror) public view returns (uint lastSessionVote) {
        return disputes[_disputeID].lastSessionVote[_juror];
    }

    /** @dev Is the juror drawn in the draw of the dispute.
     *  @param _disputeID ID of the dispute.
     *  @param _juror The juror.
     *  @param _draw The draw. Note that it starts at 1.
     *  @return drawn True if the juror is drawn, false otherwise.
     */
    function isDrawn(uint _disputeID, address _juror, uint _draw) public view returns (bool drawn) {
        Dispute storage dispute = disputes[_disputeID];
        Juror storage juror = jurors[_juror];
        if (juror.lastSession != session
        || (dispute.session+dispute.appeals != session)
        || period<=Period.Draw
        || _draw>amountJurors(_disputeID)
        || _draw==0
        || segmentSize==0
        ) {
            return false;
        } else {
            uint position = uint(keccak256(randomNumber,_disputeID,_draw)) % segmentSize;
            return (position >= juror.segmentStart) && (position < juror.segmentEnd);
        }

    }

    /** @dev Return the current ruling of a dispute. This is useful for parties to know if they should appeal.
     *  @param _disputeID ID of the dispute.
     *  @return ruling The current ruling which will be given if there is no appeal. If it is not available, return 0.
     */
    function currentRuling(uint _disputeID) public view returns (uint ruling) {
        Dispute storage dispute = disputes[_disputeID];
        return dispute.voteCounter[dispute.appeals].winningChoice;
    }

    /** @dev Return the status of a dispute.
     *  @param _disputeID ID of the dispute to rule.
     *  @return status The status of the dispute.
     */
    function disputeStatus(uint _disputeID) public view returns (DisputeStatus status) {
        Dispute storage dispute = disputes[_disputeID];
        if (dispute.session+dispute.appeals < session) // Dispute of past session.
            return DisputeStatus.Solved;
        else if(dispute.session+dispute.appeals == session) { // Dispute of current session.
            if (dispute.state == DisputeState.Open) {
                if (period < Period.Appeal)
                    return DisputeStatus.Waiting;
                else if (period == Period.Appeal)
                    return DisputeStatus.Appealable;
                else return DisputeStatus.Solved;
            } else return DisputeStatus.Solved;
        } else return DisputeStatus.Waiting; // Dispute for future session.
    }

    // **************************** //
    // *     Governor Functions   * //
    // **************************** //

    /** @dev General call function where the contract execute an arbitrary call with data and ETH following governor orders.
     *  @param _data Transaction data.
     *  @param _value Transaction value.
     *  @param _target Transaction target.
     */
    function executeOrder(bytes32 _data, uint _value, address _target) public onlyGovernor {
        _target.call.value(_value)(_data);
    }

    /** @dev Setter for rng.
     *  @param _rng An instance of RNG.
     */
    function setRng(RNG _rng) public onlyGovernor {
        rng = _rng;
    }

    /** @dev Setter for arbitrationFeePerJuror.
     *  @param _arbitrationFeePerJuror The fee which will be paid to each juror.
     */
    function setArbitrationFeePerJuror(uint _arbitrationFeePerJuror) public onlyGovernor {
        arbitrationFeePerJuror = _arbitrationFeePerJuror;
    }

    /** @dev Setter for defaultNumberJuror.
     *  @param _defaultNumberJuror Number of drawn jurors unless specified otherwise.
     */
    function setDefaultNumberJuror(uint16 _defaultNumberJuror) public onlyGovernor {
        defaultNumberJuror = _defaultNumberJuror;
    }

    /** @dev Setter for minActivatedToken.
     *  @param _minActivatedToken Minimum of tokens to be activated (in basic units).
     */
    function setMinActivatedToken(uint _minActivatedToken) public onlyGovernor {
        minActivatedToken = _minActivatedToken;
    }

    /** @dev Setter for timePerPeriod.
     *  @param _timePerPeriod The minimum time each period lasts (seconds).
     */
    function setTimePerPeriod(uint[5] _timePerPeriod) public onlyGovernor {
        timePerPeriod = _timePerPeriod;
    }

    /** @dev Setter for alpha.
     *  @param _alpha Alpha in ‱.
     */
    function setAlpha(uint _alpha) public onlyGovernor {
        alpha = _alpha;
    }

    /** @dev Setter for maxAppeals.
     *  @param _maxAppeals Number of times a dispute can be appealed. When exceeded appeal cost becomes NON_PAYABLE_AMOUNT.
     */
    function setMaxAppeals(uint _maxAppeals) public onlyGovernor {
        maxAppeals = _maxAppeals;
    }

    /** @dev Setter for governor.
     *  @param _governor Address of the governor contract.
     */
    function setGovernor(address _governor) public onlyGovernor {
        governor = _governor;
    }
}

Contract ABI
[{"constant":true,"inputs":[],"name":"lastPeriodChange","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_data","type":"bytes32"},{"name":"_value","type":"uint256"},{"name":"_target","type":"address"}],"name":"executeOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_arbitrationFeePerJuror","type":"uint256"}],"name":"setArbitrationFeePerJuror","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_alpha","type":"uint256"}],"name":"setAlpha","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"governor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_maxAppeals","type":"uint256"}],"name":"setMaxAppeals","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"}],"name":"disputeStatus","outputs":[{"name":"status","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"}],"name":"currentRuling","outputs":[{"name":"ruling","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rnBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"activateTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"}],"name":"amountJurors","outputs":[{"name":"nbJurors","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"segmentSize","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_ruling","type":"uint256"},{"name":"_draws","type":"uint256[]"}],"name":"voteRuling","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"appeal","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"disputes","outputs":[{"name":"arbitrated","type":"address"},{"name":"session","type":"uint256"},{"name":"appeals","type":"uint256"},{"name":"choices","type":"uint256"},{"name":"initialNumberJurors","type":"uint16"},{"name":"arbitrationFeePerJuror","type":"uint256"},{"name":"state","type":"uint8"},{"name":"currentAppealToRepartition","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_defaultNumberJuror","type":"uint16"}],"name":"setDefaultNumberJuror","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"session","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_appeals","type":"uint256"},{"name":"_choice","type":"uint256"}],"name":"getVoteCount","outputs":[{"name":"voteCount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_timePerPeriod","type":"uint256[5]"}],"name":"setTimePerPeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_juror","type":"address"},{"name":"_draw","type":"uint256"}],"name":"isDrawn","outputs":[{"name":"drawn","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_minActivatedToken","type":"uint256"}],"name":"setMinActivatedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_appeals","type":"uint256"},{"name":"_voteID","type":"uint256"}],"name":"getVoteAccount","outputs":[{"name":"account","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"NON_PAYABLE_AMOUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"disputeID","type":"uint256"}],"name":"executeRuling","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"","type":"address"},{"name":"","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_maxIterations","type":"uint256"}],"name":"multipleShotTokenRepartition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"arbitrationFeePerJuror","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"defaultNumberJuror","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"passPeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_appeals","type":"uint256"},{"name":"_voteID","type":"uint256"}],"name":"getVoteRuling","outputs":[{"name":"ruling","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_juror","type":"address"}],"name":"getLastSessionVote","outputs":[{"name":"lastSessionVote","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"timePerPeriod","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_rng","type":"address"}],"name":"setRng","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_choices","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"createDispute","outputs":[{"name":"disputeID","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_disputeID","type":"uint256"}],"name":"oneShotTokenRepartition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_governor","type":"address"}],"name":"setGovernor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_appeals","type":"uint256"}],"name":"getWinningChoice","outputs":[{"name":"winningChoice","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"randomNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rng","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxAppeals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"alpha","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"jurors","outputs":[{"name":"balance","type":"uint256"},{"name":"atStake","type":"uint256"},{"name":"lastSession","type":"uint256"},{"name":"segmentStart","type":"uint256"},{"name":"segmentEnd","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_appeals","type":"uint256"}],"name":"getWinningCount","outputs":[{"name":"winningCount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getStakePerDraw","outputs":[{"name":"minActivatedTokenInAlpha","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"period","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_disputeID","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"appealCost","outputs":[{"name":"fee","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_jurorAddress","type":"address"},{"name":"_disputeID","type":"uint256"},{"name":"_draws","type":"uint256[]"}],"name":"penalizeInactiveJuror","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_extraData","type":"bytes"}],"name":"arbitrationCost","outputs":[{"name":"fee","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minActivatedToken","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pinakion","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_jurorAddress","type":"address"},{"name":"_disputeID","type":"uint256"},{"name":"_draws","type":"uint256[]"}],"name":"validDraws","outputs":[{"name":"valid","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_pinakion","type":"address"},{"name":"_rng","type":"address"},{"name":"_timePerPeriod","type":"uint256[5]"},{"name":"_governor","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_period","type":"uint8"},{"indexed":true,"name":"_session","type":"uint256"}],"name":"NewPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_account","type":"address"},{"indexed":false,"name":"_disputeID","type":"uint256"},{"indexed":false,"name":"_amount","type":"int256"}],"name":"TokenShift","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_account","type":"address"},{"indexed":false,"name":"_disputeID","type":"uint256"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ArbitrationReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_disputeID","type":"uint256"}],"name":"AppealPossible","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_disputeID","type":"uint256"},{"indexed":false,"name":"_arbitrable","type":"address"}],"name":"DisputeCreation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_disputeID","type":"uint256"},{"indexed":false,"name":"_arbitrable","type":"address"}],"name":"AppealDecision","type":"event"}]

Contract Creation Code
608060405266b1a2bc2ec500006002556003805461ffff19168117905567016345785d8a00006004556107d0600a556005600b556001600d553480156200004557600080fd5b5060405161010080620034718339810160409081528151602083015160e084015160008054600160a060020a03808616600160a060020a031992831617909255600180549285169290911691909117905542600e55919390920190620000ae60058381620000d9565b50600c8054600160a060020a031916600160a060020a0392909216919091179055506200013c915050565b82600581019282156200010a579160200282015b828111156200010a578251825591602001919060010190620000ed565b50620001189291506200011c565b5090565b6200013991905b8082111562000118576000815560010162000123565b90565b613325806200014c6000396000f3006080604052600436106102715763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302d2f34981146102765780630563324c1461029d57806306ea1c02146102c65780630c17d42c146102de5780630c340a24146102f6578063104004461461032757806310f169e81461033f5780631c3db16d1461037b57806328764b441461039357806329c8d3ce146103a85780632dd40301146103c05780632e1a7d4d146103d85780633cec9309146103f05780633f58f8c01461040557806349912f8814610463578063564a565d146104b457806359f568b91461053b5780635e3568b8146105575780636c9732481461056c5780636cd2f7311461058a57806370d17adb146105cd57806370dd2e06146106085780638249562614610620578063840bc19c1461063e5780638bb04875146106535780638f4ffcb11461066b5780639313919a146106db578063a10e6d28146106f6578063ac74bcde1461070b578063b241ff0314610737578063b3c7618e1461074c578063b5040f0a1461076a578063baaaaad21461078e578063bb2e8047146107a6578063c13517e1146107c7578063c15a679114610818578063c42cf53514610830578063c8860f4114610851578063ccbac9f51461086c578063d605787b14610881578063da93f93814610896578063db1d0fd5146108ab578063dca5f6b0146108c0578063e07a31c71461090c578063e59a29a614610927578063ef78d4fd1461093c578063f23f16e614610961578063f55ab987146109bf578063f7434ea914610a26578063f971545814610a7f578063fbf405b014610a94578063fe69dacd14610aa9575b600080fd5b34801561028257600080fd5b5061028b610b10565b60408051918252519081900360200190f35b3480156102a957600080fd5b506102c4600435602435600160a060020a0360443516610b16565b005b3480156102d257600080fd5b506102c4600435610b60565b3480156102ea57600080fd5b506102c4600435610b7c565b34801561030257600080fd5b5061030b610b98565b60408051600160a060020a039092168252519081900360200190f35b34801561033357600080fd5b506102c4600435610ba7565b34801561034b57600080fd5b50610357600435610bc3565b6040518082600281111561036757fe5b60ff16815260200191505060405180910390f35b34801561038757600080fd5b5061028b600435610c89565b34801561039f57600080fd5b5061028b610cda565b3480156103b457600080fd5b506102c4600435610ce0565b3480156103cc57600080fd5b5061028b600435610d63565b3480156103e457600080fd5b506102c4600435610db3565b3480156103fc57600080fd5b5061028b610eab565b34801561041157600080fd5b5060408051602060046044358181013583810280860185019096528085526102c4958335956024803596369695606495939492019291829185019084908082843750949750610eb19650505050505050565b60408051602060046024803582810135601f81018590048502860185019096528585526102c495833595369560449491939091019190819084018382808284375094975061113c9650505050505050565b3480156104c057600080fd5b506104cc600435611205565b6040518089600160a060020a0316600160a060020a031681526020018881526020018781526020018681526020018561ffff1661ffff16815260200184815260200183600381111561051a57fe5b60ff1681526020018281526020019850505050505050505060405180910390f35b34801561054757600080fd5b506102c461ffff6004351661126e565b34801561056357600080fd5b5061028b61129d565b34801561057857600080fd5b5061028b6004356024356044356112a3565b34801561059657600080fd5b506040805160a08181019092526102c491369160049160a4919083906005908390839080828437509396506112f995505050505050565b3480156105d957600080fd5b506105f4600435600160a060020a036024351660443561131c565b604080519115158252519081900360200190f35b34801561061457600080fd5b506102c460043561142d565b34801561062c57600080fd5b5061030b600435602435604435611449565b34801561064a57600080fd5b5061028b6114b1565b34801561065f57600080fd5b506102c46004356114d5565b34801561067757600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526102c494600160a060020a038135811695602480359660443590931695369560849492019181908401838280828437509497506115d79650505050505050565b3480156106e757600080fd5b506102c46004356024356116c3565b34801561070257600080fd5b5061028b612017565b34801561071757600080fd5b5061072061201d565b6040805161ffff9092168252519081900360200190f35b34801561074357600080fd5b506102c4612027565b34801561075857600080fd5b5061028b6004356024356044356122d1565b34801561077657600080fd5b5061028b600435600160a060020a0360243516612332565b34801561079a57600080fd5b5061028b600435612374565b3480156107b257600080fd5b506102c4600160a060020a0360043516612387565b60408051602060046024803582810135601f810185900485028601850190965285855261028b9583359536956044949193909101919081908401838280828437509497506123cd9650505050505050565b34801561082457600080fd5b506102c4600435612501565b34801561083c57600080fd5b506102c4600160a060020a03600435166129cd565b34801561085d57600080fd5b5061028b600435602435612a13565b34801561087857600080fd5b5061028b612a5c565b34801561088d57600080fd5b5061030b612a62565b3480156108a257600080fd5b5061028b612a71565b3480156108b757600080fd5b5061028b612a77565b3480156108cc57600080fd5b506108e1600160a060020a0360043516612a7d565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b34801561091857600080fd5b5061028b600435602435612aac565b34801561093357600080fd5b5061028b612af5565b34801561094857600080fd5b50610951612b05565b6040518082600481111561036757fe5b34801561096d57600080fd5b5060408051602060046024803582810135601f810185900485028601850190965285855261028b958335953695604494919390910191908190840183828082843750949750612b0e9650505050505050565b3480156109cb57600080fd5b5060408051602060046044358181013583810280860185019096528085526102c4958335600160a060020a0316956024803596369695606495939492019291829185019084908082843750949750612b869650505050505050565b348015610a3257600080fd5b506040805160206004803580820135601f810184900484028501840190955284845261028b943694929360249392840191908190840183828082843750949750612d859650505050505050565b348015610a8b57600080fd5b5061028b612da0565b348015610aa057600080fd5b5061030b612da6565b348015610ab557600080fd5b5060408051602060046044358181013583810280860185019096528085526105f4958335600160a060020a0316956024803596369695606495939492019291829185019084908082843750949750612db59650505050505050565b600e5481565b600c54600160a060020a03163314610b2d57600080fd5b604080518481529051600160a060020a0383169184916020808301926000929190829003018185875af150505050505050565b600c54600160a060020a03163314610b7757600080fd5b600255565b600c54600160a060020a03163314610b9357600080fd5b600a55565b600c54600160a060020a031681565b600c54600160a060020a03163314610bbe57600080fd5b600b55565b600080601483815481101515610bd557fe5b90600052602060002090600c02019050600d5481600201548260010154011015610c025760029150610c83565b600d5481600201548260010154011415610c7e576000600682015460ff166003811115610c2b57fe5b1415610c7557600360125460ff166004811115610c4457fe5b1015610c535760009150610c83565b600360125460ff166004811115610c6657fe5b1415610c755760019150610c83565b60029150610c83565b600091505b50919050565b600080601483815481101515610c9b57fe5b90600052602060002090600c02019050806008018160020154815481101515610cc057fe5b906000526020600020906003020160000154915050919050565b60105481565b6000808060125460ff166004811115610cf557fe5b14610cff57600080fd5b3360009081526013602052604090208054909250831115610d1f57600080fd5b600454831015610d2e57600080fd5b600d5460028301541415610d4157600080fd5b50600d546002820155600f805460038301819055929092019182905560040155565b600080601483815481101515610d7557fe5b90600052602060002090600c020190506001816002015460020a8260040160009054906101000a900461ffff1660010161ffff160203915050919050565b336000908152601360205260409020805460018201541115610dd457600080fd5b6001810154815403821115610de857600080fd5b600d5460028201541415610dfb57600080fd5b8054829003815560008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018690529051600160a060020a039092169263a9059cbb926044808401936020939083900390910190829087803b158015610e7057600080fd5b505af1158015610e84573d6000803e3d6000fd5b505050506040513d6020811015610e9a57600080fd5b50511515610ea757600080fd5b5050565b600f5481565b60008080808060028060125460ff166004811115610ecb57fe5b14610ed557600080fd5b601480548a908110610ee357fe5b90600052602060002090600c020195506013600033600160a060020a0316600160a060020a031681526020019081526020016000209450856008018660020154815481101515610f2f57fe5b60009182526020808320600d5433855260098b01909252604090932054600390920290920195501415610f6157600080fd5b6003860154881115610f7257600080fd5b610f7d338a89612db5565b1515610f8857600080fd5b600d5433600090815260098801602090815260408083209390935589518b83526002880190915291902080549091019081905560018501541015610fe45760008881526002850160205260409020546001850155878455611011565b600088815260028501602052604090205460018501541480156110075750865115155b1561101157600084555b600092505b86518310156110a75785600701866002015481548110151561103457fe5b60009182526020808320604080518082019091523381528083018d815293909101805460018082018355918652929094209051600290920201805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911781559051908201559290920191611016565b6110af612af5565b875160018701805492820290920190915560058701546040519102925033906108fc8415029084906000818181858888f193505050501580156110f6573d6000803e3d6000fd5b50604080518a815260208101849052815133927f6aabe3309b819a2115cccbcff8b8284764a6a4db2ff85b12d8cc696b945192cb928290030190a2505050505050505050565b600060038060125460ff16600481111561115257fe5b1461115c57600080fd5b6111668484612f26565b601480548590811061117457fe5b90600052602060002090600c0201915061118e8484612b0e565b34101561119a57600080fd5b600d546002830154600184015401146111b257600080fd5b8154600160a060020a031633146111c857600080fd5b6002820180546001908101909155600783018054916111e991908301612ff8565b50600882018054906111fe9060018301613021565b5050505050565b601480548290811061121357fe5b60009182526020909120600c909102018054600182015460028301546003840154600485015460058601546006870154600a90970154600160a060020a03909616975093959294919361ffff90911692909160ff9091169088565b600c54600160a060020a0316331461128557600080fd5b6003805461ffff191661ffff92909216919091179055565b600d5481565b60006014848154811015156112b457fe5b90600052602060002090600c0201600801838154811015156112d257fe5b60009182526020808320948352600260039092029094010190925250604090205492915050565b600c54600160a060020a0316331461131057600080fd5b610ea76005828161304d565b60008060008060148781548110151561133157fe5b90600052602060002090600c020192506013600087600160a060020a0316600160a060020a031681526020019081526020016000209150600d5482600201541415806113895750600d54836002015484600101540114155b806113a55750600160125460ff1660048111156113a257fe5b11155b806113b757506113b487610d63565b85115b806113c0575084155b806113cb5750600f54155b156113d95760009350611423565b600f5460115460408051918252602082018a90528181018890525190819003606001902081151561140657fe5b069050816003015481101580156114205750816004015481105b93505b5050509392505050565b600c54600160a060020a0316331461144457600080fd5b600455565b600060148481548110151561145a57fe5b90600052602060002090600c02016007018381548110151561147857fe5b906000526020600020018281548110151561148f57fe5b6000918252602090912060029091020154600160a060020a0316949350505050565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b60006014828154811015156114e657fe5b60009182526020909120600c9091020190506002600682015460ff16600381111561150d57fe5b1461151757600080fd5b60068101805460ff1916600317905580546002820154600883018054600160a060020a039093169263311a6c5692869291811061155057fe5b9060005260206000209060030201600001546040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b1580156115bb57600080fd5b505af11580156115cf573d6000803e3d6000fd5b505050505050565b600054600160a060020a03163381146115ef57600080fd5b60008054604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a03898116600483015230602483015260448201899052915191909216926323b872dd92606480820193602093909283900390910190829087803b15801561166757600080fd5b505af115801561167b573d6000803e3d6000fd5b505050506040513d602081101561169157600080fd5b5051151561169e57600080fd5b505050600160a060020a03909116600090815260136020526040902080549091019055565b600080808080808080808060048060125460ff1660048111156116e257fe5b146116ec57600080fd5b601480548e9081106116fa57fe5b60009182526020909120600c909102019a50600160068c015460ff16600381111561172157fe5b111561172c57600080fd5b600d5460028c015460018d015401111561174557600080fd5b60068b01805460ff1916600117905560028b015460088c018054909190811061176a57fe5b9060005260206000209060030201600001549950611786612af5565b9850600097508a600a015496505b60028b01548711611ff057600b8b01546001880111156117c457600b8b018054906117c2906001830161308b565b505b8915801561182f57508a6008018b600201548154811015156117e257fe5b9060005260206000209060030201600101548b6008018c6002015481548110151561180957fe5b906000526020600020906003020160020160008081526020019081526020016000205414155b156118745760028b600b018881548110151561184757fe5b60009182526020909120600560069092020101805460ff1916600183600381111561186e57fe5b02179055505b6000600b8c0180548990811061188657fe5b600091825260209091206005600690920201015460ff1660038111156118a857fe5b1415611aad57600b8b018054889081106118be57fe5b90600052602060002090600602016002015495505b60078b018054889081106118e357fe5b600091825260209091200154861015611a6d578b881061190257612008565b60078b0180548890811061191257fe5b906000526020600020018681548110151561192957fe5b90600052602060002090600202019450898560010154141515611a06578454600160a060020a0316600090815260136020526040902080549094508910611971578354611973565b885b92508284600001600082825403925050819055508460000160009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e85600003604051808381526020018281526020019250505060405180910390a2828b600b01888154811015156119ea57fe5b6000918252602090912060069091020180549091019055611a32565b600b8b01805488908110611a1657fe5b6000918252602090912060016006909202018101805490910190555b600b8b01805488908110611a4257fe5b60009182526020909120600260069092020101805460019081019091559788019795909501946118d3565b60018b600b0188815481101515611a8057fe5b60009182526020909120600560069092020101805460ff19166001836003811115611aa757fe5b02179055505b6001600b8c01805489908110611abf57fe5b600091825260209091206005600690920201015460ff166003811115611ae157fe5b1415611e2f57600b8b01805488908110611af757fe5b90600052602060002090600602016001015460001415611c2757600b8b01805488908110611b2157fe5b90600052602060002090600602016000015460136000600c60009054906101000a9004600160a060020a0316600160a060020a0316600160a060020a0316815260200190815260200160002060000160008282540192505081905550600c60009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e8d600b018a815481101515611bbd57fe5b60009182526020918290206006909102015460408051938452918301528051918290030190a260028b600b0188815481101515611bf657fe5b60009182526020909120600560069092020101805460ff19166001836003811115611c1d57fe5b0217905550611e2f565b600b8b01805488908110611c3757fe5b9060005260206000209060060201600101548b600b0188815481101515611c5a57fe5b906000526020600020906006020160000154811515611c7557fe5b0491508a600b0187815481101515611c8957fe5b90600052602060002090600602016003015495505b60078b01805488908110611cae57fe5b600091825260209091200154861015611def578b8810611ccd57612008565b60078b01805488908110611cdd57fe5b9060005260206000200186815481101515611cf457fe5b906000526020600020906002020194508985600101541415611daf57601360008660000160009054906101000a9004600160a060020a0316600160a060020a0316600160a060020a0316815260200190815260200160002093508184600001600082825401925050819055508460000160009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e84604051808381526020018281526020019250505060405180910390a25b600b8b01805460019099019888908110611dc557fe5b90600052602060002090600602016003016000815460010191905081905550856001019550611c9e565b60028b600b0188815481101515611e0257fe5b60009182526020909120600560069092020101805460ff19166001836003811115611e2957fe5b02179055505b6002600b8c01805489908110611e4157fe5b600091825260209091206005600690920201015460ff166003811115611e6357fe5b1415611f9f57600b8b01805488908110611e7957fe5b90600052602060002090600602016004015495505b60078b01805488908110611e9e57fe5b600091825260209091200154861015611f5f578b8810611ebd57612008565b60078b01805488908110611ecd57fe5b9060005260206000200186815481101515611ee457fe5b6000918252602080832060029092029091018054600160a060020a0316835260139091526040909120600181810180548d90039055600b8e0180549b9091019a9297509095509088908110611f3557fe5b90600052602060002090600602016004016000815460010191905081905550856001019550611e8e565b60038b600b0188815481101515611f7257fe5b60009182526020909120600560069092020101805460ff19166001836003811115611f9957fe5b02179055505b6003600b8c01805489908110611fb157fe5b600091825260209091206005600690920201015460ff166003811115611fd357fe5b1415611fe557600a8b01805460010190555b866001019650611794565b60068b0180546002919060ff19166001835b02179055505b50505050505050505050505050565b60025481565b60035461ffff1681565b60125460059060ff16600481111561203b57fe5b60ff166005811061204857fe5b0154600e544203101561205a57600080fd5b600060125460ff16600481111561206d57fe5b141561211357600143810160108190559054604080517f7b9c34e0000000000000000000000000000000000000000000000000000000008152600481019390935251600160a060020a0390911691637b9c34e091602480830192600092919082900301818387803b1580156120e157600080fd5b505af11580156120f5573d6000803e3d6000fd5b5050601280546001935090915060ff191682805b021790555061227c565b600160125460ff16600481111561212657fe5b14156121e657600154601054604080517f1c73601e000000000000000000000000000000000000000000000000000000008152600481019290925251600160a060020a0390921691631c73601e916024808201926020929091908290030181600087803b15801561219657600080fd5b505af11580156121aa573d6000803e3d6000fd5b505050506040513d60208110156121c057600080fd5b5051601181905515156121d257600080fd5b601280546002919060ff1916600183612109565b600260125460ff1660048111156121f957fe5b141561221357601280546003919060ff1916600183612109565b600360125460ff16600481111561222657fe5b141561224057601280546004919060ff1916600183612109565b600460125460ff16600481111561225357fe5b141561227c576012805460ff19169055600d805460010190556000600f81905560108190556011555b42600e55600d546012546040517f68c618b4722a30adfd435aefec043781d40a8a871689115e91a2257ca097fab59160ff1690808260048111156122bc57fe5b60ff16815260200191505060405180910390a2565b60006014848154811015156122e257fe5b90600052602060002090600c02016007018381548110151561230057fe5b906000526020600020018281548110151561231757fe5b90600052602060002090600202016001015490509392505050565b600060148381548110151561234357fe5b60009182526020808320600160a060020a03861684526009600c909302019190910190526040902054905092915050565b60058181811061238057fe5b0154905081565b600c54600160a060020a0316331461239e57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008060006123db84612f7a565b91506123e684612d85565b3410156123f257600080fd5b601480549061240490600183016130b7565b925060148381548110151561241557fe5b60009182526020909120600c90910201805473ffffffffffffffffffffffffffffffffffffffff1916331781559050600160125460ff16600481111561245757fe5b101561246a57600d546001820155612477565b600d546001908101908201555b6003810185905560048101805461ffff191661ffff84161790556002546005820155600781018054906124ad9060018301612ff8565b50600881018054906124c29060018301613021565b5060408051338152905184917f141dfc18aa6a56fc816f44f0e9e2f1ebc92b15ab167770e17db5b084c10ed995919081900360200190a2505092915050565b60008080808080808080808060048060125460ff16600481111561252157fe5b1461252b57600080fd5b601480548e90811061253957fe5b600091825260208220600c909102019c5060068d015460ff16600381111561255d57fe5b1461256757600080fd5b600d5460028d015460018e015401111561258057600080fd5b8b6008018c6002015481548110151561259557fe5b9060005260206000209060030201600001549a506125b1612af5565b9950600098505b60028c015489116129b7578a15158061262d57508b6008018c600201548154811015156125e157fe5b9060005260206000209060030201600101548c6008018d6002015481548110151561260857fe5b9060005260206000209060030201600201600080815260200190815260200160002054145b15612919576000975060009650600095505b60078c0180548a90811061264f57fe5b6000918252602090912001548610156127535760078c0180548a90811061267257fe5b906000526020600020018681548110151561268957fe5b906000526020600020906002020194508a8560010154141515612741578454600160a060020a0316600090815260136020526040902080549094508a106126d15783546126d3565b895b92508284600001600082825403925050819055508460000160009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e85600003604051808381526020018281526020019250505060405180910390a296820196612748565b8660010196505b85600101955061263f565b8615156127f6578760136000600c60009054906101000a9004600160a060020a0316600160a060020a0316600160a060020a0316815260200190815260200160002060000160008282540192505081905550600c60009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e8a604051808381526020018281526020019250505060405180910390a2612919565b868881151561280157fe5b049150600095505b60078c0180548a90811061281957fe5b6000918252602090912001548610156129195760078c0180548a90811061283c57fe5b906000526020600020018681548110151561285357fe5b906000526020600020906002020194508a8560010154141561290e57601360008660000160009054906101000a9004600160a060020a0316600160a060020a0316600160a060020a0316815260200190815260200160002093508184600001600082825401925050819055508460000160009054906101000a9004600160a060020a0316600160a060020a03166000805160206132da8339815191528e84604051808381526020018281526020019250505060405180910390a25b856001019550612809565b600095505b60078c0180548a90811061292e57fe5b6000918252602090912001548610156129ac5760078c0180548a90811061295157fe5b906000526020600020018681548110151561296857fe5b6000918252602080832060029092029091018054600160a060020a0316835260139091526040909120600181810180548e900390559790970196909550935061291e565b8860010198506125b8565b60068c0180546002919060ff1916600183612002565b600c54600160a060020a031633146129e457600080fd5b600c805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000601483815481101515612a2457fe5b90600052602060002090600c020160080182815481101515612a4257fe5b906000526020600020906003020160000154905092915050565b60115481565b600154600160a060020a031681565b600b5481565b600a5481565b601360205260009081526040902080546001820154600283015460038401546004909401549293919290919085565b6000601483815481101515612abd57fe5b90600052602060002090600c020160080182815481101515612adb57fe5b906000526020600020906003020160010154905092915050565b600454600a546127109102045b90565b60125460ff1681565b600080601484815481101515612b2057fe5b90600052602060002090600c02019050600b548160020154101515612b67577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9150612b7f565b8060050154612b7585610d63565b6002026001010291505b5092915050565b6000806000601485815481101515612b9a57fe5b60009182526020808320600160a060020a038a16845260139091526040909220600c90910290910193509150600260125460ff166004811115612bd957fe5b11612be357600080fd5b600d54600160a060020a03871660009081526009850160205260409020541415612c0c57600080fd5b600d54600160a060020a0387166000908152600985016020526040902055612c35868686612db5565b1515612c4057600080fd5b600a5460045485516127109291020260020204905081600001548110612c67578154612c69565b805b8254819003835560408051878152600083900360208201528151929350600160a060020a038916926000805160206132da833981519152929181900390910190a23360008181526013602090815260409182902080546002860490810190915582518981529182015281516000805160206132da833981519152929181900390910190a2600281600c8054600160a060020a03908116600090815260136020526040902080549490930490930190915554166000805160206132da833981519152866002846040805193845291900460208301528051918290030190a26005830154845160405133929190910280156108fc02916000818181858888f19350505050158015612d7c573d6000803e3d6000fd5b50505050505050565b6000600254612d9383612f7a565b61ffff160290505b919050565b60045481565b600054600160a060020a031681565b600160a060020a0383166000908152601360205260408120601480548392918391829182918291908a908110612de757fe5b90600052602060002090600c02019350612e0089610d63565b600d54600287015491945014612e195760009650612f19565b600d54600285015460018601540114612e355760009650612f19565b600160125460ff166004811115612e4857fe5b11612e565760009650612f19565b600091505b8751821015612f1457858883815181101515612e7357fe5b6020908102909101015111612e8b5760009650612f19565b8782815181101515612e9957fe5b90602001906020020151955082861115612eb65760009650612f19565b600f5460115460408051918252602082018c905281810189905251908190036060019020811515612ee357fe5b06905084600301548110151515612ef957600080fd5b60048501548110612f0957600080fd5b816001019150612e5b565b600196505b5050505050509392505050565b8181612f328282612b0e565b341015612f3e57600080fd5b60408051338152905185917f9c9b64db9e130f48381bf697abf638e73117dbfbfd7a4484f2da3ba188f4187d919081900360200190a250505050565b6000600282511015612f93575060035461ffff16612d9b565b816001815181101515612fa257fe5b90602001015160f860020a900460f860020a0260f860020a90046008836000815181101515612fcd57fe5b90602001015160f860020a900460f860020a0260f860020a900461ffff169060020a02019050612d9b565b81548183558181111561301c5760008381526020902061301c9181019083016130e3565b505050565b81548183558181111561301c5760030281600302836000526020600020918201910161301c9190613106565b826005810192821561307b579160200282015b8281111561307b578251825591602001919060010190613060565b50613087929150613126565b5090565b81548183558181111561301c5760060281600602836000526020600020918201910161301c9190613140565b81548183558181111561301c57600c0281600c02836000526020600020918201910161301c9190613181565b612b0291905b808211156130875760006130fd828261321d565b506001016130e9565b612b0291905b80821115613087576000808255600182015560030161310c565b612b0291905b80821115613087576000815560010161312c565b612b0291905b80821115613087576000808255600182018190556002820181905560038201819055600482015560058101805460ff19169055600601613146565b612b0291905b8082111561308757805473ffffffffffffffffffffffffffffffffffffffff19168155600060018201819055600282018190556003820181905560048201805461ffff191690556005820181905560068201805460ff191690556131ee6007830182613241565b6131fc60088301600061325f565b600a820160009055600b820160006132149190613280565b50600c01613187565b508054600082556002029060005260206000209081019061323e91906132a1565b50565b508054600082559060005260206000209081019061323e91906130e3565b508054600082556003029060005260206000209081019061323e9190613106565b508054600082556006029060005260206000209081019061323e9190613140565b612b0291905b8082111561308757805473ffffffffffffffffffffffffffffffffffffffff19168155600060018201556002016132a7560072f86a9d9fab69e4814ca24b54076a6e59b7463230974d7b72bed55777fbcf6ca165627a7a72305820824254605b88c70ed124563b6a1191cadb75a50be299db38ee0fe0e4af8864df002900000000000000000000000093ed3fbe21207ec2e8f2d3c3de6e058cb73bc04d0000000000000000000000001738b62e403090666687243e758b1c29edffc90e00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fa4000000000000000000000000000000000000000000000000000000000000143700000000000000000000000000000000000000000000000000000000000000e1000000000000000000000000000b5ade4ac1fe9ccc08addc2c10070642335117f


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

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000093ed3fbe21207ec2e8f2d3c3de6e058cb73bc04d
Arg [1] : 0000000000000000000000001738b62e403090666687243e758b1c29edffc90e
Arg [2] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 000000000000000000000000000000000000000000000000000000000001fa40
Arg [5] : 0000000000000000000000000000000000000000000000000000000000014370
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000e10
Arg [7] : 00000000000000000000000000b5ade4ac1fe9ccc08addc2c10070642335117f


   Swarm Source:
bzzr://824254605b88c70ed124563b6a1191cadb75a50be299db38ee0fe0e4af8864df
Block Age transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.