ETH Price: $3,103.12 (-0.78%)
Gas: 3 Gwei

Contract

0x2832373DDDad96Bbfb44f1B7dA11B6541026BF40
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Update Status198570062024-05-12 22:45:356 days ago1715553935IN
FOAM: Registry
0 ETH0.000100392.99813269
Update Status198495902024-05-11 21:51:237 days ago1715464283IN
FOAM: Registry
0 ETH0.00009992.98235949
Exit198096912024-05-06 7:56:3513 days ago1714982195IN
FOAM: Registry
0 ETH0.000273384.63327132
Apply194432792024-03-15 22:20:2364 days ago1710541223IN
FOAM: Registry
0 ETH0.0046718329.27765402
Apply194432012024-03-15 22:04:3564 days ago1710540275IN
FOAM: Registry
0 ETH0.0060337231.13861067
Apply190718872024-01-23 20:57:23116 days ago1706043443IN
FOAM: Registry
0 ETH0.0023760212.26208281
Update Status183051892023-10-08 10:32:35223 days ago1696761155IN
FOAM: Registry
0 ETH0.000171715.12615495
Update Status183050982023-10-08 10:13:59223 days ago1696760039IN
FOAM: Registry
0 ETH0.00015755.3573887
Update Status183050902023-10-08 10:12:23223 days ago1696759943IN
FOAM: Registry
0 ETH0.000182476.20652636
Update Status183050902023-10-08 10:12:23223 days ago1696759943IN
FOAM: Registry
0 ETH0.000206496.16655008
Update Status183050072023-10-08 9:55:47223 days ago1696758947IN
FOAM: Registry
0 ETH0.00018326.22883253
Update Status183050072023-10-08 9:55:47223 days ago1696758947IN
FOAM: Registry
0 ETH0.000209836.26403675
Apply182550562023-10-01 10:21:11230 days ago1696155671IN
FOAM: Registry
0 ETH0.00140637.25758761
Exit182371412023-09-28 22:13:59233 days ago1695939239IN
FOAM: Registry
0 ETH0.00046957.95724352
Exit182371382023-09-28 22:13:23233 days ago1695939203IN
FOAM: Registry
0 ETH0.000461967.82937171
Withdraw182371312023-09-28 22:11:59233 days ago1695939119IN
FOAM: Registry
0 ETH0.000575078.12660305
Apply179958712023-08-26 2:27:23267 days ago1693016843IN
FOAM: Registry
0 ETH0.0026950414.26267302
Challenge174675472023-06-13 0:33:35341 days ago1686616415IN
FOAM: Registry
0 ETH0.0041350814.95548432
Apply170485112023-04-14 23:06:59400 days ago1681513619IN
FOAM: Registry
0 ETH0.0047730224.63240224
Exit160845242022-11-30 18:14:59535 days ago1669832099IN
FOAM: Registry
0 ETH0.0009384915.90887185
Exit160845222022-11-30 18:14:35535 days ago1669832075IN
FOAM: Registry
0 ETH0.0009426315.97900731
Exit160845192022-11-30 18:13:59535 days ago1669832039IN
FOAM: Registry
0 ETH0.0009275615.72363675
Exit160845162022-11-30 18:13:23535 days ago1669832003IN
FOAM: Registry
0 ETH0.0011470415.07209184
Update Status160845082022-11-30 18:11:47535 days ago1669831907IN
FOAM: Registry
0 ETH0.0005345415.96309924
Update Status160845062022-11-30 18:11:23535 days ago1669831883IN
FOAM: Registry
0 ETH0.0005026815.01170245
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Registry

Compiler Version
v0.4.24+commit.e67f0147

Optimization Enabled:
Yes with 300 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-09-07
*/

pragma solidity ^0.4.24;


contract EIP20Interface {
    /* This is a slight change to the ERC20 base standard.
    function totalSupply() constant returns (uint256 supply);
    is replaced with:
    uint256 public totalSupply;
    This automatically creates a getter function for the totalSupply.
    This is moved to the base contract since public getter functions are not
    currently recognised as an implementation of the matching abstract
    function by the compiler.
    */
    /// total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) public view returns (uint256 balance);

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) public returns (bool success);

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) public returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) public view returns (uint256 remaining);

    // solhint-disable-next-line no-simple-event-func-name
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

/*
Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
.*/


contract EIP20 is EIP20Interface {

    uint256 constant private MAX_UINT256 = 2**256 - 1;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;
    /*
    NOTE:
    The following variables are OPTIONAL vanities. One does not have to include them.
    They allow one to customise the token contract & in no way influences the core functionality.
    Some wallets/interfaces might not even bother to look at this information.
    */
    string public name;                   //fancy name: eg Simon Bucks
    uint8 public decimals;                //How many decimals to show.
    string public symbol;                 //An identifier: eg SBX

    function EIP20(
        uint256 _initialAmount,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol
    ) public {
        balances[msg.sender] = _initialAmount;               // Give the creator all initial tokens
        totalSupply = _initialAmount;                        // Update total supply
        name = _tokenName;                                   // Set the name for display purposes
        decimals = _decimalUnits;                            // Amount of decimals for display purposes
        symbol = _tokenSymbol;                               // Set the symbol for display purposes
    }

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(balances[msg.sender] >= _value);
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value);
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        }
        emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
}


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

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

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

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

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

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

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


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


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

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

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

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

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



/**
 * @title ERC165
 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
 */
interface ERC165 {

  /**
   * @notice Query if a contract implements an interface
   * @param _interfaceId The interface identifier, as specified in ERC-165
   * @dev Interface identification is specified in ERC-165. This function
   * uses less than 30,000 gas.
   */
  function supportsInterface(bytes4 _interfaceId)
    external
    view
    returns (bool);
}

contract CanCheckERC165 {
  bytes4 constant InvalidID = 0xffffffff;
  bytes4 constant ERC165ID = 0x01ffc9a7;
  function doesContractImplementInterface(address _contract, bytes4 _interfaceId) external view returns (bool) {
      uint256 success;
      uint256 result;

      (success, result) = noThrowCall(_contract, ERC165ID);
      if ((success==0)||(result==0)) {
          return false;
      }

      (success, result) = noThrowCall(_contract, InvalidID);
      if ((success==0)||(result!=0)) {
          return false;
      }

      (success, result) = noThrowCall(_contract, _interfaceId);
      if ((success==1)&&(result==1)) {
          return true;
      }
      return false;
  }

  function noThrowCall(address _contract, bytes4 _interfaceId) internal view returns (uint256 success, uint256 result) {
    bytes4 erc165ID = ERC165ID;

    assembly {
            let x := mload(0x40)               // Find empty storage location using "free memory pointer"
            mstore(x, erc165ID)                // Place signature at begining of empty storage
            mstore(add(x, 0x04), _interfaceId) // Place first argument directly next to signature

            success := staticcall(
                                30000,         // 30k gas
                                _contract,     // To addr
                                x,             // Inputs are stored at location x
                                0x20,          // Inputs are 32 bytes long
                                x,             // Store output over input (saves space)
                                0x20)          // Outputs are 32 bytes long

            result := mload(x)                 // Load the result
    }
  }
}


library DLL {

  uint constant NULL_NODE_ID = 0;

  struct Node {
    uint next;
    uint prev;
  }

  struct Data {
    mapping(uint => Node) dll;
  }

  function isEmpty(Data storage self) public view returns (bool) {
    return getStart(self) == NULL_NODE_ID;
  }

  function contains(Data storage self, uint _curr) public view returns (bool) {
    if (isEmpty(self) || _curr == NULL_NODE_ID) {
      return false;
    } 

    bool isSingleNode = (getStart(self) == _curr) && (getEnd(self) == _curr);
    bool isNullNode = (getNext(self, _curr) == NULL_NODE_ID) && (getPrev(self, _curr) == NULL_NODE_ID);
    return isSingleNode || !isNullNode;
  }

  function getNext(Data storage self, uint _curr) public view returns (uint) {
    return self.dll[_curr].next;
  }

  function getPrev(Data storage self, uint _curr) public view returns (uint) {
    return self.dll[_curr].prev;
  }

  function getStart(Data storage self) public view returns (uint) {
    return getNext(self, NULL_NODE_ID);
  }

  function getEnd(Data storage self) public view returns (uint) {
    return getPrev(self, NULL_NODE_ID);
  }

  /**
  @dev Inserts a new node between _prev and _next. When inserting a node already existing in 
  the list it will be automatically removed from the old position.
  @param _prev the node which _new will be inserted after
  @param _curr the id of the new node being inserted
  @param _next the node which _new will be inserted before
  */
  function insert(Data storage self, uint _prev, uint _curr, uint _next) public {
    require(_curr != NULL_NODE_ID);

    remove(self, _curr);

    require(_prev == NULL_NODE_ID || contains(self, _prev));
    require(_next == NULL_NODE_ID || contains(self, _next));

    require(getNext(self, _prev) == _next);
    require(getPrev(self, _next) == _prev);

    self.dll[_curr].prev = _prev;
    self.dll[_curr].next = _next;

    self.dll[_prev].next = _curr;
    self.dll[_next].prev = _curr;
  }

  function remove(Data storage self, uint _curr) public {
    if (!contains(self, _curr)) {
      return;
    }

    uint next = getNext(self, _curr);
    uint prev = getPrev(self, _curr);

    self.dll[next].prev = prev;
    self.dll[prev].next = next;

    delete self.dll[_curr];
  }
}

library AttributeStore {
    struct Data {
        mapping(bytes32 => uint) store;
    }

    function getAttribute(Data storage self, bytes32 _UUID, string _attrName)
    public view returns (uint) {
        bytes32 key = keccak256(_UUID, _attrName);
        return self.store[key];
    }

    function setAttribute(Data storage self, bytes32 _UUID, string _attrName, uint _attrVal)
    public {
        bytes32 key = keccak256(_UUID, _attrName);
        self.store[key] = _attrVal;
    }
}


/**
@title Partial-Lock-Commit-Reveal Voting scheme with ERC20 tokens
@author Team: Aspyn Palatnick, Cem Ozer, Yorke Rhodes
*/
contract PLCRVoting {

    // ============
    // EVENTS:
    // ============

    event _VoteCommitted(uint indexed pollID, uint numTokens, address indexed voter);
    event _VoteRevealed(uint indexed pollID, uint numTokens, uint votesFor, uint votesAgainst, uint indexed choice, address indexed voter);
    event _PollCreated(uint voteQuorum, uint commitEndDate, uint revealEndDate, uint indexed pollID, address indexed creator);
    event _VotingRightsGranted(uint numTokens, address indexed voter);
    event _VotingRightsWithdrawn(uint numTokens, address indexed voter);
    event _TokensRescued(uint indexed pollID, address indexed voter);

    // ============
    // DATA STRUCTURES:
    // ============

    using AttributeStore for AttributeStore.Data;
    using DLL for DLL.Data;
    using SafeMath for uint;

    struct Poll {
        uint commitEndDate;     /// expiration date of commit period for poll
        uint revealEndDate;     /// expiration date of reveal period for poll
        uint voteQuorum;	    /// number of votes required for a proposal to pass
        uint votesFor;		    /// tally of votes supporting proposal
        uint votesAgainst;      /// tally of votes countering proposal
        mapping(address => bool) didCommit;  /// indicates whether an address committed a vote for this poll
        mapping(address => bool) didReveal;   /// indicates whether an address revealed a vote for this poll
    }

    // ============
    // STATE VARIABLES:
    // ============

    uint constant public INITIAL_POLL_NONCE = 0;
    uint public pollNonce;

    mapping(uint => Poll) public pollMap; // maps pollID to Poll struct
    mapping(address => uint) public voteTokenBalance; // maps user's address to voteToken balance

    mapping(address => DLL.Data) dllMap;
    AttributeStore.Data store;

    EIP20Interface public token;

    /**
    @dev Initializer. Can only be called once.
    @param _token The address where the ERC20 token contract is deployed
    */
    constructor(address _token) public {
        require(_token != 0 && address(token) == 0);

        token = EIP20Interface(_token);
        pollNonce = INITIAL_POLL_NONCE;
    }

    // ================
    // TOKEN INTERFACE:
    // ================

    /**
    @notice Loads _numTokens ERC20 tokens into the voting contract for one-to-one voting rights
    @dev Assumes that msg.sender has approved voting contract to spend on their behalf
    @param _numTokens The number of votingTokens desired in exchange for ERC20 tokens
    */
    function requestVotingRights(uint _numTokens) public {
        require(token.balanceOf(msg.sender) >= _numTokens);
        voteTokenBalance[msg.sender] += _numTokens;
        require(token.transferFrom(msg.sender, this, _numTokens));
        emit _VotingRightsGranted(_numTokens, msg.sender);
    }

    /**
    @notice Withdraw _numTokens ERC20 tokens from the voting contract, revoking these voting rights
    @param _numTokens The number of ERC20 tokens desired in exchange for voting rights
    */
    function withdrawVotingRights(uint _numTokens) external {
        uint availableTokens = voteTokenBalance[msg.sender].sub(getLockedTokens(msg.sender));
        require(availableTokens >= _numTokens);
        voteTokenBalance[msg.sender] -= _numTokens;
        require(token.transfer(msg.sender, _numTokens));
        emit _VotingRightsWithdrawn(_numTokens, msg.sender);
    }

    /**
    @dev Unlocks tokens locked in unrevealed vote where poll has ended
    @param _pollID Integer identifier associated with the target poll
    */
    function rescueTokens(uint _pollID) public {
        require(isExpired(pollMap[_pollID].revealEndDate));
        require(dllMap[msg.sender].contains(_pollID));

        dllMap[msg.sender].remove(_pollID);
        emit _TokensRescued(_pollID, msg.sender);
    }

    /**
    @dev Unlocks tokens locked in unrevealed votes where polls have ended
    @param _pollIDs Array of integer identifiers associated with the target polls
    */
    function rescueTokensInMultiplePolls(uint[] _pollIDs) public {
        // loop through arrays, rescuing tokens from all
        for (uint i = 0; i < _pollIDs.length; i++) {
            rescueTokens(_pollIDs[i]);
        }
    }

    // =================
    // VOTING INTERFACE:
    // =================

    /**
    @notice Commits vote using hash of choice and secret salt to conceal vote until reveal
    @param _pollID Integer identifier associated with target poll
    @param _secretHash Commit keccak256 hash of voter's choice and salt (tightly packed in this order)
    @param _numTokens The number of tokens to be committed towards the target poll
    @param _prevPollID The ID of the poll that the user has voted the maximum number of tokens in which is still less than or equal to numTokens
    */
    function commitVote(uint _pollID, bytes32 _secretHash, uint _numTokens, uint _prevPollID) public {
        require(commitPeriodActive(_pollID));

        // if msg.sender doesn't have enough voting rights,
        // request for enough voting rights
        if (voteTokenBalance[msg.sender] < _numTokens) {
            uint remainder = _numTokens.sub(voteTokenBalance[msg.sender]);
            requestVotingRights(remainder);
        }

        // make sure msg.sender has enough voting rights
        require(voteTokenBalance[msg.sender] >= _numTokens);
        // prevent user from committing to zero node placeholder
        require(_pollID != 0);
        // prevent user from committing a secretHash of 0
        require(_secretHash != 0);

        // Check if _prevPollID exists in the user's DLL or if _prevPollID is 0
        require(_prevPollID == 0 || dllMap[msg.sender].contains(_prevPollID));

        uint nextPollID = dllMap[msg.sender].getNext(_prevPollID);

        // edge case: in-place update
        if (nextPollID == _pollID) {
            nextPollID = dllMap[msg.sender].getNext(_pollID);
        }

        require(validPosition(_prevPollID, nextPollID, msg.sender, _numTokens));
        dllMap[msg.sender].insert(_prevPollID, _pollID, nextPollID);

        bytes32 UUID = attrUUID(msg.sender, _pollID);

        store.setAttribute(UUID, "numTokens", _numTokens);
        store.setAttribute(UUID, "commitHash", uint(_secretHash));

        pollMap[_pollID].didCommit[msg.sender] = true;
        emit _VoteCommitted(_pollID, _numTokens, msg.sender);
    }

    /**
    @notice                 Commits votes using hashes of choices and secret salts to conceal votes until reveal
    @param _pollIDs         Array of integer identifiers associated with target polls
    @param _secretHashes    Array of commit keccak256 hashes of voter's choices and salts (tightly packed in this order)
    @param _numsTokens      Array of numbers of tokens to be committed towards the target polls
    @param _prevPollIDs     Array of IDs of the polls that the user has voted the maximum number of tokens in which is still less than or equal to numTokens
    */
    function commitVotes(uint[] _pollIDs, bytes32[] _secretHashes, uint[] _numsTokens, uint[] _prevPollIDs) external {
        // make sure the array lengths are all the same
        require(_pollIDs.length == _secretHashes.length);
        require(_pollIDs.length == _numsTokens.length);
        require(_pollIDs.length == _prevPollIDs.length);

        // loop through arrays, committing each individual vote values
        for (uint i = 0; i < _pollIDs.length; i++) {
            commitVote(_pollIDs[i], _secretHashes[i], _numsTokens[i], _prevPollIDs[i]);
        }
    }

    /**
    @dev Compares previous and next poll's committed tokens for sorting purposes
    @param _prevID Integer identifier associated with previous poll in sorted order
    @param _nextID Integer identifier associated with next poll in sorted order
    @param _voter Address of user to check DLL position for
    @param _numTokens The number of tokens to be committed towards the poll (used for sorting)
    @return valid Boolean indication of if the specified position maintains the sort
    */
    function validPosition(uint _prevID, uint _nextID, address _voter, uint _numTokens) public constant returns (bool valid) {
        bool prevValid = (_numTokens >= getNumTokens(_voter, _prevID));
        // if next is zero node, _numTokens does not need to be greater
        bool nextValid = (_numTokens <= getNumTokens(_voter, _nextID) || _nextID == 0);
        return prevValid && nextValid;
    }

    /**
    @notice Reveals vote with choice and secret salt used in generating commitHash to attribute committed tokens
    @param _pollID Integer identifier associated with target poll
    @param _voteOption Vote choice used to generate commitHash for associated poll
    @param _salt Secret number used to generate commitHash for associated poll
    */
    function revealVote(uint _pollID, uint _voteOption, uint _salt) public {
        // Make sure the reveal period is active
        require(revealPeriodActive(_pollID));
        require(pollMap[_pollID].didCommit[msg.sender]);                         // make sure user has committed a vote for this poll
        require(!pollMap[_pollID].didReveal[msg.sender]);                        // prevent user from revealing multiple times
        require(keccak256(abi.encodePacked(_voteOption, _salt)) == getCommitHash(msg.sender, _pollID)); // compare resultant hash from inputs to original commitHash

        uint numTokens = getNumTokens(msg.sender, _pollID);

        if (_voteOption == 1) {// apply numTokens to appropriate poll choice
            pollMap[_pollID].votesFor += numTokens;
        } else {
            pollMap[_pollID].votesAgainst += numTokens;
        }

        dllMap[msg.sender].remove(_pollID); // remove the node referring to this vote upon reveal
        pollMap[_pollID].didReveal[msg.sender] = true;

        emit _VoteRevealed(_pollID, numTokens, pollMap[_pollID].votesFor, pollMap[_pollID].votesAgainst, _voteOption, msg.sender);
    }

    /**
    @notice             Reveals multiple votes with choices and secret salts used in generating commitHashes to attribute committed tokens
    @param _pollIDs     Array of integer identifiers associated with target polls
    @param _voteOptions Array of vote choices used to generate commitHashes for associated polls
    @param _salts       Array of secret numbers used to generate commitHashes for associated polls
    */
    function revealVotes(uint[] _pollIDs, uint[] _voteOptions, uint[] _salts) external {
        // make sure the array lengths are all the same
        require(_pollIDs.length == _voteOptions.length);
        require(_pollIDs.length == _salts.length);

        // loop through arrays, revealing each individual vote values
        for (uint i = 0; i < _pollIDs.length; i++) {
            revealVote(_pollIDs[i], _voteOptions[i], _salts[i]);
        }
    }

    /**
    @param _pollID Integer identifier associated with target poll
    @param _salt Arbitrarily chosen integer used to generate secretHash
    @return correctVotes Number of tokens voted for winning option
    */
    function getNumPassingTokens(address _voter, uint _pollID, uint _salt) public constant returns (uint correctVotes) {
        require(pollEnded(_pollID));
        require(pollMap[_pollID].didReveal[_voter]);

        uint winningChoice = isPassed(_pollID) ? 1 : 0;
        bytes32 winnerHash = keccak256(abi.encodePacked(winningChoice, _salt));
        bytes32 commitHash = getCommitHash(_voter, _pollID);

        require(winnerHash == commitHash);

        return getNumTokens(_voter, _pollID);
    }

    // ==================
    // POLLING INTERFACE:
    // ==================

    /**
    @dev Initiates a poll with canonical configured parameters at pollID emitted by PollCreated event
    @param _voteQuorum Type of majority (out of 100) that is necessary for poll to be successful
    @param _commitDuration Length of desired commit period in seconds
    @param _revealDuration Length of desired reveal period in seconds
    */
    function startPoll(uint _voteQuorum, uint _commitDuration, uint _revealDuration) public returns (uint pollID) {
        pollNonce = pollNonce + 1;

        uint commitEndDate = block.timestamp.add(_commitDuration);
        uint revealEndDate = commitEndDate.add(_revealDuration);

        pollMap[pollNonce] = Poll({
            voteQuorum: _voteQuorum,
            commitEndDate: commitEndDate,
            revealEndDate: revealEndDate,
            votesFor: 0,
            votesAgainst: 0
        });

        emit _PollCreated(_voteQuorum, commitEndDate, revealEndDate, pollNonce, msg.sender);
        return pollNonce;
    }

    /**
    @notice Determines if proposal has passed
    @dev Check if votesFor out of totalVotes exceeds votesQuorum (requires pollEnded)
    @param _pollID Integer identifier associated with target poll
    */
    function isPassed(uint _pollID) constant public returns (bool passed) {
        require(pollEnded(_pollID));

        Poll memory poll = pollMap[_pollID];
        return (100 * poll.votesFor) > (poll.voteQuorum * (poll.votesFor + poll.votesAgainst));
    }

    // ----------------
    // POLLING HELPERS:
    // ----------------

    /**
    @dev Gets the total winning votes for reward distribution purposes
    @param _pollID Integer identifier associated with target poll
    @return Total number of votes committed to the winning option for specified poll
    */
    function getTotalNumberOfTokensForWinningOption(uint _pollID) constant public returns (uint numTokens) {
        require(pollEnded(_pollID));

        if (isPassed(_pollID))
            return pollMap[_pollID].votesFor;
        else
            return pollMap[_pollID].votesAgainst;
    }

    /**
    @notice Determines if poll is over
    @dev Checks isExpired for specified poll's revealEndDate
    @return Boolean indication of whether polling period is over
    */
    function pollEnded(uint _pollID) constant public returns (bool ended) {
        require(pollExists(_pollID));

        return isExpired(pollMap[_pollID].revealEndDate);
    }

    /**
    @notice Checks if the commit period is still active for the specified poll
    @dev Checks isExpired for the specified poll's commitEndDate
    @param _pollID Integer identifier associated with target poll
    @return Boolean indication of isCommitPeriodActive for target poll
    */
    function commitPeriodActive(uint _pollID) constant public returns (bool active) {
        require(pollExists(_pollID));

        return !isExpired(pollMap[_pollID].commitEndDate);
    }

    /**
    @notice Checks if the reveal period is still active for the specified poll
    @dev Checks isExpired for the specified poll's revealEndDate
    @param _pollID Integer identifier associated with target poll
    */
    function revealPeriodActive(uint _pollID) constant public returns (bool active) {
        require(pollExists(_pollID));

        return !isExpired(pollMap[_pollID].revealEndDate) && !commitPeriodActive(_pollID);
    }

    /**
    @dev Checks if user has committed for specified poll
    @param _voter Address of user to check against
    @param _pollID Integer identifier associated with target poll
    @return Boolean indication of whether user has committed
    */
    function didCommit(address _voter, uint _pollID) constant public returns (bool committed) {
        require(pollExists(_pollID));

        return pollMap[_pollID].didCommit[_voter];
    }

    /**
    @dev Checks if user has revealed for specified poll
    @param _voter Address of user to check against
    @param _pollID Integer identifier associated with target poll
    @return Boolean indication of whether user has revealed
    */
    function didReveal(address _voter, uint _pollID) constant public returns (bool revealed) {
        require(pollExists(_pollID));

        return pollMap[_pollID].didReveal[_voter];
    }

    /**
    @dev Checks if a poll exists
    @param _pollID The pollID whose existance is to be evaluated.
    @return Boolean Indicates whether a poll exists for the provided pollID
    */
    function pollExists(uint _pollID) constant public returns (bool exists) {
        return (_pollID != 0 && _pollID <= pollNonce);
    }

    // ---------------------------
    // DOUBLE-LINKED-LIST HELPERS:
    // ---------------------------

    /**
    @dev Gets the bytes32 commitHash property of target poll
    @param _voter Address of user to check against
    @param _pollID Integer identifier associated with target poll
    @return Bytes32 hash property attached to target poll
    */
    function getCommitHash(address _voter, uint _pollID) constant public returns (bytes32 commitHash) {
        return bytes32(store.getAttribute(attrUUID(_voter, _pollID), "commitHash"));
    }

    /**
    @dev Wrapper for getAttribute with attrName="numTokens"
    @param _voter Address of user to check against
    @param _pollID Integer identifier associated with target poll
    @return Number of tokens committed to poll in sorted poll-linked-list
    */
    function getNumTokens(address _voter, uint _pollID) constant public returns (uint numTokens) {
        return store.getAttribute(attrUUID(_voter, _pollID), "numTokens");
    }

    /**
    @dev Gets top element of sorted poll-linked-list
    @param _voter Address of user to check against
    @return Integer identifier to poll with maximum number of tokens committed to it
    */
    function getLastNode(address _voter) constant public returns (uint pollID) {
        return dllMap[_voter].getPrev(0);
    }

    /**
    @dev Gets the numTokens property of getLastNode
    @param _voter Address of user to check against
    @return Maximum number of tokens committed in poll specified
    */
    function getLockedTokens(address _voter) constant public returns (uint numTokens) {
        return getNumTokens(_voter, getLastNode(_voter));
    }

    /*
    @dev Takes the last node in the user's DLL and iterates backwards through the list searching
    for a node with a value less than or equal to the provided _numTokens value. When such a node
    is found, if the provided _pollID matches the found nodeID, this operation is an in-place
    update. In that case, return the previous node of the node being updated. Otherwise return the
    first node that was found with a value less than or equal to the provided _numTokens.
    @param _voter The voter whose DLL will be searched
    @param _numTokens The value for the numTokens attribute in the node to be inserted
    @return the node which the propoded node should be inserted after
    */
    function getInsertPointForNumTokens(address _voter, uint _numTokens, uint _pollID)
    constant public returns (uint prevNode) {
      // Get the last node in the list and the number of tokens in that node
      uint nodeID = getLastNode(_voter);
      uint tokensInNode = getNumTokens(_voter, nodeID);

      // Iterate backwards through the list until reaching the root node
      while(nodeID != 0) {
        // Get the number of tokens in the current node
        tokensInNode = getNumTokens(_voter, nodeID);
        if(tokensInNode <= _numTokens) { // We found the insert point!
          if(nodeID == _pollID) {
            // This is an in-place update. Return the prev node of the node being updated
            nodeID = dllMap[_voter].getPrev(nodeID);
          }
          // Return the insert point
          return nodeID;
        }
        // We did not find the insert point. Continue iterating backwards through the list
        nodeID = dllMap[_voter].getPrev(nodeID);
      }

      // The list is empty, or a smaller value than anything else in the list is being inserted
      return nodeID;
    }

    // ----------------
    // GENERAL HELPERS:
    // ----------------

    /**
    @dev Checks if an expiration date has been reached
    @param _terminationDate Integer timestamp of date to compare current timestamp with
    @return expired Boolean indication of whether the terminationDate has passed
    */
    function isExpired(uint _terminationDate) constant public returns (bool expired) {
        return (block.timestamp > _terminationDate);
    }

    /**
    @dev Generates an identifier which associates a user and a poll together
    @param _pollID Integer identifier associated with target poll
    @return UUID Hash which is deterministic from _user and _pollID
    */
    function attrUUID(address _user, uint _pollID) public pure returns (bytes32 UUID) {
        return keccak256(abi.encodePacked(_user, _pollID));
    }
}


contract Parameterizer is Ownable, CanCheckERC165 {

  // ------
  // EVENTS
  // ------

  event _ReparameterizationProposal(string name, uint value, bytes32 propID, uint deposit, uint appEndDate);
  event _NewChallenge(bytes32 indexed propID, uint challengeID, uint commitEndDate, uint revealEndDate);
  event _ProposalAccepted(bytes32 indexed propID, string name, uint value);
  event _ProposalExpired(bytes32 indexed propID);
  event _ChallengeSucceeded(bytes32 indexed propID, uint indexed challengeID, uint rewardPool, uint totalTokens);
  event _ChallengeFailed(bytes32 indexed propID, uint indexed challengeID, uint rewardPool, uint totalTokens);
  event _RewardClaimed(uint indexed challengeID, uint reward);


  // ------
  // DATA STRUCTURES
  // ------

  using SafeMath for uint;

  struct ParamProposal {
    uint appExpiry;
    uint challengeID;
    uint deposit;
    string name;
    address owner;
    uint processBy;
    uint value;
  }

  struct Challenge {
    uint rewardPool;        // (remaining) pool of tokens distributed amongst winning voters
    address challenger;     // owner of Challenge
    bool resolved;          // indication of if challenge is resolved
    uint stake;             // number of tokens at risk for either party during challenge
    uint winningTokens;     // (remaining) amount of tokens used for voting by the winning side
    mapping(address => bool) tokenClaims;
  }

  // ------
  // STATE
  // ------

  mapping(bytes32 => uint) public params;

  // maps challengeIDs to associated challenge data
  mapping(uint => Challenge) public challenges;

  // maps pollIDs to intended data change if poll passes
  mapping(bytes32 => ParamProposal) public proposals;

  // Global Variables
  EIP20Interface public token;
  PLCRVoting public voting;
  uint public PROCESSBY = 604800; // 7 days

  string constant NEW_REGISTRY = "_newRegistry";
  bytes32 constant NEW_REGISTRY_KEC = keccak256(abi.encodePacked(NEW_REGISTRY));
  bytes32 constant DISPENSATION_PCT_KEC = keccak256(abi.encodePacked("dispensationPct"));
  bytes32 constant P_DISPENSATION_PCT_KEC = keccak256(abi.encodePacked("pDispensationPct"));

  // todo: fill this in with the interface ID of the registry migration interface we will have
  bytes4 public REGISTRY_INTERFACE_REQUIREMENT;

  // ------------
  // CONSTRUCTOR
  // ------------

  /**
  @dev constructor
  @param _tokenAddr        address of the token which parameterizes this system
  @param _plcrAddr         address of a PLCR voting contract for the provided token
  @param _minDeposit       minimum deposit for listing to be whitelisted
  @param _pMinDeposit      minimum deposit to propose a reparameterization
  @param _applyStageLen    period over which applicants wait to be whitelisted
  @param _pApplyStageLen   period over which reparmeterization proposals wait to be processed
  @param _dispensationPct  percentage of losing party's deposit distributed to winning party
  @param _pDispensationPct percentage of losing party's deposit distributed to winning party in parameterizer
  @param _commitStageLen  length of commit period for voting
  @param _pCommitStageLen length of commit period for voting in parameterizer
  @param _revealStageLen  length of reveal period for voting
  @param _pRevealStageLen length of reveal period for voting in parameterizer
  @param _voteQuorum       type of majority out of 100 necessary for vote success
  @param _pVoteQuorum      type of majority out of 100 necessary for vote success in parameterizer
  @param _newRegistryIface ERC165 interface ID requirement (not a votable parameter)
  */
  constructor(
    address _tokenAddr,
    address _plcrAddr,
    uint _minDeposit,
    uint _pMinDeposit,
    uint _applyStageLen,
    uint _pApplyStageLen,
    uint _commitStageLen,
    uint _pCommitStageLen,
    uint _revealStageLen,
    uint _pRevealStageLen,
    uint _dispensationPct,
    uint _pDispensationPct,
    uint _voteQuorum,
    uint _pVoteQuorum,
    bytes4 _newRegistryIface
    ) Ownable() public {
      token = EIP20Interface(_tokenAddr);
      voting = PLCRVoting(_plcrAddr);
      REGISTRY_INTERFACE_REQUIREMENT = _newRegistryIface;

      set("minDeposit", _minDeposit);
      set("pMinDeposit", _pMinDeposit);
      set("applyStageLen", _applyStageLen);
      set("pApplyStageLen", _pApplyStageLen);
      set("commitStageLen", _commitStageLen);
      set("pCommitStageLen", _pCommitStageLen);
      set("revealStageLen", _revealStageLen);
      set("pRevealStageLen", _pRevealStageLen);
      set("dispensationPct", _dispensationPct);
      set("pDispensationPct", _pDispensationPct);
      set("voteQuorum", _voteQuorum);
      set("pVoteQuorum", _pVoteQuorum);
  }

  // -----------------------
  // TOKEN HOLDER INTERFACE
  // -----------------------

  /**
  @notice propose a reparamaterization of the key _name's value to _value.
  @param _name the name of the proposed param to be set
  @param _value the proposed value to set the param to be set
  */
  function proposeReparameterization(string _name, uint _value) public returns (bytes32) {
    uint deposit = get("pMinDeposit");
    bytes32 propID = keccak256(abi.encodePacked(_name, _value));
    bytes32 _nameKec = keccak256(abi.encodePacked(_name));

    if (_nameKec == DISPENSATION_PCT_KEC ||
       _nameKec == P_DISPENSATION_PCT_KEC) {
        require(_value <= 100);
    }

    if(keccak256(abi.encodePacked(_name)) == NEW_REGISTRY_KEC) {
      require(getNewRegistry() == address(0));
      require(_value != 0);
      require(msg.sender == owner);
      require((_value & 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff) == _value); // i.e., _value is zero-padded address
      require(this.doesContractImplementInterface(address(_value), REGISTRY_INTERFACE_REQUIREMENT));
    }

    require(!propExists(propID)); // Forbid duplicate proposals
    require(get(_name) != _value); // Forbid NOOP reparameterizations

    // attach name and value to pollID
    proposals[propID] = ParamProposal({
      appExpiry: now.add(get("pApplyStageLen")),
      challengeID: 0,
      deposit: deposit,
      name: _name,
      owner: msg.sender,
      processBy: now.add(get("pApplyStageLen"))
        .add(get("pCommitStageLen"))
        .add(get("pRevealStageLen"))
        .add(PROCESSBY),
      value: _value
    });

    require(token.transferFrom(msg.sender, this, deposit)); // escrow tokens (deposit amt)

    emit _ReparameterizationProposal(_name, _value, propID, deposit, proposals[propID].appExpiry);
    return propID;
  }

  /**
  @notice gets the address of the new registry, if set.
  */
  function getNewRegistry() public view returns (address) {
    //return address(get(NEW_REGISTRY));
    return address(params[NEW_REGISTRY_KEC]); // bit of an optimization
  }

  /**
  @notice challenge the provided proposal ID, and put tokens at stake to do so.
  @param _propID the proposal ID to challenge
  */
  function challengeReparameterization(bytes32 _propID) public returns (uint) {
    ParamProposal memory prop = proposals[_propID];
    uint deposit = prop.deposit;

    require(propExists(_propID) && prop.challengeID == 0);

    //start poll
    uint pollID = voting.startPoll(
      get("pVoteQuorum"),
      get("pCommitStageLen"),
      get("pRevealStageLen")
    );

    challenges[pollID] = Challenge({
      challenger: msg.sender,
      rewardPool: SafeMath.sub(100, get("pDispensationPct")).mul(deposit).div(100),
      stake: deposit,
      resolved: false,
      winningTokens: 0
    });

    proposals[_propID].challengeID = pollID;       // update listing to store most recent challenge

    //take tokens from challenger
    require(token.transferFrom(msg.sender, this, deposit));

    (uint commitEndDate, uint revealEndDate,,,) = voting.pollMap(pollID);

    emit _NewChallenge(_propID, pollID, commitEndDate, revealEndDate);
    return pollID;
  }

  /**
  @notice for the provided proposal ID, set it, resolve its challenge, or delete it depending on whether it can be set, has a challenge which can be resolved, or if its "process by" date has passed
  @param _propID the proposal ID to make a determination and state transition for
  */
  function processProposal(bytes32 _propID) public {
    ParamProposal storage prop = proposals[_propID];
    address propOwner = prop.owner;
    uint propDeposit = prop.deposit;


    // Before any token transfers, deleting the proposal will ensure that if reentrancy occurs the
    // prop.owner and prop.deposit will be 0, thereby preventing theft
   if (canBeSet(_propID)) {
      // There is no challenge against the proposal. The processBy date for the proposal has not
     // passed, but the proposal's appExpirty date has passed.
      set(prop.name, prop.value);
      emit _ProposalAccepted(_propID, prop.name, prop.value);
      delete proposals[_propID];
      require(token.transfer(propOwner, propDeposit));
    } else if (challengeCanBeResolved(_propID)) {
      // There is a challenge against the proposal.
      resolveChallenge(_propID);
    } else if (now > prop.processBy) {
      // There is no challenge against the proposal, but the processBy date has passed.
      emit _ProposalExpired(_propID);
      delete proposals[_propID];
      require(token.transfer(propOwner, propDeposit));
    } else {
      // There is no challenge against the proposal, and neither the appExpiry date nor the
      // processBy date has passed.
      revert();
    }

    assert(get("dispensationPct") <= 100);
    assert(get("pDispensationPct") <= 100);

    // verify that future proposal appExpiry and processBy times will not overflow
    now.add(get("pApplyStageLen"))
      .add(get("pCommitStageLen"))
      .add(get("pRevealStageLen"))
      .add(PROCESSBY);

    delete proposals[_propID];
  }

  /**
  @notice claim the tokens owed for the msg.sender in the provided challenge
  @param _challengeID the challenge ID to claim tokens for
  @param _salt the salt used to vote in the challenge being withdrawn for
  */
  function claimReward(uint _challengeID, uint _salt) public {
    // ensure voter has not already claimed tokens and challenge results have been processed
    require(challenges[_challengeID].tokenClaims[msg.sender] == false);
    require(challenges[_challengeID].resolved == true);

    uint voterTokens = voting.getNumPassingTokens(msg.sender, _challengeID, _salt);
    uint reward = voterReward(msg.sender, _challengeID, _salt);

    // subtract voter's information to preserve the participation ratios of other voters
    // compared to the remaining pool of rewards
    challenges[_challengeID].winningTokens = challenges[_challengeID].winningTokens.sub(voterTokens);
    challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);

    // ensures a voter cannot claim tokens again
    challenges[_challengeID].tokenClaims[msg.sender] = true;

    emit _RewardClaimed(_challengeID, reward);
    require(token.transfer(msg.sender, reward));
  }

  // --------
  // GETTERS
  // --------

  /**
  @dev                Calculates the provided voter's token reward for the given poll.
  @param _voter       The address of the voter whose reward balance is to be returned
  @param _challengeID The ID of the challenge the voter's reward is being calculated for
  @param _salt        The salt of the voter's commit hash in the given poll
  @return             The uint indicating the voter's reward
  */
  function voterReward(address _voter, uint _challengeID, uint _salt)
  public view returns (uint) {
    uint winningTokens = challenges[_challengeID].winningTokens;
    uint rewardPool = challenges[_challengeID].rewardPool;
    uint voterTokens = voting.getNumPassingTokens(_voter, _challengeID, _salt);
    return voterTokens.mul(rewardPool).div(winningTokens);
  }

  /**
  @notice Determines whether a proposal passed its application stage without a challenge
  @param _propID The proposal ID for which to determine whether its application stage passed without a challenge
  */
  function canBeSet(bytes32 _propID) view public returns (bool) {
    ParamProposal memory prop = proposals[_propID];

    return (now > prop.appExpiry && now < prop.processBy && prop.challengeID == 0);
  }

  /**
  @notice Determines whether a proposal exists for the provided proposal ID
  @param _propID The proposal ID whose existance is to be determined
  */
  function propExists(bytes32 _propID) view public returns (bool) {
    return proposals[_propID].processBy > 0;
  }

  /**
  @notice Determines whether the provided proposal ID has a challenge which can be resolved
  @param _propID The proposal ID whose challenge to inspect
  */
  function challengeCanBeResolved(bytes32 _propID) view public returns (bool) {
    ParamProposal memory prop = proposals[_propID];
    Challenge memory challenge = challenges[prop.challengeID];

    return (prop.challengeID > 0 && challenge.resolved == false &&
            voting.pollEnded(prop.challengeID));
  }

  /**
  @notice Determines the number of tokens to awarded to the winning party in a challenge
  @param _challengeID The challengeID to determine a reward for
  */
  function challengeWinnerReward(uint _challengeID) public view returns (uint) {
    if(voting.getTotalNumberOfTokensForWinningOption(_challengeID) == 0) {
      // Edge case, nobody voted, give all tokens to the challenger.
      return challenges[_challengeID].stake.mul(2);
    }

    return challenges[_challengeID].stake.mul(2).sub(challenges[_challengeID].rewardPool);
  }

  /**
  @notice gets the parameter keyed by the provided name value from the params mapping
  @param _name the key whose value is to be determined
  */
  function get(string _name) public view returns (uint value) {
    return params[keccak256(abi.encodePacked(_name))];
  }

  /**
  @dev                Getter for Challenge tokenClaims mappings
  @param _challengeID The challengeID to query
  @param _voter       The voter whose claim status to query for the provided challengeID
  */
  function tokenClaims(uint _challengeID, address _voter) public view returns (bool) {
    return challenges[_challengeID].tokenClaims[_voter];
  }

  // ----------------
  // PRIVATE FUNCTIONS
  // ----------------

  /**
  @dev resolves a challenge for the provided _propID. It must be checked in advance whether the _propID has a challenge on it
  @param _propID the proposal ID whose challenge is to be resolved.
  */
  function resolveChallenge(bytes32 _propID) private {
    ParamProposal memory prop = proposals[_propID];
    Challenge storage challenge = challenges[prop.challengeID];

    // winner gets back their full staked deposit, and dispensationPct*loser's stake
    uint reward = challengeWinnerReward(prop.challengeID);

    challenge.winningTokens =
      voting.getTotalNumberOfTokensForWinningOption(prop.challengeID);
    challenge.resolved = true;

    if (voting.isPassed(prop.challengeID)) { // The challenge failed
      if(prop.processBy > now) {
        set(prop.name, prop.value);
      }
      emit _ChallengeFailed(_propID, prop.challengeID, challenge.rewardPool, challenge.winningTokens);
      require(token.transfer(prop.owner, reward));
    }
    else { // The challenge succeeded or nobody voted
      emit _ChallengeSucceeded(_propID, prop.challengeID, challenge.rewardPool, challenge.winningTokens);
      require(token.transfer(challenges[prop.challengeID].challenger, reward));
    }
  }

  /**
  @dev sets the param keted by the provided name to the provided value
  @param _name the name of the param to be set
  @param _value the value to set the param to be set
  */
  function set(string _name, uint _value) private {
    params[keccak256(abi.encodePacked(_name))] = _value;
  }
}


contract SupercedesRegistry is ERC165 {
  function canReceiveListing(bytes32 listingHash, uint applicationExpiry, bool whitelisted, address owner, uint unstakedDeposit, uint challengeID) external view returns (bool);
  function receiveListing(bytes32 listingHash, uint applicationExpiry, bool whitelisted, address owner, uint unstakedDeposit, uint challengeID) external;
  function getSupercedesRegistryInterfaceID() public pure returns (bytes4) {
    SupercedesRegistry i;
    return i.canReceiveListing.selector ^ i.receiveListing.selector;
  }
}



contract Registry {

    // ------
    // EVENTS
    // ------

    event _Application(bytes32 indexed listingHash, uint deposit, uint appEndDate, string data);
    event _Challenge(bytes32 indexed listingHash, uint challengeID, uint deposit, string data);
    event _Deposit(bytes32 indexed listingHash, uint added, uint newTotal);
    event _Withdrawal(bytes32 indexed listingHash, uint withdrew, uint newTotal);
    event _ApplicationWhitelisted(bytes32 indexed listingHash);
    event _ApplicationRemoved(bytes32 indexed listingHash);
    event _ListingRemoved(bytes32 indexed listingHash);
    event _ListingWithdrawn(bytes32 indexed listingHash);
    event _TouchAndRemoved(bytes32 indexed listingHash);
    event _ChallengeFailed(bytes32 indexed listingHash, uint indexed challengeID, uint rewardPool, uint totalTokens);
    event _ChallengeSucceeded(bytes32 indexed listingHash, uint indexed challengeID, uint rewardPool, uint totalTokens);
    event _RewardClaimed(uint indexed challengeID, uint reward, address voter);
    event _ListingMigrated(bytes32 indexed listingHash, address newRegistry);

    using SafeMath for uint;

    struct Listing {
        uint applicationExpiry; // Expiration date of apply stage
        bool whitelisted;       // Indicates registry status
        address owner;          // Owner of Listing
        uint unstakedDeposit;   // Number of tokens in the listing not locked in a challenge
        uint challengeID;       // Corresponds to a PollID in PLCRVoting
    }

    struct Challenge {
        uint rewardPool;        // (remaining) Pool of tokens to be distributed to winning voters
        address challenger;     // Owner of Challenge
        bool resolved;          // Indication of if challenge is resolved
        uint stake;             // Number of tokens at stake for either party during challenge
        uint totalTokens;       // (remaining) Number of tokens used in voting by the winning side
        mapping(address => bool) tokenClaims; // Indicates whether a voter has claimed a reward yet
    }

    // Maps challengeIDs to associated challenge data
    mapping(uint => Challenge) public challenges;

    // Maps listingHashes to associated listingHash data
    mapping(bytes32 => Listing) public listings;

    // Maps number of applications per address
    mapping(address => uint) public numApplications;

    // Maps total amount staked per address
    mapping(address => uint) public totalStaked;

    // Global Variables
    EIP20Interface public token;
    PLCRVoting public voting;
    Parameterizer public parameterizer;
    string public constant version = "1";

    // ------------
    // CONSTRUCTOR:
    // ------------

    /**
    @dev Contructor         Sets the addresses for token, voting, and parameterizer
    @param _tokenAddr       Address of the TCR's intrinsic ERC20 token
    @param _plcrAddr        Address of a PLCR voting contract for the provided token
    @param _paramsAddr      Address of a Parameterizer contract
    */
    constructor(
        address _tokenAddr,
        address _plcrAddr,
        address _paramsAddr
    ) public {
        token = EIP20Interface(_tokenAddr);
        voting = PLCRVoting(_plcrAddr);
        parameterizer = Parameterizer(_paramsAddr);
    }

    // --------------------
    // PUBLISHER INTERFACE:
    // --------------------

    /**
    @dev                Allows a user to start an application. Takes tokens from user and sets
                        apply stage end time.
    @param _listingHash The hash of a potential listing a user is applying to add to the registry
    @param _amount      The number of ERC20 tokens a user is willing to potentially stake
    @param _data        Extra data relevant to the application. Think IPFS hashes.
    */
    function apply(bytes32 _listingHash, uint _amount, string _data) onlyIfCurrentRegistry external {
        require(!isWhitelisted(_listingHash));
        require(!appWasMade(_listingHash));
        require(_amount >= parameterizer.get("minDeposit"));

        // Sets owner
        Listing storage listing = listings[_listingHash];
        listing.owner = msg.sender;

        // Sets apply stage end time
        listing.applicationExpiry = block.timestamp.add(parameterizer.get("applyStageLen"));
        listing.unstakedDeposit = _amount;

        // Tally application count per address
        numApplications[listing.owner] = numApplications[listing.owner].add(1);

        // Tally total staked amount
        totalStaked[listing.owner] = totalStaked[listing.owner].add(_amount);

        // Transfers tokens from user to Registry contract
        require(token.transferFrom(listing.owner, this, _amount));
        emit _Application(_listingHash, _amount, listing.applicationExpiry, _data);
    }

    /**
    @dev                Allows the owner of a listingHash to increase their unstaked deposit.
    @param _listingHash A listingHash msg.sender is the owner of
    @param _amount      The number of ERC20 tokens to increase a user's unstaked deposit
    */
    function deposit(bytes32 _listingHash, uint _amount) external {
        Listing storage listing = listings[_listingHash];

        require(listing.owner == msg.sender);

        listing.unstakedDeposit = listing.unstakedDeposit.add(_amount);

        // Update total stake
        totalStaked[listing.owner] = totalStaked[listing.owner].add(_amount);

        require(token.transferFrom(msg.sender, this, _amount));

        emit _Deposit(_listingHash, _amount, listing.unstakedDeposit);
    }

    /**
    @dev                Allows the owner of a listingHash to decrease their unstaked deposit.
    @param _listingHash A listingHash msg.sender is the owner of.
    @param _amount      The number of ERC20 tokens to withdraw from the unstaked deposit.
    */
    function withdraw(bytes32 _listingHash, uint _amount) external {
        Listing storage listing = listings[_listingHash];

        require(listing.owner == msg.sender);
        require(_amount <= listing.unstakedDeposit);
        require(listing.unstakedDeposit.sub(_amount) >= parameterizer.get("minDeposit"));

        listing.unstakedDeposit = listing.unstakedDeposit.sub(_amount);

        require(token.transfer(msg.sender, _amount));

        emit _Withdrawal(_listingHash, _amount, listing.unstakedDeposit);
    }

    /**
    @dev                Allows the owner of a listingHash to remove the listingHash from the whitelist
                        Returns all tokens to the owner of the listingHash
    @param _listingHash A listingHash msg.sender is the owner of.
    */
    function exit(bytes32 _listingHash) external {
        Listing storage listing = listings[_listingHash];

        require(msg.sender == listing.owner);
        require(isWhitelisted(_listingHash));

        // Cannot exit during ongoing challenge
        require(listing.challengeID == 0 || challenges[listing.challengeID].resolved);

        // Remove listingHash & return tokens
        resetListing(_listingHash);
        emit _ListingWithdrawn(_listingHash);
    }

    // -----------------------
    // TOKEN HOLDER INTERFACE:
    // -----------------------

    /**
    @dev                Starts a poll for a listingHash which is either in the apply stage or
                        already in the whitelist. Tokens are taken from the challenger and the
                        applicant's deposits are locked.
    @param _listingHash The listingHash being challenged, whether listed or in application
    @param _deposit     The deposit with which the listing is challenge (used to be `minDeposit`)
    @param _data        Extra data relevant to the challenge. Think IPFS hashes.
    */
    function challenge(bytes32 _listingHash, uint _deposit, string _data) onlyIfCurrentRegistry external returns (uint challengeID) {
        Listing storage listing = listings[_listingHash];
        uint minDeposit = parameterizer.get("minDeposit");

        // Listing must be in apply stage or already on the whitelist
        require(appWasMade(_listingHash) || listing.whitelisted);
        // Prevent multiple challenges
        require(listing.challengeID == 0 || challenges[listing.challengeID].resolved);

        if (listing.unstakedDeposit < minDeposit) {
            // Not enough tokens, listingHash auto-delisted
            resetListing(_listingHash);
            emit _TouchAndRemoved(_listingHash);
            return 0;
        }

        // Starts poll
        uint pollID = voting.startPoll(
            parameterizer.get("voteQuorum"),
            parameterizer.get("commitStageLen"),
            parameterizer.get("revealStageLen")
        );

        challenges[pollID] = Challenge({
            challenger: msg.sender,
            rewardPool: ((100 - parameterizer.get("dispensationPct")) * _deposit) / 100,
            stake: _deposit,
            resolved: false,
            totalTokens: 0
        });

        // Updates listingHash to store most recent challenge
        listing.challengeID = pollID;

        // make sure _deposit is more than minDeposit and smaller than unstaked deposit
        require(_deposit >= minDeposit && _deposit <= listing.unstakedDeposit);

        // Locks tokens for listingHash during challenge
        listing.unstakedDeposit = listing.unstakedDeposit.sub(_deposit);

        // Takes tokens from challenger
        require(token.transferFrom(msg.sender, this, _deposit));

        emit _Challenge(_listingHash, pollID, _deposit, _data);
        return pollID;
    }

    /**
    @dev                Updates a listingHash's status from 'application' to 'listing' or resolves
                        a challenge if one exists.
    @param _listingHash The listingHash whose status is being updated
    */
    function updateStatus(bytes32 _listingHash) public {
        if (canBeWhitelisted(_listingHash)) {
          whitelistApplication(_listingHash);
        } else if (challengeCanBeResolved(_listingHash)) {
          resolveChallenge(_listingHash);
        } else {
          revert();
        }
    }

    // ----------------
    // TOKEN FUNCTIONS:
    // ----------------

    /**
    @dev                Called by a voter to claim their reward for each completed vote. Someone
                        must call updateStatus() before this can be called.
    @param _challengeID The PLCR pollID of the challenge a reward is being claimed for
    @param _salt        The salt of a voter's commit hash in the given poll
    */
    function claimReward(uint _challengeID, uint _salt) public {
        // Ensures the voter has not already claimed tokens and challenge results have been processed
        require(challenges[_challengeID].tokenClaims[msg.sender] == false);
        require(challenges[_challengeID].resolved == true);

        uint voterTokens = voting.getNumPassingTokens(msg.sender, _challengeID, _salt);
        uint reward = voterReward(msg.sender, _challengeID, _salt);

        // Subtracts the voter's information to preserve the participation ratios
        // of other voters compared to the remaining pool of rewards
        challenges[_challengeID].totalTokens = challenges[_challengeID].totalTokens.sub(voterTokens);
        challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);

        // Ensures a voter cannot claim tokens again
        challenges[_challengeID].tokenClaims[msg.sender] = true;

        require(token.transfer(msg.sender, reward));

        emit _RewardClaimed(_challengeID, reward, msg.sender);
    }

    // --------
    // GETTERS:
    // --------

    /**
    @dev                Calculates the provided voter's token reward for the given poll.
    @param _voter       The address of the voter whose reward balance is to be returned
    @param _challengeID The pollID of the challenge a reward balance is being queried for
    @param _salt        The salt of the voter's commit hash in the given poll
    @return             The uint indicating the voter's reward
    */
    function voterReward(address _voter, uint _challengeID, uint _salt)
    public view returns (uint) {
        uint totalTokens = challenges[_challengeID].totalTokens;
        uint rewardPool = challenges[_challengeID].rewardPool;
        uint voterTokens = voting.getNumPassingTokens(_voter, _challengeID, _salt);
        return (voterTokens * rewardPool) / totalTokens;
    }

    /**
    @dev                Determines whether the given listingHash can be whitelisted.
    @param _listingHash The listingHash whose status is to be examined
    */
    function canBeWhitelisted(bytes32 _listingHash) view public returns (bool) {
        uint challengeID = listings[_listingHash].challengeID;

        // Ensures that the application was made,
        // the application period has ended,
        // the listingHash can be whitelisted,
        // and either: the challengeID == 0, or the challenge has been resolved.
        if (
            appWasMade(_listingHash) &&
            listings[_listingHash].applicationExpiry < now &&
            !isWhitelisted(_listingHash) &&
            (challengeID == 0 || challenges[challengeID].resolved == true)
        ) {
          return true;
        }

        return false;
    }

    /**
    @dev                Returns true if the provided listingHash is whitelisted
    @param _listingHash The listingHash whose status is to be examined
    */
    function isWhitelisted(bytes32 _listingHash) view public returns (bool whitelisted) {
        return listings[_listingHash].whitelisted;
    }

    /**
    @dev                Returns true if apply was called for this listingHash
    @param _listingHash The listingHash whose status is to be examined
    */
    function appWasMade(bytes32 _listingHash) view public returns (bool exists) {
        return listings[_listingHash].applicationExpiry > 0;
    }

    /**
    @dev                Returns true if the application/listingHash has an unresolved challenge
    @param _listingHash The listingHash whose status is to be examined
    */
    function challengeExists(bytes32 _listingHash) view public returns (bool) {
        uint challengeID = listings[_listingHash].challengeID;

        return (challengeID > 0 && !challenges[challengeID].resolved);
    }

    /**
    @dev                Determines whether voting has concluded in a challenge for a given
                        listingHash. Throws if no challenge exists.
    @param _listingHash A listingHash with an unresolved challenge
    */
    function challengeCanBeResolved(bytes32 _listingHash) view public returns (bool) {
        uint challengeID = listings[_listingHash].challengeID;

        require(challengeExists(_listingHash));

        return voting.pollEnded(challengeID);
    }

    /**
    @dev                Determines the number of tokens awarded to the winning party in a challenge.
    @param _challengeID The challengeID to determine a reward for
    */
    function determineReward(uint _challengeID) public view returns (uint) {
        require(!challenges[_challengeID].resolved && voting.pollEnded(_challengeID));

        // Edge case, nobody voted, give all tokens to the challenger.
        if (voting.getTotalNumberOfTokensForWinningOption(_challengeID) == 0) {
            return challenges[_challengeID].stake.mul(2);
        }

        return (challenges[_challengeID].stake).mul(2).sub(challenges[_challengeID].rewardPool);
    }

    /**
    @dev                Getter for Challenge tokenClaims mappings
    @param _challengeID The challengeID to query
    @param _voter       The voter whose claim status to query for the provided challengeID
    */
    function tokenClaims(uint _challengeID, address _voter) public view returns (bool) {
      return challenges[_challengeID].tokenClaims[_voter];
    }

    // ----------------
    // PRIVATE FUNCTIONS:
    // ----------------

    /**
    @dev                Determines the winner in a challenge. Rewards the winner tokens and
                        either whitelists or de-whitelists the listingHash.
    @param _listingHash A listingHash with a challenge that is to be resolved
    */
    function resolveChallenge(bytes32 _listingHash) private {
        uint challengeID = listings[_listingHash].challengeID;

        // Calculates the winner's reward,
        // which is: (winner's full stake) + (dispensationPct * loser's stake)
        uint reward = determineReward(challengeID);

        // Sets flag on challenge being processed
        challenges[challengeID].resolved = true;

        // Stores the total tokens used for voting by the winning side for reward purposes
        challenges[challengeID].totalTokens =
            voting.getTotalNumberOfTokensForWinningOption(challengeID);

        // Case: challenge failed
        if (voting.isPassed(challengeID)) {
            whitelistApplication(_listingHash);
            // Unlock stake so that it can be retrieved by the applicant
            listings[_listingHash].unstakedDeposit = listings[_listingHash].unstakedDeposit.add(reward);

            totalStaked[listings[_listingHash].owner] = totalStaked[listings[_listingHash].owner].add(reward);

            emit _ChallengeFailed(_listingHash, challengeID, challenges[challengeID].rewardPool, challenges[challengeID].totalTokens);
        }
        // Case: challenge succeeded or nobody voted
        else {
            resetListing(_listingHash);
            // Transfer the reward to the challenger
            require(token.transfer(challenges[challengeID].challenger, reward));

            emit _ChallengeSucceeded(_listingHash, challengeID, challenges[challengeID].rewardPool, challenges[challengeID].totalTokens);
        }
    }

    /**
    @dev                Called by updateStatus() if the applicationExpiry date passed without a
                        challenge being made. Called by resolveChallenge() if an
                        application/listing beat a challenge.
    @param _listingHash The listingHash of an application/listingHash to be whitelisted
    */
    function whitelistApplication(bytes32 _listingHash) private {
        if (!listings[_listingHash].whitelisted) {
          emit _ApplicationWhitelisted(_listingHash);
        }
        listings[_listingHash].whitelisted = true;
    }

    /**
    @dev                Deletes a listingHash from the whitelist and transfers tokens back to owner
    @param _listingHash The listing hash to delete
    */
    function resetListing(bytes32 _listingHash) private {
        Listing storage listing = listings[_listingHash];

        // Emit events before deleting listing to check whether is whitelisted
        if (listing.whitelisted) {
            emit _ListingRemoved(_listingHash);
        } else {
            emit _ApplicationRemoved(_listingHash);
        }

        // Deleting listing to prevent reentry
        address owner = listing.owner;
        uint unstakedDeposit = listing.unstakedDeposit;
        delete listings[_listingHash];

        // Transfers any remaining balance back to the owner
        if (unstakedDeposit > 0){
            require(token.transfer(owner, unstakedDeposit));
        }
    }

    /**
    @dev Modifier to specify that a function can only be called if this is the current registry.
    */
    modifier onlyIfCurrentRegistry() {
      require(parameterizer.getNewRegistry() == address(0));
      _;
    }

    /**
    @dev Modifier to specify that a function cannot be called if this is the current registry.
    */
    modifier onlyIfOutdatedRegistry() {
      require(parameterizer.getNewRegistry() != address(0));
      _;
    }

    /**
     @dev Check if a listing exists in the registry by checking that its owner is not zero
          Since all solidity mappings have every key set to zero, we check that the address of the creator isn't zero.
    */
    function listingExists(bytes32 listingHash) public view returns (bool) {
      return listings[listingHash].owner != address(0);
    }

    /**
    @dev migrates a listing
    */
    function migrateListing(bytes32 listingHash) onlyIfOutdatedRegistry public {
      require(listingExists(listingHash)); // duh
      require(!challengeExists(listingHash)); // can't migrate a listing that's challenged

      address newRegistryAddress = parameterizer.getNewRegistry();
      SupercedesRegistry newRegistry = SupercedesRegistry(newRegistryAddress);
      Listing storage listing = listings[listingHash];

      require(newRegistry.canReceiveListing(
        listingHash, listing.applicationExpiry,
        listing.whitelisted, listing.owner,
        listing.unstakedDeposit, listing.challengeID
      ));

      token.approve(newRegistry, listing.unstakedDeposit);
      newRegistry.receiveListing(
        listingHash, listing.applicationExpiry,
        listing.whitelisted, listing.owner,
        listing.unstakedDeposit, listing.challengeID
      );
      delete listings[listingHash];
      emit _ListingMigrated(listingHash, newRegistryAddress);
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"isWhitelisted","outputs":[{"name":"whitelisted","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"},{"name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"challengeExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"},{"name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"numApplications","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"canBeWhitelisted","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"listingHash","type":"bytes32"}],"name":"listingExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"challengeCanBeResolved","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_challengeID","type":"uint256"},{"name":"_salt","type":"uint256"}],"name":"claimReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"string"}],"name":"apply","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"updateStatus","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_listingHash","type":"bytes32"}],"name":"appWasMade","outputs":[{"name":"exists","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"listingHash","type":"bytes32"}],"name":"migrateListing","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"challenges","outputs":[{"name":"rewardPool","type":"uint256"},{"name":"challenger","type":"address"},{"name":"resolved","type":"bool"},{"name":"stake","type":"uint256"},{"name":"totalTokens","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"totalStaked","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_challengeID","type":"uint256"},{"name":"_voter","type":"address"}],"name":"tokenClaims","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_voter","type":"address"},{"name":"_challengeID","type":"uint256"},{"name":"_salt","type":"uint256"}],"name":"voterReward","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"listings","outputs":[{"name":"applicationExpiry","type":"uint256"},{"name":"whitelisted","type":"bool"},{"name":"owner","type":"address"},{"name":"unstakedDeposit","type":"uint256"},{"name":"challengeID","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_challengeID","type":"uint256"}],"name":"determineReward","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parameterizer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"voting","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_listingHash","type":"bytes32"},{"name":"_deposit","type":"uint256"},{"name":"_data","type":"string"}],"name":"challenge","outputs":[{"name":"challengeID","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_tokenAddr","type":"address"},{"name":"_plcrAddr","type":"address"},{"name":"_paramsAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":false,"name":"deposit","type":"uint256"},{"indexed":false,"name":"appEndDate","type":"uint256"},{"indexed":false,"name":"data","type":"string"}],"name":"_Application","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":false,"name":"challengeID","type":"uint256"},{"indexed":false,"name":"deposit","type":"uint256"},{"indexed":false,"name":"data","type":"string"}],"name":"_Challenge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":false,"name":"added","type":"uint256"},{"indexed":false,"name":"newTotal","type":"uint256"}],"name":"_Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":false,"name":"withdrew","type":"uint256"},{"indexed":false,"name":"newTotal","type":"uint256"}],"name":"_Withdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"}],"name":"_ApplicationWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"}],"name":"_ApplicationRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"}],"name":"_ListingRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"}],"name":"_ListingWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"}],"name":"_TouchAndRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":true,"name":"challengeID","type":"uint256"},{"indexed":false,"name":"rewardPool","type":"uint256"},{"indexed":false,"name":"totalTokens","type":"uint256"}],"name":"_ChallengeFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":true,"name":"challengeID","type":"uint256"},{"indexed":false,"name":"rewardPool","type":"uint256"},{"indexed":false,"name":"totalTokens","type":"uint256"}],"name":"_ChallengeSucceeded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"challengeID","type":"uint256"},{"indexed":false,"name":"reward","type":"uint256"},{"indexed":false,"name":"voter","type":"address"}],"name":"_RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"listingHash","type":"bytes32"},{"indexed":false,"name":"newRegistry","type":"address"}],"name":"_ListingMigrated","type":"event"}]

608060405234801561001057600080fd5b5060405160608061279c83398101604090815281516020830151919092015160048054600160a060020a0319908116600160a060020a0395861617909155600580548216938516939093179092556006805490921692169190911790556127208061007c6000396000f30060806040526004361061012f5763ffffffff60e060020a60003504166301a5e3fe8114610134578063040cf020146101605780630ca362631461017d5780631b7bbecb146101955780631de26e16146101ad57806354fd4d50146101c8578063683e52c514610252578063691a38ab1461028557806375bd32371461029d57806377609a41146102b557806386bb8f37146102cd57806389bb55c7146102e85780638a59eb56146103105780638cf8151f146103285780638e298549146103405780638f1d3776146103585780639bfd8d61146103a3578063a5ba3b1e146103c4578063a7aad3db146103e8578063c18b8db41461040f578063c8187cf11461045a578063e1e3f91514610472578063fc0c546a146104a3578063fce1ccca146104b8578063fd48cc45146104cd575b600080fd5b34801561014057600080fd5b5061014c6004356104f5565b604080519115158252519081900360200190f35b34801561016c57600080fd5b5061017b600435602435610511565b005b34801561018957600080fd5b5061017b600435610722565b3480156101a157600080fd5b5061014c6004356107d5565b3480156101b957600080fd5b5061017b600435602435610818565b3480156101d457600080fd5b506101dd61099b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102175781810151838201526020016101ff565b50505050905090810190601f1680156102445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025e57600080fd5b50610273600160a060020a03600435166109d2565b60408051918252519081900360200190f35b34801561029157600080fd5b5061014c6004356109e4565b3480156102a957600080fd5b5061014c600435610a72565b3480156102c157600080fd5b5061014c600435610a98565b3480156102d957600080fd5b5061017b600435602435610b58565b3480156102f457600080fd5b5061017b60048035906024803591604435918201910135610dae565b34801561031c57600080fd5b5061017b6004356111e3565b34801561033457600080fd5b5061014c600435611219565b34801561034c57600080fd5b5061017b60043561122c565b34801561036457600080fd5b50610370600435611640565b60408051958652600160a060020a0390941660208601529115158484015260608401526080830152519081900360a00190f35b3480156103af57600080fd5b50610273600160a060020a036004351661167c565b3480156103d057600080fd5b5061014c600435600160a060020a036024351661168e565b3480156103f457600080fd5b50610273600160a060020a03600435166024356044356116bc565b34801561041b57600080fd5b5061042760043561178b565b604080519586529315156020860152600160a060020a039092168484015260608401526080830152519081900360a00190f35b34801561046657600080fd5b506102736004356117c6565b34801561047e57600080fd5b50610487611982565b60408051600160a060020a039092168252519081900360200190f35b3480156104af57600080fd5b50610487611991565b3480156104c457600080fd5b506104876119a0565b3480156104d957600080fd5b50610273600480359060248035916044359182019101356119af565b6000818152600160208190526040909120015460ff165b919050565b6000828152600160208190526040909120908101546101009004600160a060020a0316331461053f57600080fd5b600281015482111561055057600080fd5b600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f6d696e4465706f7369740000000000000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b1580156105d157600080fd5b505af11580156105e5573d6000803e3d6000fd5b505050506040513d60208110156105fb57600080fd5b50516002820154610612908463ffffffff61210c16565b101561061d57600080fd5b6002810154610632908363ffffffff61210c16565b600282015560048054604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233938101939093526024830185905251600160a060020a039091169163a9059cbb9160448083019260209291908290030181600087803b1580156106a557600080fd5b505af11580156106b9573d6000803e3d6000fd5b505050506040513d60208110156106cf57600080fd5b505115156106dc57600080fd5b6002810154604080518481526020810192909252805185927febf81d30de8bdb30e2a07a5e34bd7c1b843c5b9674b224113cc6cee0d8571c9292908290030190a2505050565b6000818152600160208190526040909120908101546101009004600160a060020a0316331461075057600080fd5b610759826104f5565b151561076457600080fd5b600381015415806107925750600381015460009081526020819052604090206001015460a060020a900460ff165b151561079d57600080fd5b6107a68261211e565b60405182907f8a51904a50ce4451be09dc08242bd2d5565b05cf0f4f5aa88c77f96fdf538b4290600090a25050565b600081815260016020526040812060030154818111801561080f575060008181526020819052604090206001015460a060020a900460ff16155b91505b50919050565b6000828152600160208190526040909120908101546101009004600160a060020a0316331461084657600080fd5b600281015461085b908363ffffffff6122af16565b600282015560018101546101009004600160a060020a031660009081526003602052604090205461088c90836122af565b6001820154600160a060020a0361010090910481166000908152600360209081526040808320949094556004805485517f23b872dd000000000000000000000000000000000000000000000000000000008152339281019290925230602483015260448201889052945194909316936323b872dd93606480820194918390030190829087803b15801561091e57600080fd5b505af1158015610932573d6000803e3d6000fd5b505050506040513d602081101561094857600080fd5b5051151561095557600080fd5b6002810154604080518481526020810192909252805185927f77e303d2327bb214eb0f6441b799c7b1de3cea010185c2a27a60cbd774e590c292908290030190a2505050565b60408051808201909152600181527f3100000000000000000000000000000000000000000000000000000000000000602082015281565b60026020526000908152604090205481565b6000818152600160205260408120600301546109ff83611219565b8015610a18575060008381526001602052604090205442115b8015610a2a5750610a28836104f5565b155b8015610a5b5750801580610a5b5750600081815260208190526040902060019081015460a060020a900460ff161515145b15610a695760019150610812565b50600092915050565b600090815260016020819052604090912001546101009004600160a060020a0316151590565b600081815260016020526040812060030154610ab3836107d5565b1515610abe57600080fd5b600554604080517fee684830000000000000000000000000000000000000000000000000000000008152600481018490529051600160a060020a039092169163ee684830916024808201926020929091908290030181600087803b158015610b2557600080fd5b505af1158015610b39573d6000803e3d6000fd5b505050506040513d6020811015610b4f57600080fd5b50519392505050565b600082815260208181526040808320338452600401909152812054819060ff1615610b8257600080fd5b600084815260208190526040902060019081015460a060020a900460ff16151514610bac57600080fd5b600554604080517fb43bd06900000000000000000000000000000000000000000000000000000000815233600482015260248101879052604481018690529051600160a060020a039092169163b43bd069916064808201926020929091908290030181600087803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b505050506040513d6020811015610c4a57600080fd5b50519150610c593385856116bc565b600085815260208190526040902060030154909150610c7e908363ffffffff61210c16565b6000858152602081905260409020600381019190915554610ca5908263ffffffff61210c16565b6000858152602081815260408083209384553380845260049485018352818420805460ff19166001179055845482517fa9059cbb00000000000000000000000000000000000000000000000000000000815295860191909152602485018690529051600160a060020a03919091169363a9059cbb9360448083019493928390030190829087803b158015610d3857600080fd5b505af1158015610d4c573d6000803e3d6000fd5b505050506040513d6020811015610d6257600080fd5b50511515610d6f57600080fd5b60408051828152336020820152815186927f6f4c982acc31b0af2cf1dc1556f21c0325d893782d65e83c68a5534a33f59957928290030190a250505050565b600080600160a060020a0316600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610e0d57600080fd5b505af1158015610e21573d6000803e3d6000fd5b505050506040513d6020811015610e3757600080fd5b5051600160a060020a031614610e4c57600080fd5b610e55856104f5565b15610e5f57600080fd5b610e6885611219565b15610e7257600080fd5b600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f6d696e4465706f7369740000000000000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015610ef357600080fd5b505af1158015610f07573d6000803e3d6000fd5b505050506040513d6020811015610f1d57600080fd5b5051841015610f2b57600080fd5b506000848152600160208181526040808420928301805474ffffffffffffffffffffffffffffffffffffffff001916336101000217905560065481516000805160206126d5833981519152815260048101849052600d60248201527f6170706c7953746167654c656e0000000000000000000000000000000000000060448201529151939461101e94600160a060020a039092169363693ec85e936064808201949293918390030190829087803b158015610fe557600080fd5b505af1158015610ff9573d6000803e3d6000fd5b505050506040513d602081101561100f57600080fd5b5051429063ffffffff6122af16565b815560028082018590556001808301546101009004600160a060020a03166000908152602092909252604090912054611056916122af565b600182018054600160a060020a03610100918290048116600090815260026020908152604080832096909655935492909204168152600390915220546110a2908563ffffffff6122af16565b600182018054600160a060020a0361010091829004811660009081526003602090815260408083209690965560048054955487517f23b872dd000000000000000000000000000000000000000000000000000000008152959004841690850152306024850152604484018a9052945193909116936323b872dd93606480850194929391928390030190829087803b15801561113c57600080fd5b505af1158015611150573d6000803e3d6000fd5b505050506040513d602081101561116657600080fd5b5051151561117357600080fd5b84600019167feeb12328919531145f8e8dce4e50e39dba9eaa8a7051cea29fcf9afc17d75e21858360000154868660405180858152602001848152602001806020018281038252848482818152602001925080828437604051920182900397509095505050505050a25050505050565b6111ec816109e4565b156111ff576111fa816122bc565b611216565b61120881610a98565b1561012f576111fa81612324565b50565b6000908152600160205260408120541190565b600654604080517f70c8658a0000000000000000000000000000000000000000000000000000000081529051600092839283928392600160a060020a0316916370c8658a91600480830192602092919082900301818787803b15801561129157600080fd5b505af11580156112a5573d6000803e3d6000fd5b505050506040513d60208110156112bb57600080fd5b5051600160a060020a031614156112d157600080fd5b6112da84610a72565b15156112e557600080fd5b6112ee846107d5565b156112f857600080fd5b600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561134b57600080fd5b505af115801561135f573d6000803e3d6000fd5b505050506040513d602081101561137557600080fd5b505160008581526001602081815260408084208054938101546002820154600383015484517f63921a74000000000000000000000000000000000000000000000000000000008152600481018e9052602481019790975260ff831615156044880152600160a060020a0361010090930483166064880152608487019190915260a4860152915195985088975095508616936363921a749360c4808501948390030190829087803b15801561142857600080fd5b505af115801561143c573d6000803e3d6000fd5b505050506040513d602081101561145257600080fd5b5051151561145f57600080fd5b600480546002830154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a0387811695820195909552602481019290925251929091169163095ea7b3916044808201926020929091908290030181600087803b1580156114d757600080fd5b505af11580156114eb573d6000803e3d6000fd5b505050506040513d602081101561150157600080fd5b50508054600182015460028301546003840154604080517fadda1d4d000000000000000000000000000000000000000000000000000000008152600481018a9052602481019590955260ff841615156044860152600160a060020a0361010090940484166064860152608485019290925260a4840152519084169163adda1d4d9160c480830192600092919082900301818387803b1580156115a257600080fd5b505af11580156115b6573d6000803e3d6000fd5b5050506000858152600160208181526040808420848155928301805474ffffffffffffffffffffffffffffffffffffffffff19169055600283018490556003909201929092558051600160a060020a038716815290518793507ffdc1934e2a8f30c0b71ea95edbc0f51db4f3caa842a33aeb3be0ab85177cb6e2929181900390910190a250505050565b60006020819052908152604090208054600182015460028301546003909301549192600160a060020a0382169260a060020a90920460ff169185565b60036020526000908152604090205481565b600082815260208181526040808320600160a060020a038516845260040190915290205460ff165b92915050565b6000828152602081815260408083206003810154905460055483517fb43bd069000000000000000000000000000000000000000000000000000000008152600160a060020a038a81166004830152602482018a905260448201899052945193959294879492169263b43bd0699260648084019382900301818787803b15801561174457600080fd5b505af1158015611758573d6000803e3d6000fd5b505050506040513d602081101561176e57600080fd5b505190508282820281151561177f57fe5b04979650505050505050565b6001602081905260009182526040909120805491810154600282015460039092015460ff821692610100909204600160a060020a0316919085565b60008181526020819052604081206001015460a060020a900460ff1615801561187e5750600554604080517fee684830000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163ee684830916024808201926020929091908290030181600087803b15801561185157600080fd5b505af1158015611865573d6000803e3d6000fd5b505050506040513d602081101561187b57600080fd5b50515b151561188957600080fd5b600554604080517f053e71a6000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163053e71a6916024808201926020929091908290030181600087803b1580156118f057600080fd5b505af1158015611904573d6000803e3d6000fd5b505050506040513d602081101561191a57600080fd5b5051151561194c5760008281526020819052604090206002908101546119459163ffffffff6126ab16565b905061050c565b600082815260208190526040902080546002918201546116b692611976919063ffffffff6126ab16565b9063ffffffff61210c16565b600654600160a060020a031681565b600454600160a060020a031681565b600554600160a060020a031681565b6000806000806000600160a060020a0316600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015611a1357600080fd5b505af1158015611a27573d6000803e3d6000fd5b505050506040513d6020811015611a3d57600080fd5b5051600160a060020a031614611a5257600080fd5b600088815260016020908152604080832060065482516000805160206126d5833981519152815260048101859052600a60248201527f6d696e4465706f7369740000000000000000000000000000000000000000000060448201529251919750600160a060020a03169363693ec85e93606480850194919392918390030190829087803b158015611ae257600080fd5b505af1158015611af6573d6000803e3d6000fd5b505050506040513d6020811015611b0c57600080fd5b50519150611b1988611219565b80611b285750600183015460ff165b1515611b3357600080fd5b60038301541580611b615750600383015460009081526020819052604090206001015460a060020a900460ff165b1515611b6c57600080fd5b8183600201541015611bb557611b818861211e565b60405188907f4a9ee335af9e32f32f2229943dc7a0d3b5adf7e4c5c4062b372eae8c476d928690600090a260009350612101565b600554600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f766f746551756f72756d0000000000000000000000000000000000000000000060448301529151600160a060020a03948516946332ed3d6094169263693ec85e92606480820193918290030181600087803b158015611c3f57600080fd5b505af1158015611c53573d6000803e3d6000fd5b505050506040513d6020811015611c6957600080fd5b5051600654604080516000805160206126d58339815191528152602060048201819052600e60248301527f636f6d6d697453746167654c656e00000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b505050506040513d6020811015611d1657600080fd5b5051600654604080516000805160206126d58339815191528152602060048201819052600e60248301527f72657665616c53746167654c656e00000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015611d9957600080fd5b505af1158015611dad573d6000803e3d6000fd5b505050506040513d6020811015611dc357600080fd5b50516040805160e060020a63ffffffff87160281526004810194909452602484019290925260448301525160648083019260209291908290030181600087803b158015611e0f57600080fd5b505af1158015611e23573d6000803e3d6000fd5b505050506040513d6020811015611e3957600080fd5b50516040805160a081018083526006546000805160206126d5833981519152909152602060a48301819052600f60c48401527f64697370656e736174696f6e506374000000000000000000000000000000000060e48401529251939450909283926064928c92600160a060020a039091169163693ec85e916101048088019291908189030181600087803b158015611ed057600080fd5b505af1158015611ee4573d6000803e3d6000fd5b505050506040513d6020811015611efa57600080fd5b505160640302811515611f0957fe5b048152336020808301919091526000604080840182905260608085018d9052608094850183905286835282845291819020855181559285015160018401805492870151151560a060020a0274ff000000000000000000000000000000000000000019600160a060020a039390931673ffffffffffffffffffffffffffffffffffffffff19909416939093179190911691909117905583015160028201559101516003918201558301819055818710801590611fc8575082600201548711155b1515611fd357600080fd5b6002830154611fe8908863ffffffff61210c16565b600284015560048054604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523393810193909352306024840152604483018a905251600160a060020a03909116916323b872dd9160648083019260209291908290030181600087803b15801561206157600080fd5b505af1158015612075573d6000803e3d6000fd5b505050506040513d602081101561208b57600080fd5b5051151561209857600080fd5b87600019167f9a114fb0a925e49fdd5328ae588bc890c8e0d6bcd0fe0813b12aa8cb1b3ba85d8289898960405180858152602001848152602001806020018281038252848482818152602001925080828437604051920182900397509095505050505050a28093505b505050949350505050565b60008282111561211857fe5b50900390565b6000818152600160208190526040822090810154909190819060ff161561216f5760405184907fd1ffb796b7108387b2f02adf47b4b81a1690cf2a190422c87a4f670780103e6390600090a261219b565b60405184907f2e5ec035f6eac8ff1cf7cdf36cfeca7c85413f9f67652dc2c13d20f337204a2690600090a25b50506001818101546002808401546000868152602085905260408120818155948501805474ffffffffffffffffffffffffffffffffffffffffff191690559184018290556003909301819055610100909104600160a060020a031691908111156122a95760048054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0386811694820194909452602481018590529051929091169163a9059cbb916044808201926020929091908290030181600087803b15801561227257600080fd5b505af1158015612286573d6000803e3d6000fd5b505050506040513d602081101561229c57600080fd5b505115156122a957600080fd5b50505050565b818101828110156116b657fe5b6000818152600160208190526040909120015460ff1615156123045760405181907fa7bc1d57d9006d9d248707c7b6828c1bab8c51719cc06d78c82a3ee891ef967c90600090a25b60009081526001602081905260409091208101805460ff19169091179055565b60008181526001602052604081206003015490612340826117c6565b600083815260208181526040808320600101805474ff0000000000000000000000000000000000000000191660a060020a17905560055481517f053e71a6000000000000000000000000000000000000000000000000000000008152600481018890529151949550600160a060020a03169363053e71a693602480840194938390030190829087803b1580156123d557600080fd5b505af11580156123e9573d6000803e3d6000fd5b505050506040513d60208110156123ff57600080fd5b50516000838152602081815260408083206003019390935560055483517f49403183000000000000000000000000000000000000000000000000000000008152600481018790529351600160a060020a039091169363494031839360248083019493928390030190829087803b15801561247857600080fd5b505af115801561248c573d6000803e3d6000fd5b505050506040513d60208110156124a257600080fd5b505115612592576124b2836122bc565b6000838152600160205260409020600201546124d4908263ffffffff6122af16565b6000848152600160208181526040808420600281019590955593909101546101009004600160a060020a0316825260039052205461251290826122af565b6000848152600160208181526040808420909201546101009004600160a060020a031683526003808252828420949094558583528281529181902080549301548151938452918301919091528051849286927fc4497224aa78dd50c9b3e344aab02596201ca1e6dca4057a91a6c02f83f4f6c192918290030190a36126a6565b61259b8361211e565b600480546000848152602081815260408083206001015481517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a039182169681019690965260248601879052905193169363a9059cbb9360448083019491928390030190829087803b15801561261957600080fd5b505af115801561262d573d6000803e3d6000fd5b505050506040513d602081101561264357600080fd5b5051151561265057600080fd5b6000828152602081815260409182902080546003909101548351918252918101919091528151849286927f362a12431f779a2baff4f77f75ba7960ae993a5c41b425df11f7fd0af2b9cbe6929081900390910190a35b505050565b60008215156126bc575060006116b6565b508181028183828115156126cc57fe5b04146116b657fe00693ec85e00000000000000000000000000000000000000000000000000000000a165627a7a723058202d74b3583a6722432dcf5fada9c10d296b471602ac6323b207fabb0bb4d9150300290000000000000000000000004946fcea7c692606e8908002e55a582af44ac12100000000000000000000000066f27365d66c0e8ad4ef87db8cb4af63ce874b7b000000000000000000000000baba8fbe1169fba058ca253236522a0d1f1737e9

Deployed Bytecode

0x60806040526004361061012f5763ffffffff60e060020a60003504166301a5e3fe8114610134578063040cf020146101605780630ca362631461017d5780631b7bbecb146101955780631de26e16146101ad57806354fd4d50146101c8578063683e52c514610252578063691a38ab1461028557806375bd32371461029d57806377609a41146102b557806386bb8f37146102cd57806389bb55c7146102e85780638a59eb56146103105780638cf8151f146103285780638e298549146103405780638f1d3776146103585780639bfd8d61146103a3578063a5ba3b1e146103c4578063a7aad3db146103e8578063c18b8db41461040f578063c8187cf11461045a578063e1e3f91514610472578063fc0c546a146104a3578063fce1ccca146104b8578063fd48cc45146104cd575b600080fd5b34801561014057600080fd5b5061014c6004356104f5565b604080519115158252519081900360200190f35b34801561016c57600080fd5b5061017b600435602435610511565b005b34801561018957600080fd5b5061017b600435610722565b3480156101a157600080fd5b5061014c6004356107d5565b3480156101b957600080fd5b5061017b600435602435610818565b3480156101d457600080fd5b506101dd61099b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102175781810151838201526020016101ff565b50505050905090810190601f1680156102445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025e57600080fd5b50610273600160a060020a03600435166109d2565b60408051918252519081900360200190f35b34801561029157600080fd5b5061014c6004356109e4565b3480156102a957600080fd5b5061014c600435610a72565b3480156102c157600080fd5b5061014c600435610a98565b3480156102d957600080fd5b5061017b600435602435610b58565b3480156102f457600080fd5b5061017b60048035906024803591604435918201910135610dae565b34801561031c57600080fd5b5061017b6004356111e3565b34801561033457600080fd5b5061014c600435611219565b34801561034c57600080fd5b5061017b60043561122c565b34801561036457600080fd5b50610370600435611640565b60408051958652600160a060020a0390941660208601529115158484015260608401526080830152519081900360a00190f35b3480156103af57600080fd5b50610273600160a060020a036004351661167c565b3480156103d057600080fd5b5061014c600435600160a060020a036024351661168e565b3480156103f457600080fd5b50610273600160a060020a03600435166024356044356116bc565b34801561041b57600080fd5b5061042760043561178b565b604080519586529315156020860152600160a060020a039092168484015260608401526080830152519081900360a00190f35b34801561046657600080fd5b506102736004356117c6565b34801561047e57600080fd5b50610487611982565b60408051600160a060020a039092168252519081900360200190f35b3480156104af57600080fd5b50610487611991565b3480156104c457600080fd5b506104876119a0565b3480156104d957600080fd5b50610273600480359060248035916044359182019101356119af565b6000818152600160208190526040909120015460ff165b919050565b6000828152600160208190526040909120908101546101009004600160a060020a0316331461053f57600080fd5b600281015482111561055057600080fd5b600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f6d696e4465706f7369740000000000000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b1580156105d157600080fd5b505af11580156105e5573d6000803e3d6000fd5b505050506040513d60208110156105fb57600080fd5b50516002820154610612908463ffffffff61210c16565b101561061d57600080fd5b6002810154610632908363ffffffff61210c16565b600282015560048054604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233938101939093526024830185905251600160a060020a039091169163a9059cbb9160448083019260209291908290030181600087803b1580156106a557600080fd5b505af11580156106b9573d6000803e3d6000fd5b505050506040513d60208110156106cf57600080fd5b505115156106dc57600080fd5b6002810154604080518481526020810192909252805185927febf81d30de8bdb30e2a07a5e34bd7c1b843c5b9674b224113cc6cee0d8571c9292908290030190a2505050565b6000818152600160208190526040909120908101546101009004600160a060020a0316331461075057600080fd5b610759826104f5565b151561076457600080fd5b600381015415806107925750600381015460009081526020819052604090206001015460a060020a900460ff165b151561079d57600080fd5b6107a68261211e565b60405182907f8a51904a50ce4451be09dc08242bd2d5565b05cf0f4f5aa88c77f96fdf538b4290600090a25050565b600081815260016020526040812060030154818111801561080f575060008181526020819052604090206001015460a060020a900460ff16155b91505b50919050565b6000828152600160208190526040909120908101546101009004600160a060020a0316331461084657600080fd5b600281015461085b908363ffffffff6122af16565b600282015560018101546101009004600160a060020a031660009081526003602052604090205461088c90836122af565b6001820154600160a060020a0361010090910481166000908152600360209081526040808320949094556004805485517f23b872dd000000000000000000000000000000000000000000000000000000008152339281019290925230602483015260448201889052945194909316936323b872dd93606480820194918390030190829087803b15801561091e57600080fd5b505af1158015610932573d6000803e3d6000fd5b505050506040513d602081101561094857600080fd5b5051151561095557600080fd5b6002810154604080518481526020810192909252805185927f77e303d2327bb214eb0f6441b799c7b1de3cea010185c2a27a60cbd774e590c292908290030190a2505050565b60408051808201909152600181527f3100000000000000000000000000000000000000000000000000000000000000602082015281565b60026020526000908152604090205481565b6000818152600160205260408120600301546109ff83611219565b8015610a18575060008381526001602052604090205442115b8015610a2a5750610a28836104f5565b155b8015610a5b5750801580610a5b5750600081815260208190526040902060019081015460a060020a900460ff161515145b15610a695760019150610812565b50600092915050565b600090815260016020819052604090912001546101009004600160a060020a0316151590565b600081815260016020526040812060030154610ab3836107d5565b1515610abe57600080fd5b600554604080517fee684830000000000000000000000000000000000000000000000000000000008152600481018490529051600160a060020a039092169163ee684830916024808201926020929091908290030181600087803b158015610b2557600080fd5b505af1158015610b39573d6000803e3d6000fd5b505050506040513d6020811015610b4f57600080fd5b50519392505050565b600082815260208181526040808320338452600401909152812054819060ff1615610b8257600080fd5b600084815260208190526040902060019081015460a060020a900460ff16151514610bac57600080fd5b600554604080517fb43bd06900000000000000000000000000000000000000000000000000000000815233600482015260248101879052604481018690529051600160a060020a039092169163b43bd069916064808201926020929091908290030181600087803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b505050506040513d6020811015610c4a57600080fd5b50519150610c593385856116bc565b600085815260208190526040902060030154909150610c7e908363ffffffff61210c16565b6000858152602081905260409020600381019190915554610ca5908263ffffffff61210c16565b6000858152602081815260408083209384553380845260049485018352818420805460ff19166001179055845482517fa9059cbb00000000000000000000000000000000000000000000000000000000815295860191909152602485018690529051600160a060020a03919091169363a9059cbb9360448083019493928390030190829087803b158015610d3857600080fd5b505af1158015610d4c573d6000803e3d6000fd5b505050506040513d6020811015610d6257600080fd5b50511515610d6f57600080fd5b60408051828152336020820152815186927f6f4c982acc31b0af2cf1dc1556f21c0325d893782d65e83c68a5534a33f59957928290030190a250505050565b600080600160a060020a0316600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610e0d57600080fd5b505af1158015610e21573d6000803e3d6000fd5b505050506040513d6020811015610e3757600080fd5b5051600160a060020a031614610e4c57600080fd5b610e55856104f5565b15610e5f57600080fd5b610e6885611219565b15610e7257600080fd5b600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f6d696e4465706f7369740000000000000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015610ef357600080fd5b505af1158015610f07573d6000803e3d6000fd5b505050506040513d6020811015610f1d57600080fd5b5051841015610f2b57600080fd5b506000848152600160208181526040808420928301805474ffffffffffffffffffffffffffffffffffffffff001916336101000217905560065481516000805160206126d5833981519152815260048101849052600d60248201527f6170706c7953746167654c656e0000000000000000000000000000000000000060448201529151939461101e94600160a060020a039092169363693ec85e936064808201949293918390030190829087803b158015610fe557600080fd5b505af1158015610ff9573d6000803e3d6000fd5b505050506040513d602081101561100f57600080fd5b5051429063ffffffff6122af16565b815560028082018590556001808301546101009004600160a060020a03166000908152602092909252604090912054611056916122af565b600182018054600160a060020a03610100918290048116600090815260026020908152604080832096909655935492909204168152600390915220546110a2908563ffffffff6122af16565b600182018054600160a060020a0361010091829004811660009081526003602090815260408083209690965560048054955487517f23b872dd000000000000000000000000000000000000000000000000000000008152959004841690850152306024850152604484018a9052945193909116936323b872dd93606480850194929391928390030190829087803b15801561113c57600080fd5b505af1158015611150573d6000803e3d6000fd5b505050506040513d602081101561116657600080fd5b5051151561117357600080fd5b84600019167feeb12328919531145f8e8dce4e50e39dba9eaa8a7051cea29fcf9afc17d75e21858360000154868660405180858152602001848152602001806020018281038252848482818152602001925080828437604051920182900397509095505050505050a25050505050565b6111ec816109e4565b156111ff576111fa816122bc565b611216565b61120881610a98565b1561012f576111fa81612324565b50565b6000908152600160205260408120541190565b600654604080517f70c8658a0000000000000000000000000000000000000000000000000000000081529051600092839283928392600160a060020a0316916370c8658a91600480830192602092919082900301818787803b15801561129157600080fd5b505af11580156112a5573d6000803e3d6000fd5b505050506040513d60208110156112bb57600080fd5b5051600160a060020a031614156112d157600080fd5b6112da84610a72565b15156112e557600080fd5b6112ee846107d5565b156112f857600080fd5b600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561134b57600080fd5b505af115801561135f573d6000803e3d6000fd5b505050506040513d602081101561137557600080fd5b505160008581526001602081815260408084208054938101546002820154600383015484517f63921a74000000000000000000000000000000000000000000000000000000008152600481018e9052602481019790975260ff831615156044880152600160a060020a0361010090930483166064880152608487019190915260a4860152915195985088975095508616936363921a749360c4808501948390030190829087803b15801561142857600080fd5b505af115801561143c573d6000803e3d6000fd5b505050506040513d602081101561145257600080fd5b5051151561145f57600080fd5b600480546002830154604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a0387811695820195909552602481019290925251929091169163095ea7b3916044808201926020929091908290030181600087803b1580156114d757600080fd5b505af11580156114eb573d6000803e3d6000fd5b505050506040513d602081101561150157600080fd5b50508054600182015460028301546003840154604080517fadda1d4d000000000000000000000000000000000000000000000000000000008152600481018a9052602481019590955260ff841615156044860152600160a060020a0361010090940484166064860152608485019290925260a4840152519084169163adda1d4d9160c480830192600092919082900301818387803b1580156115a257600080fd5b505af11580156115b6573d6000803e3d6000fd5b5050506000858152600160208181526040808420848155928301805474ffffffffffffffffffffffffffffffffffffffffff19169055600283018490556003909201929092558051600160a060020a038716815290518793507ffdc1934e2a8f30c0b71ea95edbc0f51db4f3caa842a33aeb3be0ab85177cb6e2929181900390910190a250505050565b60006020819052908152604090208054600182015460028301546003909301549192600160a060020a0382169260a060020a90920460ff169185565b60036020526000908152604090205481565b600082815260208181526040808320600160a060020a038516845260040190915290205460ff165b92915050565b6000828152602081815260408083206003810154905460055483517fb43bd069000000000000000000000000000000000000000000000000000000008152600160a060020a038a81166004830152602482018a905260448201899052945193959294879492169263b43bd0699260648084019382900301818787803b15801561174457600080fd5b505af1158015611758573d6000803e3d6000fd5b505050506040513d602081101561176e57600080fd5b505190508282820281151561177f57fe5b04979650505050505050565b6001602081905260009182526040909120805491810154600282015460039092015460ff821692610100909204600160a060020a0316919085565b60008181526020819052604081206001015460a060020a900460ff1615801561187e5750600554604080517fee684830000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163ee684830916024808201926020929091908290030181600087803b15801561185157600080fd5b505af1158015611865573d6000803e3d6000fd5b505050506040513d602081101561187b57600080fd5b50515b151561188957600080fd5b600554604080517f053e71a6000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163053e71a6916024808201926020929091908290030181600087803b1580156118f057600080fd5b505af1158015611904573d6000803e3d6000fd5b505050506040513d602081101561191a57600080fd5b5051151561194c5760008281526020819052604090206002908101546119459163ffffffff6126ab16565b905061050c565b600082815260208190526040902080546002918201546116b692611976919063ffffffff6126ab16565b9063ffffffff61210c16565b600654600160a060020a031681565b600454600160a060020a031681565b600554600160a060020a031681565b6000806000806000600160a060020a0316600660009054906101000a9004600160a060020a0316600160a060020a03166370c8658a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015611a1357600080fd5b505af1158015611a27573d6000803e3d6000fd5b505050506040513d6020811015611a3d57600080fd5b5051600160a060020a031614611a5257600080fd5b600088815260016020908152604080832060065482516000805160206126d5833981519152815260048101859052600a60248201527f6d696e4465706f7369740000000000000000000000000000000000000000000060448201529251919750600160a060020a03169363693ec85e93606480850194919392918390030190829087803b158015611ae257600080fd5b505af1158015611af6573d6000803e3d6000fd5b505050506040513d6020811015611b0c57600080fd5b50519150611b1988611219565b80611b285750600183015460ff165b1515611b3357600080fd5b60038301541580611b615750600383015460009081526020819052604090206001015460a060020a900460ff165b1515611b6c57600080fd5b8183600201541015611bb557611b818861211e565b60405188907f4a9ee335af9e32f32f2229943dc7a0d3b5adf7e4c5c4062b372eae8c476d928690600090a260009350612101565b600554600654604080516000805160206126d58339815191528152602060048201819052600a60248301527f766f746551756f72756d0000000000000000000000000000000000000000000060448301529151600160a060020a03948516946332ed3d6094169263693ec85e92606480820193918290030181600087803b158015611c3f57600080fd5b505af1158015611c53573d6000803e3d6000fd5b505050506040513d6020811015611c6957600080fd5b5051600654604080516000805160206126d58339815191528152602060048201819052600e60248301527f636f6d6d697453746167654c656e00000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b505050506040513d6020811015611d1657600080fd5b5051600654604080516000805160206126d58339815191528152602060048201819052600e60248301527f72657665616c53746167654c656e00000000000000000000000000000000000060448301529151600160a060020a039093169263693ec85e926064808401939192918290030181600087803b158015611d9957600080fd5b505af1158015611dad573d6000803e3d6000fd5b505050506040513d6020811015611dc357600080fd5b50516040805160e060020a63ffffffff87160281526004810194909452602484019290925260448301525160648083019260209291908290030181600087803b158015611e0f57600080fd5b505af1158015611e23573d6000803e3d6000fd5b505050506040513d6020811015611e3957600080fd5b50516040805160a081018083526006546000805160206126d5833981519152909152602060a48301819052600f60c48401527f64697370656e736174696f6e506374000000000000000000000000000000000060e48401529251939450909283926064928c92600160a060020a039091169163693ec85e916101048088019291908189030181600087803b158015611ed057600080fd5b505af1158015611ee4573d6000803e3d6000fd5b505050506040513d6020811015611efa57600080fd5b505160640302811515611f0957fe5b048152336020808301919091526000604080840182905260608085018d9052608094850183905286835282845291819020855181559285015160018401805492870151151560a060020a0274ff000000000000000000000000000000000000000019600160a060020a039390931673ffffffffffffffffffffffffffffffffffffffff19909416939093179190911691909117905583015160028201559101516003918201558301819055818710801590611fc8575082600201548711155b1515611fd357600080fd5b6002830154611fe8908863ffffffff61210c16565b600284015560048054604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523393810193909352306024840152604483018a905251600160a060020a03909116916323b872dd9160648083019260209291908290030181600087803b15801561206157600080fd5b505af1158015612075573d6000803e3d6000fd5b505050506040513d602081101561208b57600080fd5b5051151561209857600080fd5b87600019167f9a114fb0a925e49fdd5328ae588bc890c8e0d6bcd0fe0813b12aa8cb1b3ba85d8289898960405180858152602001848152602001806020018281038252848482818152602001925080828437604051920182900397509095505050505050a28093505b505050949350505050565b60008282111561211857fe5b50900390565b6000818152600160208190526040822090810154909190819060ff161561216f5760405184907fd1ffb796b7108387b2f02adf47b4b81a1690cf2a190422c87a4f670780103e6390600090a261219b565b60405184907f2e5ec035f6eac8ff1cf7cdf36cfeca7c85413f9f67652dc2c13d20f337204a2690600090a25b50506001818101546002808401546000868152602085905260408120818155948501805474ffffffffffffffffffffffffffffffffffffffffff191690559184018290556003909301819055610100909104600160a060020a031691908111156122a95760048054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0386811694820194909452602481018590529051929091169163a9059cbb916044808201926020929091908290030181600087803b15801561227257600080fd5b505af1158015612286573d6000803e3d6000fd5b505050506040513d602081101561229c57600080fd5b505115156122a957600080fd5b50505050565b818101828110156116b657fe5b6000818152600160208190526040909120015460ff1615156123045760405181907fa7bc1d57d9006d9d248707c7b6828c1bab8c51719cc06d78c82a3ee891ef967c90600090a25b60009081526001602081905260409091208101805460ff19169091179055565b60008181526001602052604081206003015490612340826117c6565b600083815260208181526040808320600101805474ff0000000000000000000000000000000000000000191660a060020a17905560055481517f053e71a6000000000000000000000000000000000000000000000000000000008152600481018890529151949550600160a060020a03169363053e71a693602480840194938390030190829087803b1580156123d557600080fd5b505af11580156123e9573d6000803e3d6000fd5b505050506040513d60208110156123ff57600080fd5b50516000838152602081815260408083206003019390935560055483517f49403183000000000000000000000000000000000000000000000000000000008152600481018790529351600160a060020a039091169363494031839360248083019493928390030190829087803b15801561247857600080fd5b505af115801561248c573d6000803e3d6000fd5b505050506040513d60208110156124a257600080fd5b505115612592576124b2836122bc565b6000838152600160205260409020600201546124d4908263ffffffff6122af16565b6000848152600160208181526040808420600281019590955593909101546101009004600160a060020a0316825260039052205461251290826122af565b6000848152600160208181526040808420909201546101009004600160a060020a031683526003808252828420949094558583528281529181902080549301548151938452918301919091528051849286927fc4497224aa78dd50c9b3e344aab02596201ca1e6dca4057a91a6c02f83f4f6c192918290030190a36126a6565b61259b8361211e565b600480546000848152602081815260408083206001015481517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a039182169681019690965260248601879052905193169363a9059cbb9360448083019491928390030190829087803b15801561261957600080fd5b505af115801561262d573d6000803e3d6000fd5b505050506040513d602081101561264357600080fd5b5051151561265057600080fd5b6000828152602081815260409182902080546003909101548351918252918101919091528151849286927f362a12431f779a2baff4f77f75ba7960ae993a5c41b425df11f7fd0af2b9cbe6929081900390910190a35b505050565b60008215156126bc575060006116b6565b508181028183828115156126cc57fe5b04146116b657fe00693ec85e00000000000000000000000000000000000000000000000000000000a165627a7a723058202d74b3583a6722432dcf5fada9c10d296b471602ac6323b207fabb0bb4d915030029

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

0000000000000000000000004946fcea7c692606e8908002e55a582af44ac12100000000000000000000000066f27365d66c0e8ad4ef87db8cb4af63ce874b7b000000000000000000000000baba8fbe1169fba058ca253236522a0d1f1737e9

-----Decoded View---------------
Arg [0] : _tokenAddr (address): 0x4946Fcea7C692606e8908002e55A582af44AC121
Arg [1] : _plcrAddr (address): 0x66f27365D66C0E8aD4ef87Db8cB4af63ce874b7b
Arg [2] : _paramsAddr (address): 0xBAbA8FBE1169FBa058CA253236522a0d1F1737e9

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000004946fcea7c692606e8908002e55a582af44ac121
Arg [1] : 00000000000000000000000066f27365d66c0e8ad4ef87db8cb4af63ce874b7b
Arg [2] : 000000000000000000000000baba8fbe1169fba058ca253236522a0d1f1737e9


Swarm Source

bzzr://2d74b3583a6722432dcf5fada9c10d296b471602ac6323b207fabb0bb4d91503

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.