Contract 0x5bCAf9BfD511166A6E0bcFE24B42F5932f43f4B7

 
Txn Hash
Method
Block
From
To
Value
0x007200215a07f040569d96aa14e231c32eb4d31d0b9d62e847aaf404fc6bffb8Set Schemes101858262020-06-02 10:20:50849 days 5 hrs agonecDAO: Deployer IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0035077620
0x6cf0e7c2c385db23814f51721fcbba3739e78f8b0e0bd9eea89825a7f0457fb2Forge Org101858212020-06-02 10:20:04849 days 5 hrs agonecDAO: Deployer IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.1169735220
0xe3410ed3ad6ba0bc3c1b3ff3ae0968b1e6b0fe4b13cc35c066fc043ae08d4939Set Schemes101857482020-06-02 10:04:27849 days 5 hrs agonecDAO: Deployer IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0028154220
0x593c44926f81942bc7a35b68d341ed9caad85ef2a538955f517781338c985d8eForge Org101857352020-06-02 10:01:53849 days 5 hrs agonecDAO: Deployer IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.1169773620
0x75680a5119ca3ef4db8d9cc9c614c6328e893861a4341d596fc1c3f8af191efeForge Org89155232019-11-11 16:58:471052 days 22 hrs agoENS Name dorgjelli.eth IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.040343357
0x4c72e2f5e1dd971eab30490da0d60158673f2399c613a531a34bfadb65ee8b2aForge Org89002702019-11-09 4:12:331055 days 11 hrs ago0xb11d3de1746516aa26a39a9fefa4df0a6b0521a0 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.123653720
0x33e4289d8910afb3e90b18f5fddd8b0a5d24224f017720e090572beb8ec5eccfSet Schemes88983092019-11-08 20:36:531055 days 19 hrs agoENS Name dorgjelli.eth IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0013269910
0xe3e80e7a929c259d12b0a380130a5cb49413aac087ef51dd6cf9dac66aee46d6Forge Org88982852019-11-08 20:31:161055 days 19 hrs agoENS Name dorgjelli.eth IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0576519210
0xa8f91adb0db654a11be84354c1f1666d39624984d6dd271777e4f0fdb775f414Forge Org88980552019-11-08 19:32:531055 days 20 hrs agoENS Name dorgjelli.eth IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0576519210
0x5644b8b33fb034b4526e310e4e80eaea75a6caae7638c6e350952a1450d3d5a6Forge Org88964772019-11-08 13:30:591056 days 2 hrs ago0x5b88ab3ab9c0db863adbff778859bb63c18907a7 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0576519210
0x49849c7e4b01e1013713f0a15a5bcc7b89e4f6ca481864bcc3e82539a5a8710cForge Org88963762019-11-08 13:09:391056 days 2 hrs ago0x5b88ab3ab9c0db863adbff778859bb63c18907a7 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0576519210
0xf927f20b0c0a65851a84c24ddbcc9058608fc6735f2b461d8fed5d9506744ebdForge Org88910782019-11-07 16:32:311056 days 23 hrs ago0x5b88ab3ab9c0db863adbff778859bb63c18907a7 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.040356347
0x210c2ed5acf5aa467cbc1c8432343e6af669ecb106340998b23764dcdf110e9cForge Org88875212019-11-07 2:34:491057 days 13 hrs ago0x8062e69af89430d0749697cede9614cda80325e0 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.043278797
0x550440e573e1ff484d7f2fcec0bcfb6013c3d039f2303233cad677fccdd7d638Forge Org88872102019-11-07 1:26:571057 days 14 hrs ago0x8062e69af89430d0749697cede9614cda80325e0 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.043278797
0x7db3e01cad80f3c39ca4f44f28a0e984f046a8bbd5cd3d7f7c2634e522166d12Set Schemes88768732019-11-05 9:52:161059 days 5 hrs ago0xf5913759b449fae8900d61f7116d451d200c60f7 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.000929347
0xaab409bfead71c9e387ee9b8bb55ef0a55ee0d7fde648fe0d4ff1572ef2b74dcForge Org88767962019-11-05 9:33:301059 days 6 hrs agoGitcoin Grants: Prtcl IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.040021877
0x48c8653a9eb5dbd9f582ff2c68b993062ac27e9f3ad53ed0e4df404859d07e91Forge Org88767542019-11-05 9:23:501059 days 6 hrs ago0xf5913759b449fae8900d61f7116d451d200c60f7 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.040354557
0x49b66f3bba15a9651805b93ec158db65040e180c655908096e446d5f3f810edaForge Org88473312019-10-31 15:41:211063 days 23 hrs ago0xebe7e47e89129382d0837f067ed51d318c891307 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.046600867
0x99c7aec980145ea616e45e7f920a86095922322855182a0964cceacfda1d5a64Set Schemes87607462019-10-17 20:49:551077 days 18 hrs ago0xcaa9c1251dfdad81f4175edbd09ba9d9131aca77 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.000929347
0x3b04019e89da174bf534d19152274bf2e4f30fd30fa065d12fae1c43c666a542Add Founders87606972019-10-17 20:38:081077 days 19 hrs ago0xcaa9c1251dfdad81f4175edbd09ba9d9131aca77 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.002631637
0xdc3a9aa3e1d9224e5378558e1316c78f06f327126fbca4fa7cf7481f714ef92cForge Org87606932019-10-17 20:37:361077 days 19 hrs ago0xcaa9c1251dfdad81f4175edbd09ba9d9131aca77 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.047731267
0x833c90eb2cb4ebee95290381a564266fdec571c5aab5798caea844827bb8b556Forge Org87103392019-10-09 22:29:571085 days 17 hrs agoENS Name dorgjelli.eth IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.047549058
0xe8eeefe12a90ce5b6891bc2d590f12c9be32473b25a53ba3d7a32a4fdcd7c559Forge Org86931122019-10-07 5:26:071088 days 10 hrs ago0x00fcaf8c715f4e8b4710a73fdcf9e729972612e3 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.058869319.90577617
0xa8e668b0147ef53c794c92ef35dabd0859ac79c81b7246e9d1b159c0bc1efda3Set Schemes86930212019-10-07 5:05:251088 days 10 hrs ago0x00fcaf8c715f4e8b4710a73fdcf9e729972612e3 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0013263510
0x7a4deb6f47e043dbe37e01b55c9468efd72dd8a572ea1eb64033e79d0185818eForge Org86928692019-10-07 4:28:001088 days 11 hrs ago0x00fcaf8c715f4e8b4710a73fdcf9e729972612e3 IN  0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b70 Ether0.0594292810
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x6cf0e7c2c385db23814f51721fcbba3739e78f8b0e0bd9eea89825a7f0457fb2101858212020-06-02 10:20:04849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x6cf0e7c2c385db23814f51721fcbba3739e78f8b0e0bd9eea89825a7f0457fb2101858212020-06-02 10:20:04849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x6cf0e7c2c385db23814f51721fcbba3739e78f8b0e0bd9eea89825a7f0457fb2101858212020-06-02 10:20:04849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x593c44926f81942bc7a35b68d341ed9caad85ef2a538955f517781338c985d8e101857352020-06-02 10:01:53849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x593c44926f81942bc7a35b68d341ed9caad85ef2a538955f517781338c985d8e101857352020-06-02 10:01:53849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x593c44926f81942bc7a35b68d341ed9caad85ef2a538955f517781338c985d8e101857352020-06-02 10:01:53849 days 5 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x75680a5119ca3ef4db8d9cc9c614c6328e893861a4341d596fc1c3f8af191efe89155232019-11-11 16:58:471052 days 22 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x75680a5119ca3ef4db8d9cc9c614c6328e893861a4341d596fc1c3f8af191efe89155232019-11-11 16:58:471052 days 22 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x75680a5119ca3ef4db8d9cc9c614c6328e893861a4341d596fc1c3f8af191efe89155232019-11-11 16:58:471052 days 22 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x4c72e2f5e1dd971eab30490da0d60158673f2399c613a531a34bfadb65ee8b2a89002702019-11-09 4:12:331055 days 11 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x4c72e2f5e1dd971eab30490da0d60158673f2399c613a531a34bfadb65ee8b2a89002702019-11-09 4:12:331055 days 11 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x4c72e2f5e1dd971eab30490da0d60158673f2399c613a531a34bfadb65ee8b2a89002702019-11-09 4:12:331055 days 11 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xe3e80e7a929c259d12b0a380130a5cb49413aac087ef51dd6cf9dac66aee46d688982852019-11-08 20:31:161055 days 19 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xe3e80e7a929c259d12b0a380130a5cb49413aac087ef51dd6cf9dac66aee46d688982852019-11-08 20:31:161055 days 19 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xe3e80e7a929c259d12b0a380130a5cb49413aac087ef51dd6cf9dac66aee46d688982852019-11-08 20:31:161055 days 19 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xa8f91adb0db654a11be84354c1f1666d39624984d6dd271777e4f0fdb775f41488980552019-11-08 19:32:531055 days 20 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xa8f91adb0db654a11be84354c1f1666d39624984d6dd271777e4f0fdb775f41488980552019-11-08 19:32:531055 days 20 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xa8f91adb0db654a11be84354c1f1666d39624984d6dd271777e4f0fdb775f41488980552019-11-08 19:32:531055 days 20 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x5644b8b33fb034b4526e310e4e80eaea75a6caae7638c6e350952a1450d3d5a688964772019-11-08 13:30:591056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x5644b8b33fb034b4526e310e4e80eaea75a6caae7638c6e350952a1450d3d5a688964772019-11-08 13:30:591056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x5644b8b33fb034b4526e310e4e80eaea75a6caae7638c6e350952a1450d3d5a688964772019-11-08 13:30:591056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x49849c7e4b01e1013713f0a15a5bcc7b89e4f6ca481864bcc3e82539a5a8710c88963762019-11-08 13:09:391056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x49849c7e4b01e1013713f0a15a5bcc7b89e4f6ca481864bcc3e82539a5a8710c88963762019-11-08 13:09:391056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0x49849c7e4b01e1013713f0a15a5bcc7b89e4f6ca481864bcc3e82539a5a8710c88963762019-11-08 13:09:391056 days 2 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
0xf927f20b0c0a65851a84c24ddbcc9058608fc6735f2b461d8fed5d9506744ebd88910782019-11-07 16:32:311056 days 23 hrs ago 0x5bcaf9bfd511166a6e0bcfe24b42f5932f43f4b7  Contract Creation0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DaoCreator

Compiler Version
v0.5.4+commit.9549d8ff

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2019-05-27
*/

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

pragma solidity ^0.5.0;

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

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

    /**
     * @dev The Ownable constructor sets the original `owner` of the contract to the sender
     * account.
     */
    constructor () internal {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), _owner);
    }

    /**
     * @return the address of the owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

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

    /**
     * @return true if `msg.sender` is the owner of the contract.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _owner;
    }

    /**
     * @dev Allows the current owner to relinquish control of the contract.
     * @notice Renouncing to ownership will leave the contract without an owner.
     * It will not be possible to call the functions with the `onlyOwner`
     * modifier anymore.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

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

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

// File: @daostack/infra/contracts/Reputation.sol

pragma solidity ^0.5.4;



/**
 * @title Reputation system
 * @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust .
 * A reputation is use to assign influence measure to a DAO'S peers.
 * Reputation is similar to regular tokens but with one crucial difference: It is non-transferable.
 * The Reputation contract maintain a map of address to reputation value.
 * It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address.
 */

contract Reputation is Ownable {

    uint8 public decimals = 18;             //Number of decimals of the smallest unit
    // Event indicating minting of reputation to an address.
    event Mint(address indexed _to, uint256 _amount);
    // Event indicating burning of reputation for an address.
    event Burn(address indexed _from, uint256 _amount);

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

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

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

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

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

    /// @notice Constructor to create a Reputation
    constructor(
    ) public
    {
    }

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

  ////////////////
  // Query balance and totalSupply in History
  ////////////////
    /**
    * @dev return the reputation amount of a given owner
    * @param _owner an address of the owner which we want to get his reputation
    */
    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balanceOfAt(_owner, block.number);
    }

      /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
      /// @param _owner The address from which the balance will be retrieved
      /// @param _blockNumber The block number when the balance is queried
      /// @return The balance at `_blockNumber`
    function balanceOfAt(address _owner, uint256 _blockNumber)
    public view returns (uint256)
    {
        if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
            return 0;
          // This will return the expected balance during normal situations
        } else {
            return getValueAt(balances[_owner], _blockNumber);
        }
    }

      /// @notice Total amount of reputation at a specific `_blockNumber`.
      /// @param _blockNumber The block number when the totalSupply is queried
      /// @return The total amount of reputation at `_blockNumber`
    function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
        if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
            return 0;
          // This will return the expected totalSupply during normal situations
        } else {
            return getValueAt(totalSupplyHistory, _blockNumber);
        }
    }

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

      /// @notice Burns `_amount` reputation from `_owner`
      /// @param _user The address that will lose the reputation
      /// @param _amount The quantity of reputation to burn
      /// @return True if the reputation are burned correctly
    function burn(address _user, uint256 _amount) public onlyOwner returns (bool) {
        uint256 curTotalSupply = totalSupply();
        uint256 amountBurned = _amount;
        uint256 previousBalanceFrom = balanceOf(_user);
        if (previousBalanceFrom < amountBurned) {
            amountBurned = previousBalanceFrom;
        }
        updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned);
        updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned);
        emit Burn(_user, amountBurned);
        return true;
    }

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

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

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

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

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

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

pragma solidity ^0.5.0;

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
interface IERC20 {
    function transfer(address to, uint256 value) external returns (bool);

    function approve(address spender, uint256 value) external returns (bool);

    function transferFrom(address from, address to, uint256 value) external returns (bool);

    function totalSupply() external view returns (uint256);

    function balanceOf(address who) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    event Transfer(address indexed from, address indexed to, uint256 value);

    event Approval(address indexed owner, address indexed spender, uint256 value);
}

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

pragma solidity ^0.5.0;

/**
 * @title SafeMath
 * @dev Unsigned math operations with safety checks that revert on error
 */
library SafeMath {
    /**
    * @dev Multiplies two unsigned integers, reverts on overflow.
    */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring '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;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }

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

        return c;
    }

    /**
    * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
    */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
    * @dev Adds two unsigned integers, reverts on overflow.
    */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
    * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
    * reverts when dividing by zero.
    */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0);
        return a % b;
    }
}

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

pragma solidity ^0.5.0;



/**
 * @title Standard ERC20 token
 *
 * @dev Implementation of the basic standard token.
 * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
 * Originally based on code by FirstBlood:
 * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 *
 * This implementation emits additional Approval events, allowing applications to reconstruct the allowance status for
 * all accounts just by listening to said events. Note that this isn't required by the specification, and other
 * compliant implementations may not do it.
 */
contract ERC20 is IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowed;

    uint256 private _totalSupply;

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

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

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

    /**
    * @dev Transfer token for a specified address
    * @param to The address to transfer to.
    * @param value The amount to be transferred.
    */
    function transfer(address to, uint256 value) public returns (bool) {
        _transfer(msg.sender, to, value);
        return true;
    }

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

        _allowed[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    /**
     * @dev Transfer tokens from one address to another.
     * Note that while this function emits an Approval event, this is not required as per the specification,
     * and other compliant implementations may not emit the event.
     * @param from address The address which you want to send tokens from
     * @param to address The address which you want to transfer to
     * @param value uint256 the amount of tokens to be transferred
     */
    function transferFrom(address from, address to, uint256 value) public returns (bool) {
        _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
        _transfer(from, to, value);
        emit Approval(from, msg.sender, _allowed[from][msg.sender]);
        return true;
    }

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

        _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
        emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
        return true;
    }

    /**
     * @dev Decrease the amount of tokens that an owner allowed to a spender.
     * approve should be called when allowed_[_spender] == 0. To decrement
     * allowed value is better to use this function to avoid 2 calls (and wait until
     * the first transaction is mined)
     * From MonolithDAO Token.sol
     * Emits an Approval event.
     * @param spender The address which will spend the funds.
     * @param subtractedValue The amount of tokens to decrease the allowance by.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        require(spender != address(0));

        _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
        emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
        return true;
    }

    /**
    * @dev Transfer token for a specified addresses
    * @param from The address to transfer from.
    * @param to The address to transfer to.
    * @param value The amount to be transferred.
    */
    function _transfer(address from, address to, uint256 value) internal {
        require(to != address(0));

        _balances[from] = _balances[from].sub(value);
        _balances[to] = _balances[to].add(value);
        emit Transfer(from, to, value);
    }

    /**
     * @dev Internal function that mints an amount of the token and assigns it to
     * an account. This encapsulates the modification of balances such that the
     * proper events are emitted.
     * @param account The account that will receive the created tokens.
     * @param value The amount that will be created.
     */
    function _mint(address account, uint256 value) internal {
        require(account != address(0));

        _totalSupply = _totalSupply.add(value);
        _balances[account] = _balances[account].add(value);
        emit Transfer(address(0), account, value);
    }

    /**
     * @dev Internal function that burns an amount of the token of a given
     * account.
     * @param account The account whose tokens will be burnt.
     * @param value The amount that will be burnt.
     */
    function _burn(address account, uint256 value) internal {
        require(account != address(0));

        _totalSupply = _totalSupply.sub(value);
        _balances[account] = _balances[account].sub(value);
        emit Transfer(account, address(0), value);
    }

    /**
     * @dev Internal function that burns an amount of the token of a given
     * account, deducting from the sender's allowance for said account. Uses the
     * internal burn function.
     * Emits an Approval event (reflecting the reduced allowance).
     * @param account The account whose tokens will be burnt.
     * @param value The amount that will be burnt.
     */
    function _burnFrom(address account, uint256 value) internal {
        _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
        _burn(account, value);
        emit Approval(account, msg.sender, _allowed[account][msg.sender]);
    }
}

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

pragma solidity ^0.5.0;


/**
 * @title Burnable Token
 * @dev Token that can be irreversibly burned (destroyed).
 */
contract ERC20Burnable is ERC20 {
    /**
     * @dev Burns a specific amount of tokens.
     * @param value The amount of token to be burned.
     */
    function burn(uint256 value) public {
        _burn(msg.sender, value);
    }

    /**
     * @dev Burns a specific amount of tokens from the target address and decrements allowance
     * @param from address The address which you want to send tokens from
     * @param value uint256 The amount of token to be burned
     */
    function burnFrom(address from, uint256 value) public {
        _burnFrom(from, value);
    }
}

// File: contracts/controller/DAOToken.sol

pragma solidity ^0.5.4;





/**
 * @title DAOToken, base on zeppelin contract.
 * @dev ERC20 compatible token. It is a mintable, burnable token.
 */

contract DAOToken is ERC20, ERC20Burnable, Ownable {

    string public name;
    string public symbol;
    // solhint-disable-next-line const-name-snakecase
    uint8 public constant decimals = 18;
    uint256 public cap;

    /**
    * @dev Constructor
    * @param _name - token name
    * @param _symbol - token symbol
    * @param _cap - token cap - 0 value means no cap
    */
    constructor(string memory _name, string memory _symbol, uint256 _cap)
    public {
        name = _name;
        symbol = _symbol;
        cap = _cap;
    }

    /**
     * @dev Function to mint tokens
     * @param _to The address that will receive the minted tokens.
     * @param _amount The amount of tokens to mint.
     */
    function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
        if (cap > 0)
            require(totalSupply().add(_amount) <= cap);
        _mint(_to, _amount);
        return true;
    }
}

// File: openzeppelin-solidity/contracts/utils/Address.sol

pragma solidity ^0.5.0;

/**
 * Utility library of inline functions on addresses
 */
library Address {
    /**
     * Returns whether the target address is a contract
     * @dev This function will return false if invoked during the constructor of a contract,
     * as the code is not actually created until after the constructor finishes.
     * @param account address of the account to check
     * @return whether the target address is a contract
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // XXX Currently there is no better way to check if there is a contract in an address
        // than to check the size of the code at that address.
        // See https://ethereum.stackexchange.com/a/14016/36603
        // for more details about how this works.
        // TODO Check this again before the Serenity release, because all addresses will be
        // contracts then.
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }
}

// File: contracts/libs/SafeERC20.sol

/*

SafeERC20 by daostack.
The code is based on a fix by SECBIT Team.

USE WITH CAUTION & NO WARRANTY

REFERENCE & RELATED READING
- https://github.com/ethereum/solidity/issues/4116
- https://medium.com/@chris_77367/explaining-unexpected-reverts-starting-with-solidity-0-4-22-3ada6e82308c
- https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
- https://gist.github.com/BrendanChou/88a2eeb80947ff00bcf58ffdafeaeb61

*/
pragma solidity ^0.5.4;



library SafeERC20 {
    using Address for address;

    bytes4 constant private TRANSFER_SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)")));
    bytes4 constant private TRANSFERFROM_SELECTOR = bytes4(keccak256(bytes("transferFrom(address,address,uint256)")));
    bytes4 constant private APPROVE_SELECTOR = bytes4(keccak256(bytes("approve(address,uint256)")));

    function safeTransfer(address _erc20Addr, address _to, uint256 _value) internal {

        // Must be a contract addr first!
        require(_erc20Addr.isContract());

        (bool success, bytes memory returnValue) =
        // solhint-disable-next-line avoid-low-level-calls
        _erc20Addr.call(abi.encodeWithSelector(TRANSFER_SELECTOR, _to, _value));
        // call return false when something wrong
        require(success);
        //check return value
        require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
    }

    function safeTransferFrom(address _erc20Addr, address _from, address _to, uint256 _value) internal {

        // Must be a contract addr first!
        require(_erc20Addr.isContract());

        (bool success, bytes memory returnValue) =
        // solhint-disable-next-line avoid-low-level-calls
        _erc20Addr.call(abi.encodeWithSelector(TRANSFERFROM_SELECTOR, _from, _to, _value));
        // call return false when something wrong
        require(success);
        //check return value
        require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
    }

    function safeApprove(address _erc20Addr, address _spender, uint256 _value) internal {

        // Must be a contract addr first!
        require(_erc20Addr.isContract());

        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero.
        require((_value == 0) || (IERC20(_erc20Addr).allowance(address(this), _spender) == 0));

        (bool success, bytes memory returnValue) =
        // solhint-disable-next-line avoid-low-level-calls
        _erc20Addr.call(abi.encodeWithSelector(APPROVE_SELECTOR, _spender, _value));
        // call return false when something wrong
        require(success);
        //check return value
        require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
    }
}

// File: contracts/controller/Avatar.sol

pragma solidity ^0.5.4;







/**
 * @title An Avatar holds tokens, reputation and ether for a controller
 */
contract Avatar is Ownable {
    using SafeERC20 for address;

    string public orgName;
    DAOToken public nativeToken;
    Reputation public nativeReputation;

    event GenericCall(address indexed _contract, bytes _data, uint _value, bool _success);
    event SendEther(uint256 _amountInWei, address indexed _to);
    event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint256 _value);
    event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint256 _value);
    event ExternalTokenApproval(address indexed _externalToken, address _spender, uint256 _value);
    event ReceiveEther(address indexed _sender, uint256 _value);
    event MetaData(string _metaData);

    /**
    * @dev the constructor takes organization name, native token and reputation system
    and creates an avatar for a controller
    */
    constructor(string memory _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
        orgName = _orgName;
        nativeToken = _nativeToken;
        nativeReputation = _nativeReputation;
    }

    /**
    * @dev enables an avatar to receive ethers
    */
    function() external payable {
        emit ReceiveEther(msg.sender, msg.value);
    }

    /**
    * @dev perform a generic call to an arbitrary contract
    * @param _contract  the contract's address to call
    * @param _data ABI-encoded contract call to call `_contract` address.
    * @param _value value (ETH) to transfer with the transaction
    * @return bool    success or fail
    *         bytes - the return bytes of the called contract's function.
    */
    function genericCall(address _contract, bytes memory _data, uint256 _value)
    public
    onlyOwner
    returns(bool success, bytes memory returnValue) {
      // solhint-disable-next-line avoid-call-value
        (success, returnValue) = _contract.call.value(_value)(_data);
        emit GenericCall(_contract, _data, _value, success);
    }

    /**
    * @dev send ethers from the avatar's wallet
    * @param _amountInWei amount to send in Wei units
    * @param _to send the ethers to this address
    * @return bool which represents success
    */
    function sendEther(uint256 _amountInWei, address payable _to) public onlyOwner returns(bool) {
        _to.transfer(_amountInWei);
        emit SendEther(_amountInWei, _to);
        return true;
    }

    /**
    * @dev external token transfer
    * @param _externalToken the token contract
    * @param _to the destination address
    * @param _value the amount of tokens to transfer
    * @return bool which represents success
    */
    function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value)
    public onlyOwner returns(bool)
    {
        address(_externalToken).safeTransfer(_to, _value);
        emit ExternalTokenTransfer(address(_externalToken), _to, _value);
        return true;
    }

    /**
    * @dev external token transfer from a specific account
    * @param _externalToken the token contract
    * @param _from the account to spend token from
    * @param _to the destination address
    * @param _value the amount of tokens to transfer
    * @return bool which represents success
    */
    function externalTokenTransferFrom(
        IERC20 _externalToken,
        address _from,
        address _to,
        uint256 _value
    )
    public onlyOwner returns(bool)
    {
        address(_externalToken).safeTransferFrom(_from, _to, _value);
        emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
        return true;
    }

    /**
    * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
    *      on behalf of msg.sender.
    * @param _externalToken the address of the Token Contract
    * @param _spender address
    * @param _value the amount of ether (in Wei) which the approval is referring to.
    * @return bool which represents a success
    */
    function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value)
    public onlyOwner returns(bool)
    {
        address(_externalToken).safeApprove(_spender, _value);
        emit ExternalTokenApproval(address(_externalToken), _spender, _value);
        return true;
    }

    /**
    * @dev metaData emits an event with a string, should contain the hash of some meta data.
    * @param _metaData a string representing a hash of the meta data
    * @return bool which represents a success
    */
    function metaData(string memory _metaData) public onlyOwner returns(bool) {
        emit MetaData(_metaData);
        return true;
    }


}

// File: contracts/universalSchemes/UniversalSchemeInterface.sol

pragma solidity ^0.5.4;


contract UniversalSchemeInterface {

    function getParametersFromController(Avatar _avatar) internal view returns(bytes32);
    
}

// File: contracts/globalConstraints/GlobalConstraintInterface.sol

pragma solidity ^0.5.4;


contract GlobalConstraintInterface {

    enum CallPhase { Pre, Post, PreAndPost }

    function pre( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool);
    function post( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool);
    /**
     * @dev when return if this globalConstraints is pre, post or both.
     * @return CallPhase enum indication  Pre, Post or PreAndPost.
     */
    function when() public returns(CallPhase);
}

// File: contracts/controller/ControllerInterface.sol

pragma solidity ^0.5.4;



/**
 * @title Controller contract
 * @dev A controller controls the organizations tokens ,reputation and avatar.
 * It is subject to a set of schemes and constraints that determine its behavior.
 * Each scheme has it own parameters and operation permissions.
 */
interface ControllerInterface {

    /**
     * @dev Mint `_amount` of reputation that are assigned to `_to` .
     * @param  _amount amount of reputation to mint
     * @param _to beneficiary address
     * @return bool which represents a success
    */
    function mintReputation(uint256 _amount, address _to, address _avatar)
    external
    returns(bool);

    /**
     * @dev Burns `_amount` of reputation from `_from`
     * @param _amount amount of reputation to burn
     * @param _from The address that will lose the reputation
     * @return bool which represents a success
     */
    function burnReputation(uint256 _amount, address _from, address _avatar)
    external
    returns(bool);

    /**
     * @dev mint tokens .
     * @param  _amount amount of token to mint
     * @param _beneficiary beneficiary address
     * @param _avatar address
     * @return bool which represents a success
     */
    function mintTokens(uint256 _amount, address _beneficiary, address _avatar)
    external
    returns(bool);

  /**
   * @dev register or update a scheme
   * @param _scheme the address of the scheme
   * @param _paramsHash a hashed configuration of the usage of the scheme
   * @param _permissions the permissions the new scheme will have
   * @param _avatar address
   * @return bool which represents a success
   */
    function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar)
    external
    returns(bool);

    /**
     * @dev unregister a scheme
     * @param _avatar address
     * @param _scheme the address of the scheme
     * @return bool which represents a success
     */
    function unregisterScheme(address _scheme, address _avatar)
    external
    returns(bool);

    /**
     * @dev unregister the caller's scheme
     * @param _avatar address
     * @return bool which represents a success
     */
    function unregisterSelf(address _avatar) external returns(bool);

    /**
     * @dev add or update Global Constraint
     * @param _globalConstraint the address of the global constraint to be added.
     * @param _params the constraint parameters hash.
     * @param _avatar the avatar of the organization
     * @return bool which represents a success
     */
    function addGlobalConstraint(address _globalConstraint, bytes32 _params, address _avatar)
    external returns(bool);

    /**
     * @dev remove Global Constraint
     * @param _globalConstraint the address of the global constraint to be remove.
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function removeGlobalConstraint (address _globalConstraint, address _avatar)
    external  returns(bool);

  /**
    * @dev upgrade the Controller
    *      The function will trigger an event 'UpgradeController'.
    * @param  _newController the address of the new controller.
    * @param _avatar address
    * @return bool which represents a success
    */
    function upgradeController(address _newController, Avatar _avatar)
    external returns(bool);

    /**
    * @dev perform a generic call to an arbitrary contract
    * @param _contract  the contract's address to call
    * @param _data ABI-encoded contract call to call `_contract` address.
    * @param _avatar the controller's avatar address
    * @param _value value (ETH) to transfer with the transaction
    * @return bool -success
    *         bytes  - the return value of the called _contract's function.
    */
    function genericCall(address _contract, bytes calldata _data, Avatar _avatar, uint256 _value)
    external
    returns(bool, bytes memory);

  /**
   * @dev send some ether
   * @param _amountInWei the amount of ether (in Wei) to send
   * @param _to address of the beneficiary
   * @param _avatar address
   * @return bool which represents a success
   */
    function sendEther(uint256 _amountInWei, address payable _to, Avatar _avatar)
    external returns(bool);

    /**
    * @dev send some amount of arbitrary ERC20 Tokens
    * @param _externalToken the address of the Token Contract
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @param _avatar address
    * @return bool which represents a success
    */
    function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
    external
    returns(bool);

    /**
    * @dev transfer token "from" address "to" address
    *      One must to approve the amount of tokens which can be spend from the
    *      "from" account.This can be done using externalTokenApprove.
    * @param _externalToken the address of the Token Contract
    * @param _from address of the account to send from
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @param _avatar address
    * @return bool which represents a success
    */
    function externalTokenTransferFrom(
    IERC20 _externalToken,
    address _from,
    address _to,
    uint256 _value,
    Avatar _avatar)
    external
    returns(bool);

    /**
    * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
    *      on behalf of msg.sender.
    * @param _externalToken the address of the Token Contract
    * @param _spender address
    * @param _value the amount of ether (in Wei) which the approval is referring to.
    * @return bool which represents a success
    */
    function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value, Avatar _avatar)
    external
    returns(bool);

    /**
    * @dev metaData emits an event with a string, should contain the hash of some meta data.
    * @param _metaData a string representing a hash of the meta data
    * @param _avatar Avatar
    * @return bool which represents a success
    */
    function metaData(string calldata _metaData, Avatar _avatar) external returns(bool);

    /**
     * @dev getNativeReputation
     * @param _avatar the organization avatar.
     * @return organization native reputation
     */
    function getNativeReputation(address _avatar)
    external
    view
    returns(address);

    function isSchemeRegistered( address _scheme, address _avatar) external view returns(bool);

    function getSchemeParameters(address _scheme, address _avatar) external view returns(bytes32);

    function getGlobalConstraintParameters(address _globalConstraint, address _avatar) external view returns(bytes32);

    function getSchemePermissions(address _scheme, address _avatar) external view returns(bytes4);

    /**
     * @dev globalConstraintsCount return the global constraint pre and post count
     * @return uint256 globalConstraintsPre count.
     * @return uint256 globalConstraintsPost count.
     */
    function globalConstraintsCount(address _avatar) external view returns(uint, uint);

    function isGlobalConstraintRegistered(address _globalConstraint, address _avatar) external view returns(bool);
}

// File: contracts/universalSchemes/UniversalScheme.sol

pragma solidity ^0.5.4;





contract UniversalScheme is UniversalSchemeInterface {
    /**
    *  @dev get the parameters for the current scheme from the controller
    */
    function getParametersFromController(Avatar _avatar) internal view returns(bytes32) {
        require(ControllerInterface(_avatar.owner()).isSchemeRegistered(address(this), address(_avatar)),
        "scheme is not registered");
        return ControllerInterface(_avatar.owner()).getSchemeParameters(address(this), address(_avatar));
    }
}

// File: contracts/controller/UController.sol

pragma solidity ^0.5.4;





/**
 * @title Universal Controller contract
 * @dev A universal controller hold organizations and controls their tokens ,reputations
 *       and avatar.
 * It is subject to a set of schemes and constraints that determine its behavior.
 * Each scheme has it own parameters and operation permissions.
 */
contract UController is ControllerInterface {

    struct Scheme {
        bytes32 paramsHash;  // a hash "configuration" of the scheme
        bytes4  permissions; // A bitwise flags of permissions,
                            // All 0: Not registered,
                            // 1st bit: Flag if the scheme is registered,
                            // 2nd bit: Scheme can register other schemes
                            // 3th bit: Scheme can add/remove global constraints
                            // 4rd bit: Scheme can upgrade the controller
                            // 5th bit: Scheme can call delegatecall
    }

    struct GlobalConstraint {
        address gcAddress;
        bytes32 params;
    }

    struct GlobalConstraintRegister {
        bool isRegistered; //is registered
        uint256 index;    //index at globalConstraints
    }

    struct Organization {
        DAOToken                  nativeToken;
        Reputation                nativeReputation;
        mapping(address=>Scheme)  schemes;
      // globalConstraintsPre that determine pre- conditions for all actions on the controller
        GlobalConstraint[] globalConstraintsPre;
        // globalConstraintsPost that determine post-conditions for all actions on the controller
        GlobalConstraint[] globalConstraintsPost;
      // globalConstraintsRegisterPre indicate if a globalConstraints is registered as a Pre global constraint.
        mapping(address=>GlobalConstraintRegister) globalConstraintsRegisterPre;
      // globalConstraintsRegisterPost indicate if a globalConstraints is registered as a Post global constraint.
        mapping(address=>GlobalConstraintRegister) globalConstraintsRegisterPost;
    }

    //mapping between organization's avatar address to Organization
    mapping(address=>Organization) public organizations;
    // newController will point to the new controller after the present controller is upgraded
    //  address external newController;
    mapping(address=>address) public newControllers;//mapping between avatar address and newController address
    //mapping for all reputation system and tokens addresses registered.
    mapping(address=>bool) public actors;

    event MintReputation (address indexed _sender, address indexed _to, uint256 _amount, address indexed _avatar);
    event BurnReputation (address indexed _sender, address indexed _from, uint256 _amount, address indexed _avatar);
    event MintTokens (address indexed _sender, address indexed _beneficiary, uint256 _amount, address indexed _avatar);
    event RegisterScheme (address indexed _sender, address indexed _scheme, address indexed _avatar);
    event UnregisterScheme (address indexed _sender, address indexed _scheme, address indexed _avatar);
    event UpgradeController(address indexed _oldController, address _newController, address _avatar);

    event AddGlobalConstraint(
        address indexed _globalConstraint,
        bytes32 _params,
        GlobalConstraintInterface.CallPhase _when,
        address indexed _avatar
    );

    event RemoveGlobalConstraint(
        address indexed _globalConstraint,
        uint256 _index,
        bool _isPre,
        address indexed _avatar
    );

   /**
    * @dev newOrganization set up a new organization with default daoCreator.
    * @param _avatar the organization avatar
    */
    function newOrganization(
        Avatar _avatar
    ) external
    {
        require(!actors[address(_avatar)]);
        actors[address(_avatar)] = true;
        require(_avatar.owner() == address(this));
        DAOToken nativeToken = _avatar.nativeToken();
        Reputation nativeReputation = _avatar.nativeReputation();
        require(nativeToken.owner() == address(this));
        require(nativeReputation.owner() == address(this));
        //To guaranty uniqueness for the reputation systems.
        require(!actors[address(nativeReputation)]);
        actors[address(nativeReputation)] = true;
        //To guaranty uniqueness for the nativeToken.
        require(!actors[address(nativeToken)]);
        actors[address(nativeToken)] = true;
        organizations[address(_avatar)].nativeToken = nativeToken;
        organizations[address(_avatar)].nativeReputation = nativeReputation;
        organizations[address(_avatar)].schemes[msg.sender] =
        Scheme({paramsHash: bytes32(0), permissions: bytes4(0x0000001f)});
        emit RegisterScheme(msg.sender, msg.sender, address(_avatar));
    }

  // Modifiers:
    modifier onlyRegisteredScheme(address avatar) {
        require(organizations[avatar].schemes[msg.sender].permissions&bytes4(0x00000001) == bytes4(0x00000001));
        _;
    }

    modifier onlyRegisteringSchemes(address avatar) {
        require(organizations[avatar].schemes[msg.sender].permissions&bytes4(0x00000002) == bytes4(0x00000002));
        _;
    }

    modifier onlyGlobalConstraintsScheme(address avatar) {
        require(organizations[avatar].schemes[msg.sender].permissions&bytes4(0x00000004) == bytes4(0x00000004));
        _;
    }

    modifier onlyUpgradingScheme(address _avatar) {
        require(organizations[_avatar].schemes[msg.sender].permissions&bytes4(0x00000008) == bytes4(0x00000008));
        _;
    }

    modifier onlyGenericCallScheme(address _avatar) {
        require(organizations[_avatar].schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
        _;
    }

    modifier onlyMetaDataScheme(address _avatar) {
        require(organizations[_avatar].schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
        _;
    }

    modifier onlySubjectToConstraint(bytes32 func, address _avatar) {
        uint256 idx;
        GlobalConstraint[] memory globalConstraintsPre = organizations[_avatar].globalConstraintsPre;
        GlobalConstraint[] memory globalConstraintsPost = organizations[_avatar].globalConstraintsPost;
        for (idx = 0; idx < globalConstraintsPre.length; idx++) {
            require(
            (GlobalConstraintInterface(globalConstraintsPre[idx].gcAddress))
            .pre(msg.sender, globalConstraintsPre[idx].params, func));
        }
        _;
        for (idx = 0; idx < globalConstraintsPost.length; idx++) {
            require(
            (GlobalConstraintInterface(globalConstraintsPost[idx].gcAddress))
            .post(msg.sender, globalConstraintsPost[idx].params, func));
        }
    }

    /**
     * @dev Mint `_amount` of reputation that are assigned to `_to` .
     * @param  _amount amount of reputation to mint
     * @param _to beneficiary address
     * @param _avatar the address of the organization's avatar
     * @return bool which represents a success
     */
    function mintReputation(uint256 _amount, address _to, address _avatar)
    external
    onlyRegisteredScheme(_avatar)
    onlySubjectToConstraint("mintReputation", _avatar)
    returns(bool)
    {
        emit MintReputation(msg.sender, _to, _amount, _avatar);
        return organizations[_avatar].nativeReputation.mint(_to, _amount);
    }

    /**
     * @dev Burns `_amount` of reputation from `_from`
     * @param _amount amount of reputation to burn
     * @param _from The address that will lose the reputation
     * @return bool which represents a success
     */
    function burnReputation(uint256 _amount, address _from, address _avatar)
    external
    onlyRegisteredScheme(_avatar)
    onlySubjectToConstraint("burnReputation", _avatar)
    returns(bool)
    {
        emit BurnReputation(msg.sender, _from, _amount, _avatar);
        return organizations[_avatar].nativeReputation.burn(_from, _amount);
    }

    /**
     * @dev mint tokens .
     * @param  _amount amount of token to mint
     * @param _beneficiary beneficiary address
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function mintTokens(uint256 _amount, address _beneficiary, address _avatar)
    external
    onlyRegisteredScheme(_avatar)
    onlySubjectToConstraint("mintTokens", _avatar)
    returns(bool)
    {
        emit MintTokens(msg.sender, _beneficiary, _amount, _avatar);
        return organizations[_avatar].nativeToken.mint(_beneficiary, _amount);
    }

  /**
   * @dev register or update a scheme
   * @param _scheme the address of the scheme
   * @param _paramsHash a hashed configuration of the usage of the scheme
   * @param _permissions the permissions the new scheme will have
   * @param _avatar the organization avatar.
   * @return bool which represents a success
   */
    function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar)
    external
    onlyRegisteringSchemes(_avatar)
    onlySubjectToConstraint("registerScheme", _avatar)
    returns(bool)
    {
        bytes4 schemePermission = organizations[_avatar].schemes[_scheme].permissions;
        bytes4 senderPermission = organizations[_avatar].schemes[msg.sender].permissions;
    // Check scheme has at least the permissions it is changing, and at least the current permissions:
    // Implementation is a bit messy. One must recall logic-circuits ^^

    // produces non-zero if sender does not have all of the perms that are changing between old and new
        require(bytes4(0x0000001f)&(_permissions^schemePermission)&(~senderPermission) == bytes4(0));

    // produces non-zero if sender does not have all of the perms in the old scheme
        require(bytes4(0x0000001f)&(schemePermission&(~senderPermission)) == bytes4(0));

    // Add or change the scheme:
        organizations[_avatar].schemes[_scheme] =
        Scheme({paramsHash:_paramsHash, permissions:_permissions|bytes4(0x00000001)});
        emit RegisterScheme(msg.sender, _scheme, _avatar);
        return true;
    }

    /**
     * @dev unregister a scheme
     * @param _scheme the address of the scheme
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function unregisterScheme(address _scheme, address _avatar)
    external
    onlyRegisteringSchemes(_avatar)
    onlySubjectToConstraint("unregisterScheme", _avatar)
    returns(bool)
    {
        bytes4 schemePermission = organizations[_avatar].schemes[_scheme].permissions;
    //check if the scheme is registered
        if (schemePermission&bytes4(0x00000001) == bytes4(0)) {
            return false;
        }
    // Check the unregistering scheme has enough permissions:
        require(
        bytes4(0x0000001f)&(schemePermission&(~organizations[_avatar].schemes[msg.sender].permissions)) == bytes4(0));

    // Unregister:
        emit UnregisterScheme(msg.sender, _scheme, _avatar);
        delete organizations[_avatar].schemes[_scheme];
        return true;
    }

    /**
     * @dev unregister the caller's scheme
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function unregisterSelf(address _avatar) external returns(bool) {
        if (_isSchemeRegistered(msg.sender, _avatar) == false) {
            return false;
        }
        delete organizations[_avatar].schemes[msg.sender];
        emit UnregisterScheme(msg.sender, msg.sender, _avatar);
        return true;
    }

    /**
     * @dev add or update Global Constraint
     * @param _globalConstraint the address of the global constraint to be added.
     * @param _params the constraint parameters hash.
     * @param _avatar the avatar of the organization
     * @return bool which represents a success
     */
    function addGlobalConstraint(address _globalConstraint, bytes32 _params, address _avatar)
    external onlyGlobalConstraintsScheme(_avatar) returns(bool)
    {
        Organization storage organization = organizations[_avatar];
        GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
        if ((when == GlobalConstraintInterface.CallPhase.Pre)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            if (!organization.globalConstraintsRegisterPre[_globalConstraint].isRegistered) {
                organization.globalConstraintsPre.push(GlobalConstraint(_globalConstraint, _params));
                organization.globalConstraintsRegisterPre[_globalConstraint] =
                GlobalConstraintRegister(true, organization.globalConstraintsPre.length-1);
            }else {
                organization
                .globalConstraintsPre[organization.globalConstraintsRegisterPre[_globalConstraint].index]
                .params = _params;
            }
        }

        if ((when == GlobalConstraintInterface.CallPhase.Post)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            if (!organization.globalConstraintsRegisterPost[_globalConstraint].isRegistered) {
                organization.globalConstraintsPost.push(GlobalConstraint(_globalConstraint, _params));
                organization.globalConstraintsRegisterPost[_globalConstraint] =
                GlobalConstraintRegister(true, organization.globalConstraintsPost.length-1);
            } else {
                organization
                .globalConstraintsPost[organization.globalConstraintsRegisterPost[_globalConstraint].index]
                .params = _params;
            }
        }
        emit AddGlobalConstraint(_globalConstraint, _params, when, _avatar);
        return true;
    }

    /**
     * @dev remove Global Constraint
     * @param _globalConstraint the address of the global constraint to be remove.
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function removeGlobalConstraint (address _globalConstraint, address _avatar)
    external onlyGlobalConstraintsScheme(_avatar) returns(bool)
    {
        GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
        if ((when == GlobalConstraintInterface.CallPhase.Pre)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            removeGlobalConstraintPre(_globalConstraint, _avatar);
        }
        if ((when == GlobalConstraintInterface.CallPhase.Post)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            removeGlobalConstraintPost(_globalConstraint, _avatar);
        }
        return true;
    }

  /**
    * @dev upgrade the Controller
    *      The function will trigger an event 'UpgradeController'.
    * @param  _newController the address of the new controller.
    * @param _avatar the organization avatar.
    * @return bool which represents a success
    */
    function upgradeController(address _newController, Avatar _avatar)
    external onlyUpgradingScheme(address(_avatar)) returns(bool)
    {
        require(newControllers[address(_avatar)] == address(0));   // so the upgrade could be done once for a contract.
        require(_newController != address(0));
        newControllers[address(_avatar)] = _newController;
        _avatar.transferOwnership(_newController);
        require(_avatar.owner() == _newController);
        if (organizations[address(_avatar)].nativeToken.owner() == address(this)) {
            organizations[address(_avatar)].nativeToken.transferOwnership(_newController);
            require(organizations[address(_avatar)].nativeToken.owner() == _newController);
        }
        if (organizations[address(_avatar)].nativeReputation.owner() == address(this)) {
            organizations[address(_avatar)].nativeReputation.transferOwnership(_newController);
            require(organizations[address(_avatar)].nativeReputation.owner() == _newController);
        }
        emit UpgradeController(address(this), _newController, address(_avatar));
        return true;
    }

    /**
    * @dev perform a generic call to an arbitrary contract
    * @param _contract  the contract's address to call
    * @param _data ABI-encoded contract call to call `_contract` address.
    * @param _avatar the controller's avatar address
    * @param _value value (ETH) to transfer with the transaction
    * @return bool -success
    *         bytes  - the return value of the called _contract's function.
    */
    function genericCall(address _contract, bytes calldata _data, Avatar _avatar, uint256 _value)
    external
    onlyGenericCallScheme(address(_avatar))
    onlySubjectToConstraint("genericCall", address(_avatar))
    returns (bool, bytes memory)
    {
        return _avatar.genericCall(_contract, _data, _value);
    }

  /**
   * @dev send some ether
   * @param _amountInWei the amount of ether (in Wei) to send
   * @param _to address of the beneficiary
   * @param _avatar the organization avatar.
   * @return bool which represents a success
   */
    function sendEther(uint256 _amountInWei, address payable _to, Avatar _avatar)
    external
    onlyRegisteredScheme(address(_avatar))
    onlySubjectToConstraint("sendEther", address(_avatar))
    returns(bool)
    {
        return _avatar.sendEther(_amountInWei, _to);
    }

    /**
    * @dev send some amount of arbitrary ERC20 Tokens
    * @param _externalToken the address of the Token Contract
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @param _avatar the organization avatar.
    * @return bool which represents a success
    */
    function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
    external
    onlyRegisteredScheme(address(_avatar))
    onlySubjectToConstraint("externalTokenTransfer", address(_avatar))
    returns(bool)
    {
        return _avatar.externalTokenTransfer(_externalToken, _to, _value);
    }

    /**
    * @dev transfer token "from" address "to" address
    *      One must to approve the amount of tokens which can be spend from the
    *      "from" account.This can be done using externalTokenApprove.
    * @param _externalToken the address of the Token Contract
    * @param _from address of the account to send from
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @param _avatar the organization avatar.
    * @return bool which represents a success
    */
    function externalTokenTransferFrom(
    IERC20 _externalToken,
    address _from,
    address _to,
    uint256 _value,
    Avatar _avatar)
    external
    onlyRegisteredScheme(address(_avatar))
    onlySubjectToConstraint("externalTokenTransferFrom", address(_avatar))
    returns(bool)
    {
        return _avatar.externalTokenTransferFrom(_externalToken, _from, _to, _value);
    }

    /**
    * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
    *      on behalf of msg.sender.
    * @param _externalToken the address of the Token Contract
    * @param _spender address
    * @param _value the amount of ether (in Wei) which the approval is referring to.
    * @return bool which represents a success
    */
    function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value, Avatar _avatar)
    external
    onlyRegisteredScheme(address(_avatar))
    onlySubjectToConstraint("externalTokenApproval", address(_avatar))
    returns(bool)
    {
        return _avatar.externalTokenApproval(_externalToken, _spender, _value);
    }

    /**
    * @dev metaData emits an event with a string, should contain the hash of some meta data.
    * @param _metaData a string representing a hash of the meta data
    * @param _avatar Avatar
    * @return bool which represents a success
    */
    function metaData(string calldata _metaData, Avatar _avatar)
        external
        onlyMetaDataScheme(address(_avatar))
        returns(bool)
        {
        return _avatar.metaData(_metaData);
    }

    function isSchemeRegistered( address _scheme, address _avatar) external view returns(bool) {
        return _isSchemeRegistered(_scheme, _avatar);
    }

    function getSchemeParameters(address _scheme, address _avatar) external view returns(bytes32) {
        return organizations[_avatar].schemes[_scheme].paramsHash;
    }

    function getSchemePermissions(address _scheme, address _avatar) external view returns(bytes4) {
        return organizations[_avatar].schemes[_scheme].permissions;
    }

    function getGlobalConstraintParameters(address _globalConstraint, address _avatar) external view returns(bytes32) {

        Organization storage organization = organizations[_avatar];

        GlobalConstraintRegister memory register = organization.globalConstraintsRegisterPre[_globalConstraint];

        if (register.isRegistered) {
            return organization.globalConstraintsPre[register.index].params;
        }

        register = organization.globalConstraintsRegisterPost[_globalConstraint];

        if (register.isRegistered) {
            return organization.globalConstraintsPost[register.index].params;
        }
    }

   /**
   * @dev globalConstraintsCount return the global constraint pre and post count
   * @return uint256 globalConstraintsPre count.
   * @return uint256 globalConstraintsPost count.
   */
    function globalConstraintsCount(address _avatar) external view returns(uint, uint) {
        return (
        organizations[_avatar].globalConstraintsPre.length,
        organizations[_avatar].globalConstraintsPost.length
        );
    }

    function isGlobalConstraintRegistered(address _globalConstraint, address _avatar) external view returns(bool) {
        return (organizations[_avatar].globalConstraintsRegisterPre[_globalConstraint].isRegistered ||
        organizations[_avatar].globalConstraintsRegisterPost[_globalConstraint].isRegistered);
    }

    /**
     * @dev getNativeReputation
     * @param _avatar the organization avatar.
     * @return organization native reputation
     */
    function getNativeReputation(address _avatar) external view returns(address) {
        return address(organizations[_avatar].nativeReputation);
    }

    /**
     * @dev removeGlobalConstraintPre
     * @param _globalConstraint the address of the global constraint to be remove.
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function removeGlobalConstraintPre(address _globalConstraint, address _avatar)
    private returns(bool)
    {
        GlobalConstraintRegister memory globalConstraintRegister =
        organizations[_avatar].globalConstraintsRegisterPre[_globalConstraint];
        GlobalConstraint[] storage globalConstraints = organizations[_avatar].globalConstraintsPre;

        if (globalConstraintRegister.isRegistered) {
            if (globalConstraintRegister.index < globalConstraints.length-1) {
                GlobalConstraint memory globalConstraint = globalConstraints[globalConstraints.length-1];
                globalConstraints[globalConstraintRegister.index] = globalConstraint;
                organizations[_avatar].globalConstraintsRegisterPre[globalConstraint.gcAddress].index =
                globalConstraintRegister.index;
            }
            globalConstraints.length--;
            delete organizations[_avatar].globalConstraintsRegisterPre[_globalConstraint];
            emit RemoveGlobalConstraint(_globalConstraint, globalConstraintRegister.index, true, _avatar);
            return true;
        }
        return false;
    }

    /**
     * @dev removeGlobalConstraintPost
     * @param _globalConstraint the address of the global constraint to be remove.
     * @param _avatar the organization avatar.
     * @return bool which represents a success
     */
    function removeGlobalConstraintPost(address _globalConstraint, address _avatar)
    private returns(bool)
    {
        GlobalConstraintRegister memory globalConstraintRegister =
        organizations[_avatar].globalConstraintsRegisterPost[_globalConstraint];
        GlobalConstraint[] storage globalConstraints = organizations[_avatar].globalConstraintsPost;

        if (globalConstraintRegister.isRegistered) {
            if (globalConstraintRegister.index < globalConstraints.length-1) {
                GlobalConstraint memory globalConstraint = globalConstraints[globalConstraints.length-1];
                globalConstraints[globalConstraintRegister.index] = globalConstraint;
                organizations[_avatar].globalConstraintsRegisterPost[globalConstraint.gcAddress].index =
                globalConstraintRegister.index;
            }
            globalConstraints.length--;
            delete organizations[_avatar].globalConstraintsRegisterPost[_globalConstraint];
            emit RemoveGlobalConstraint(_globalConstraint, globalConstraintRegister.index, false, _avatar);
            return true;
        }
        return false;
    }

    function _isSchemeRegistered( address _scheme, address _avatar) private view returns(bool) {
        return (organizations[_avatar].schemes[_scheme].permissions&bytes4(0x00000001) != bytes4(0));
    }
}

// File: contracts/controller/Controller.sol

pragma solidity ^0.5.4;





/**
 * @title Controller contract
 * @dev A controller controls the organizations tokens, reputation and avatar.
 * It is subject to a set of schemes and constraints that determine its behavior.
 * Each scheme has it own parameters and operation permissions.
 */
contract Controller is ControllerInterface {

    struct Scheme {
        bytes32 paramsHash;  // a hash "configuration" of the scheme
        bytes4  permissions; // A bitwise flags of permissions,
                             // All 0: Not registered,
                             // 1st bit: Flag if the scheme is registered,
                             // 2nd bit: Scheme can register other schemes
                             // 3rd bit: Scheme can add/remove global constraints
                             // 4th bit: Scheme can upgrade the controller
                             // 5th bit: Scheme can call genericCall on behalf of
                             //          the organization avatar
    }

    struct GlobalConstraint {
        address gcAddress;
        bytes32 params;
    }

    struct GlobalConstraintRegister {
        bool isRegistered; //is registered
        uint256 index;    //index at globalConstraints
    }

    mapping(address=>Scheme) public schemes;

    Avatar public avatar;
    DAOToken public nativeToken;
    Reputation public nativeReputation;
  // newController will point to the new controller after the present controller is upgraded
    address public newController;
  // globalConstraintsPre that determine pre conditions for all actions on the controller

    GlobalConstraint[] public globalConstraintsPre;
  // globalConstraintsPost that determine post conditions for all actions on the controller
    GlobalConstraint[] public globalConstraintsPost;
  // globalConstraintsRegisterPre indicate if a globalConstraints is registered as a pre global constraint
    mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPre;
  // globalConstraintsRegisterPost indicate if a globalConstraints is registered as a post global constraint
    mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPost;

    event MintReputation (address indexed _sender, address indexed _to, uint256 _amount);
    event BurnReputation (address indexed _sender, address indexed _from, uint256 _amount);
    event MintTokens (address indexed _sender, address indexed _beneficiary, uint256 _amount);
    event RegisterScheme (address indexed _sender, address indexed _scheme);
    event UnregisterScheme (address indexed _sender, address indexed _scheme);
    event UpgradeController(address indexed _oldController, address _newController);

    event AddGlobalConstraint(
        address indexed _globalConstraint,
        bytes32 _params,
        GlobalConstraintInterface.CallPhase _when);

    event RemoveGlobalConstraint(address indexed _globalConstraint, uint256 _index, bool _isPre);

    constructor( Avatar _avatar) public {
        avatar = _avatar;
        nativeToken = avatar.nativeToken();
        nativeReputation = avatar.nativeReputation();
        schemes[msg.sender] = Scheme({paramsHash: bytes32(0), permissions: bytes4(0x0000001F)});
    }

  // Do not allow mistaken calls:
   // solhint-disable-next-line payable-fallback
    function() external {
        revert();
    }

  // Modifiers:
    modifier onlyRegisteredScheme() {
        require(schemes[msg.sender].permissions&bytes4(0x00000001) == bytes4(0x00000001));
        _;
    }

    modifier onlyRegisteringSchemes() {
        require(schemes[msg.sender].permissions&bytes4(0x00000002) == bytes4(0x00000002));
        _;
    }

    modifier onlyGlobalConstraintsScheme() {
        require(schemes[msg.sender].permissions&bytes4(0x00000004) == bytes4(0x00000004));
        _;
    }

    modifier onlyUpgradingScheme() {
        require(schemes[msg.sender].permissions&bytes4(0x00000008) == bytes4(0x00000008));
        _;
    }

    modifier onlyGenericCallScheme() {
        require(schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
        _;
    }

    modifier onlyMetaDataScheme() {
        require(schemes[msg.sender].permissions&bytes4(0x00000010) == bytes4(0x00000010));
        _;
    }

    modifier onlySubjectToConstraint(bytes32 func) {
        uint256 idx;
        for (idx = 0; idx < globalConstraintsPre.length; idx++) {
            require(
            (GlobalConstraintInterface(globalConstraintsPre[idx].gcAddress))
            .pre(msg.sender, globalConstraintsPre[idx].params, func));
        }
        _;
        for (idx = 0; idx < globalConstraintsPost.length; idx++) {
            require(
            (GlobalConstraintInterface(globalConstraintsPost[idx].gcAddress))
            .post(msg.sender, globalConstraintsPost[idx].params, func));
        }
    }

    modifier isAvatarValid(address _avatar) {
        require(_avatar == address(avatar));
        _;
    }

    /**
     * @dev Mint `_amount` of reputation that are assigned to `_to` .
     * @param  _amount amount of reputation to mint
     * @param _to beneficiary address
     * @return bool which represents a success
     */
    function mintReputation(uint256 _amount, address _to, address _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("mintReputation")
    isAvatarValid(_avatar)
    returns(bool)
    {
        emit MintReputation(msg.sender, _to, _amount);
        return nativeReputation.mint(_to, _amount);
    }

    /**
     * @dev Burns `_amount` of reputation from `_from`
     * @param _amount amount of reputation to burn
     * @param _from The address that will lose the reputation
     * @return bool which represents a success
     */
    function burnReputation(uint256 _amount, address _from, address _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("burnReputation")
    isAvatarValid(_avatar)
    returns(bool)
    {
        emit BurnReputation(msg.sender, _from, _amount);
        return nativeReputation.burn(_from, _amount);
    }

    /**
     * @dev mint tokens .
     * @param  _amount amount of token to mint
     * @param _beneficiary beneficiary address
     * @return bool which represents a success
     */
    function mintTokens(uint256 _amount, address _beneficiary, address _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("mintTokens")
    isAvatarValid(_avatar)
    returns(bool)
    {
        emit MintTokens(msg.sender, _beneficiary, _amount);
        return nativeToken.mint(_beneficiary, _amount);
    }

  /**
   * @dev register a scheme
   * @param _scheme the address of the scheme
   * @param _paramsHash a hashed configuration of the usage of the scheme
   * @param _permissions the permissions the new scheme will have
   * @return bool which represents a success
   */
    function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar)
    external
    onlyRegisteringSchemes
    onlySubjectToConstraint("registerScheme")
    isAvatarValid(_avatar)
    returns(bool)
    {

        Scheme memory scheme = schemes[_scheme];

    // Check scheme has at least the permissions it is changing, and at least the current permissions:
    // Implementation is a bit messy. One must recall logic-circuits ^^

    // produces non-zero if sender does not have all of the perms that are changing between old and new
        require(bytes4(0x0000001f)&(_permissions^scheme.permissions)&(~schemes[msg.sender].permissions) == bytes4(0));

    // produces non-zero if sender does not have all of the perms in the old scheme
        require(bytes4(0x0000001f)&(scheme.permissions&(~schemes[msg.sender].permissions)) == bytes4(0));

    // Add or change the scheme:
        schemes[_scheme].paramsHash = _paramsHash;
        schemes[_scheme].permissions = _permissions|bytes4(0x00000001);
        emit RegisterScheme(msg.sender, _scheme);
        return true;
    }

    /**
     * @dev unregister a scheme
     * @param _scheme the address of the scheme
     * @return bool which represents a success
     */
    function unregisterScheme( address _scheme, address _avatar)
    external
    onlyRegisteringSchemes
    onlySubjectToConstraint("unregisterScheme")
    isAvatarValid(_avatar)
    returns(bool)
    {
    //check if the scheme is registered
        if (_isSchemeRegistered(_scheme) == false) {
            return false;
        }
    // Check the unregistering scheme has enough permissions:
        require(bytes4(0x0000001f)&(schemes[_scheme].permissions&(~schemes[msg.sender].permissions)) == bytes4(0));

    // Unregister:
        emit UnregisterScheme(msg.sender, _scheme);
        delete schemes[_scheme];
        return true;
    }

    /**
     * @dev unregister the caller's scheme
     * @return bool which represents a success
     */
    function unregisterSelf(address _avatar) external isAvatarValid(_avatar) returns(bool) {
        if (_isSchemeRegistered(msg.sender) == false) {
            return false;
        }
        delete schemes[msg.sender];
        emit UnregisterScheme(msg.sender, msg.sender);
        return true;
    }

    /**
     * @dev add or update Global Constraint
     * @param _globalConstraint the address of the global constraint to be added.
     * @param _params the constraint parameters hash.
     * @return bool which represents a success
     */
    function addGlobalConstraint(address _globalConstraint, bytes32 _params, address _avatar)
    external
    onlyGlobalConstraintsScheme
    isAvatarValid(_avatar)
    returns(bool)
    {
        GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
        if ((when == GlobalConstraintInterface.CallPhase.Pre)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            if (!globalConstraintsRegisterPre[_globalConstraint].isRegistered) {
                globalConstraintsPre.push(GlobalConstraint(_globalConstraint, _params));
                globalConstraintsRegisterPre[_globalConstraint] =
                GlobalConstraintRegister(true, globalConstraintsPre.length-1);
            }else {
                globalConstraintsPre[globalConstraintsRegisterPre[_globalConstraint].index].params = _params;
            }
        }
        if ((when == GlobalConstraintInterface.CallPhase.Post)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            if (!globalConstraintsRegisterPost[_globalConstraint].isRegistered) {
                globalConstraintsPost.push(GlobalConstraint(_globalConstraint, _params));
                globalConstraintsRegisterPost[_globalConstraint] =
                GlobalConstraintRegister(true, globalConstraintsPost.length-1);
            }else {
                globalConstraintsPost[globalConstraintsRegisterPost[_globalConstraint].index].params = _params;
            }
        }
        emit AddGlobalConstraint(_globalConstraint, _params, when);
        return true;
    }

    /**
     * @dev remove Global Constraint
     * @param _globalConstraint the address of the global constraint to be remove.
     * @return bool which represents a success
     */
     // solhint-disable-next-line code-complexity
    function removeGlobalConstraint (address _globalConstraint, address _avatar)
    external
    onlyGlobalConstraintsScheme
    isAvatarValid(_avatar)
    returns(bool)
    {
        GlobalConstraintRegister memory globalConstraintRegister;
        GlobalConstraint memory globalConstraint;
        GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when();
        bool retVal = false;

        if ((when == GlobalConstraintInterface.CallPhase.Pre)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            globalConstraintRegister = globalConstraintsRegisterPre[_globalConstraint];
            if (globalConstraintRegister.isRegistered) {
                if (globalConstraintRegister.index < globalConstraintsPre.length-1) {
                    globalConstraint = globalConstraintsPre[globalConstraintsPre.length-1];
                    globalConstraintsPre[globalConstraintRegister.index] = globalConstraint;
                    globalConstraintsRegisterPre[globalConstraint.gcAddress].index = globalConstraintRegister.index;
                }
                globalConstraintsPre.length--;
                delete globalConstraintsRegisterPre[_globalConstraint];
                retVal = true;
            }
        }
        if ((when == GlobalConstraintInterface.CallPhase.Post)||
            (when == GlobalConstraintInterface.CallPhase.PreAndPost)) {
            globalConstraintRegister = globalConstraintsRegisterPost[_globalConstraint];
            if (globalConstraintRegister.isRegistered) {
                if (globalConstraintRegister.index < globalConstraintsPost.length-1) {
                    globalConstraint = globalConstraintsPost[globalConstraintsPost.length-1];
                    globalConstraintsPost[globalConstraintRegister.index] = globalConstraint;
                    globalConstraintsRegisterPost[globalConstraint.gcAddress].index = globalConstraintRegister.index;
                }
                globalConstraintsPost.length--;
                delete globalConstraintsRegisterPost[_globalConstraint];
                retVal = true;
            }
        }
        if (retVal) {
            emit RemoveGlobalConstraint(
            _globalConstraint,
            globalConstraintRegister.index,
            when == GlobalConstraintInterface.CallPhase.Pre
            );
        }
        return retVal;
    }

  /**
    * @dev upgrade the Controller
    *      The function will trigger an event 'UpgradeController'.
    * @param  _newController the address of the new controller.
    * @return bool which represents a success
    */
    function upgradeController(address _newController, Avatar _avatar)
    external
    onlyUpgradingScheme
    isAvatarValid(address(_avatar))
    returns(bool)
    {
        require(newController == address(0));   // so the upgrade could be done once for a contract.
        require(_newController != address(0));
        newController = _newController;
        avatar.transferOwnership(_newController);
        require(avatar.owner() == _newController);
        if (nativeToken.owner() == address(this)) {
            nativeToken.transferOwnership(_newController);
            require(nativeToken.owner() == _newController);
        }
        if (nativeReputation.owner() == address(this)) {
            nativeReputation.transferOwnership(_newController);
            require(nativeReputation.owner() == _newController);
        }
        emit UpgradeController(address(this), newController);
        return true;
    }

    /**
    * @dev perform a generic call to an arbitrary contract
    * @param _contract  the contract's address to call
    * @param _data ABI-encoded contract call to call `_contract` address.
    * @param _avatar the controller's avatar address
    * @param _value value (ETH) to transfer with the transaction
    * @return bool -success
    *         bytes  - the return value of the called _contract's function.
    */
    function genericCall(address _contract, bytes calldata _data, Avatar _avatar, uint256 _value)
    external
    onlyGenericCallScheme
    onlySubjectToConstraint("genericCall")
    isAvatarValid(address(_avatar))
    returns (bool, bytes memory)
    {
        return avatar.genericCall(_contract, _data, _value);
    }

  /**
   * @dev send some ether
   * @param _amountInWei the amount of ether (in Wei) to send
   * @param _to address of the beneficiary
   * @return bool which represents a success
   */
    function sendEther(uint256 _amountInWei, address payable _to, Avatar _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("sendEther")
    isAvatarValid(address(_avatar))
    returns(bool)
    {
        return avatar.sendEther(_amountInWei, _to);
    }

    /**
    * @dev send some amount of arbitrary ERC20 Tokens
    * @param _externalToken the address of the Token Contract
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @return bool which represents a success
    */
    function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("externalTokenTransfer")
    isAvatarValid(address(_avatar))
    returns(bool)
    {
        return avatar.externalTokenTransfer(_externalToken, _to, _value);
    }

    /**
    * @dev transfer token "from" address "to" address
    *      One must to approve the amount of tokens which can be spend from the
    *      "from" account.This can be done using externalTokenApprove.
    * @param _externalToken the address of the Token Contract
    * @param _from address of the account to send from
    * @param _to address of the beneficiary
    * @param _value the amount of ether (in Wei) to send
    * @return bool which represents a success
    */
    function externalTokenTransferFrom(
    IERC20 _externalToken,
    address _from,
    address _to,
    uint256 _value,
    Avatar _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("externalTokenTransferFrom")
    isAvatarValid(address(_avatar))
    returns(bool)
    {
        return avatar.externalTokenTransferFrom(_externalToken, _from, _to, _value);
    }

    /**
    * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
    *      on behalf of msg.sender.
    * @param _externalToken the address of the Token Contract
    * @param _spender address
    * @param _value the amount of ether (in Wei) which the approval is referring to.
    * @return bool which represents a success
    */
    function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value, Avatar _avatar)
    external
    onlyRegisteredScheme
    onlySubjectToConstraint("externalTokenIncreaseApproval")
    isAvatarValid(address(_avatar))
    returns(bool)
    {
        return avatar.externalTokenApproval(_externalToken, _spender, _value);
    }

    /**
    * @dev metaData emits an event with a string, should contain the hash of some meta data.
    * @param _metaData a string representing a hash of the meta data
    * @param _avatar Avatar
    * @return bool which represents a success
    */
    function metaData(string calldata _metaData, Avatar _avatar)
        external
        onlyMetaDataScheme
        isAvatarValid(address(_avatar))
        returns(bool)
        {
        return avatar.metaData(_metaData);
    }

    /**
     * @dev getNativeReputation
     * @param _avatar the organization avatar.
     * @return organization native reputation
     */
    function getNativeReputation(address _avatar) external isAvatarValid(_avatar) view returns(address) {
        return address(nativeReputation);
    }

    function isSchemeRegistered(address _scheme, address _avatar) external isAvatarValid(_avatar) view returns(bool) {
        return _isSchemeRegistered(_scheme);
    }

    function getSchemeParameters(address _scheme, address _avatar)
    external
    isAvatarValid(_avatar)
    view
    returns(bytes32)
    {
        return schemes[_scheme].paramsHash;
    }

    function getSchemePermissions(address _scheme, address _avatar)
    external
    isAvatarValid(_avatar)
    view
    returns(bytes4)
    {
        return schemes[_scheme].permissions;
    }

    function getGlobalConstraintParameters(address _globalConstraint, address) external view returns(bytes32) {

        GlobalConstraintRegister memory register = globalConstraintsRegisterPre[_globalConstraint];

        if (register.isRegistered) {
            return globalConstraintsPre[register.index].params;
        }

        register = globalConstraintsRegisterPost[_globalConstraint];

        if (register.isRegistered) {
            return globalConstraintsPost[register.index].params;
        }
    }

   /**
    * @dev globalConstraintsCount return the global constraint pre and post count
    * @return uint256 globalConstraintsPre count.
    * @return uint256 globalConstraintsPost count.
    */
    function globalConstraintsCount(address _avatar)
        external
        isAvatarValid(_avatar)
        view
        returns(uint, uint)
        {
        return (globalConstraintsPre.length, globalConstraintsPost.length);
    }

    function isGlobalConstraintRegistered(address _globalConstraint, address _avatar)
        external
        isAvatarValid(_avatar)
        view
        returns(bool)
        {
        return (globalConstraintsRegisterPre[_globalConstraint].isRegistered ||
                globalConstraintsRegisterPost[_globalConstraint].isRegistered);
    }

    function _isSchemeRegistered(address _scheme) private view returns(bool) {
        return (schemes[_scheme].permissions&bytes4(0x00000001) != bytes4(0));
    }
}

// File: contracts/universalSchemes/DaoCreator.sol

pragma solidity ^0.5.4;





/**
 * @title ControllerCreator for creating a single controller.
 */

contract ControllerCreator {

    function create(Avatar _avatar) public returns(address) {
        Controller controller = new Controller(_avatar);
        controller.registerScheme(msg.sender, bytes32(0), bytes4(0x0000001f), address(_avatar));
        controller.unregisterScheme(address(this), address(_avatar));
        return address(controller);
    }
}

/**
 * @title Genesis Scheme that creates organizations
 */


contract DaoCreator {

    mapping(address=>address) public locks;

    event NewOrg (address _avatar);
    event InitialSchemesSet (address _avatar);

    ControllerCreator private controllerCreator;

    constructor(ControllerCreator _controllerCreator) public {
        controllerCreator = _controllerCreator;
    }

    /**
      * @dev addFounders add founders to the organization.
      *      this function can be called only after forgeOrg and before setSchemes
      * @param _avatar the organization avatar
      * @param _founders An array with the addresses of the founders of the organization
      * @param _foundersTokenAmount An array of amount of tokens that the founders
      *  receive in the new organization
      * @param _foundersReputationAmount An array of amount of reputation that the
      *   founders receive in the new organization
      * @return bool true or false
      */
    function addFounders (
        Avatar _avatar,
        address[] calldata _founders,
        uint[] calldata _foundersTokenAmount,
        uint[] calldata _foundersReputationAmount
    )
    external
    returns(bool)
    {
        require(_founders.length == _foundersTokenAmount.length);
        require(_founders.length == _foundersReputationAmount.length);
        require(_founders.length > 0);
        require(locks[address(_avatar)] == msg.sender);
        // Mint token and reputation for founders:
        for (uint256 i = 0; i < _founders.length; i++) {
            require(_founders[i] != address(0));
            if (_foundersTokenAmount[i] > 0) {
                ControllerInterface(
                _avatar.owner()).mintTokens(_foundersTokenAmount[i], _founders[i], address(_avatar));
            }
            if (_foundersReputationAmount[i] > 0) {
                ControllerInterface(
                _avatar.owner()).mintReputation(_foundersReputationAmount[i], _founders[i], address(_avatar));
            }
        }
        return true;
    }

  /**
    * @dev Create a new organization
    * @param _orgName The name of the new organization
    * @param _tokenName The name of the token associated with the organization
    * @param _tokenSymbol The symbol of the token
    * @param _founders An array with the addresses of the founders of the organization
    * @param _foundersTokenAmount An array of amount of tokens that the founders
    *  receive in the new organization
    * @param _foundersReputationAmount An array of amount of reputation that the
    *   founders receive in the new organization
    * @param  _uController universal controller instance
    *         if _uController address equal to zero the organization will use none universal controller.
    * @param  _cap token cap - 0 for no cap.
    * @return The address of the avatar of the controller
    */
    function forgeOrg (
        string calldata _orgName,
        string calldata _tokenName,
        string calldata _tokenSymbol,
        address[] calldata _founders,
        uint[] calldata _foundersTokenAmount,
        uint[] calldata _foundersReputationAmount,
        UController _uController,
        uint256 _cap
    )
    external
    returns(address)
    {
        //The call for the private function is needed to bypass a deep stack issues
        return _forgeOrg(
            _orgName,
            _tokenName,
            _tokenSymbol,
            _founders,
            _foundersTokenAmount,
            _foundersReputationAmount,
            _uController,
            _cap);
    }

     /**
      * @dev Set initial schemes for the organization.
      * @param _avatar organization avatar (returns from forgeOrg)
      * @param _schemes the schemes to register for the organization
      * @param _params the schemes's params
      * @param _permissions the schemes permissions.
      * @param _metaData dao meta data hash
      */
    function setSchemes (
        Avatar _avatar,
        address[] calldata _schemes,
        bytes32[] calldata _params,
        bytes4[] calldata _permissions,
        string calldata _metaData
    )
        external
    {
        // this action can only be executed by the account that holds the lock
        // for this controller
        require(locks[address(_avatar)] == msg.sender);
        // register initial schemes:
        ControllerInterface controller = ControllerInterface(_avatar.owner());
        for (uint256 i = 0; i < _schemes.length; i++) {
            controller.registerScheme(_schemes[i], _params[i], _permissions[i], address(_avatar));
        }
        controller.metaData(_metaData, _avatar);
        // Unregister self:
        controller.unregisterScheme(address(this), address(_avatar));
        // Remove lock:
        delete locks[address(_avatar)];
        emit InitialSchemesSet(address(_avatar));
    }

    /**
     * @dev Create a new organization
     * @param _orgName The name of the new organization
     * @param _tokenName The name of the token associated with the organization
     * @param _tokenSymbol The symbol of the token
     * @param _founders An array with the addresses of the founders of the organization
     * @param _foundersTokenAmount An array of amount of tokens that the founders
     *  receive in the new organization
     * @param _foundersReputationAmount An array of amount of reputation that the
     *   founders receive in the new organization
     * @param  _uController universal controller instance
     *         if _uController address equal to zero the organization will use none universal controller.
     * @param  _cap token cap - 0 for no cap.
     * @return The address of the avatar of the controller
     */
    function _forgeOrg (
        string memory _orgName,
        string memory _tokenName,
        string memory _tokenSymbol,
        address[] memory _founders,
        uint[] memory _foundersTokenAmount,
        uint[] memory _foundersReputationAmount,
        UController _uController,
        uint256 _cap
    ) private returns(address)
    {
        // Create Token, Reputation and Avatar:
        require(_founders.length == _foundersTokenAmount.length);
        require(_founders.length == _foundersReputationAmount.length);
        require(_founders.length > 0);
        DAOToken  nativeToken = new DAOToken(_tokenName, _tokenSymbol, _cap);
        Reputation  nativeReputation = new Reputation();
        Avatar  avatar = new Avatar(_orgName, nativeToken, nativeReputation);
        ControllerInterface  controller;

        // Mint token and reputation for founders:
        for (uint256 i = 0; i < _founders.length; i++) {
            require(_founders[i] != address(0));
            if (_foundersTokenAmount[i] > 0) {
                nativeToken.mint(_founders[i], _foundersTokenAmount[i]);
            }
            if (_foundersReputationAmount[i] > 0) {
                nativeReputation.mint(_founders[i], _foundersReputationAmount[i]);
            }
        }

        // Create Controller:
        if (UController(0) == _uController) {
            controller = ControllerInterface(controllerCreator.create(avatar));
            avatar.transferOwnership(address(controller));
            // Transfer ownership:
            nativeToken.transferOwnership(address(controller));
            nativeReputation.transferOwnership(address(controller));
        } else {
            controller = _uController;
            avatar.transferOwnership(address(controller));
            // Transfer ownership:
            nativeToken.transferOwnership(address(controller));
            nativeReputation.transferOwnership(address(controller));
            _uController.newOrganization(avatar);
        }

        locks[address(avatar)] = msg.sender;

        emit NewOrg (address(avatar));
        return (address(avatar));
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"_avatar","type":"address"},{"name":"_schemes","type":"address[]"},{"name":"_params","type":"bytes32[]"},{"name":"_permissions","type":"bytes4[]"},{"name":"_metaData","type":"string"}],"name":"setSchemes","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_avatar","type":"address"},{"name":"_founders","type":"address[]"},{"name":"_foundersTokenAmount","type":"uint256[]"},{"name":"_foundersReputationAmount","type":"uint256[]"}],"name":"addFounders","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"locks","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgName","type":"string"},{"name":"_tokenName","type":"string"},{"name":"_tokenSymbol","type":"string"},{"name":"_founders","type":"address[]"},{"name":"_foundersTokenAmount","type":"uint256[]"},{"name":"_foundersReputationAmount","type":"uint256[]"},{"name":"_uController","type":"address"},{"name":"_cap","type":"uint256"}],"name":"forgeOrg","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_controllerCreator","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_avatar","type":"address"}],"name":"NewOrg","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_avatar","type":"address"}],"name":"InitialSchemesSet","type":"event"}]

608060405234801561001057600080fd5b5060405160208061432d8339810180604052602081101561003057600080fd5b505160018054600160a060020a031916600160a060020a039092169190911790556142cd806100606000396000f3fe60806040523480156200001157600080fd5b5060043610620000555760e060020a6000350463064bf38681146200005a578063571084bd14620001e15780635de9a1371462000325578063ff720f0f146200036a575b600080fd5b620001df600480360360a08110156200007257600080fd5b600160a060020a0382351691908101906040810160208201356401000000008111156200009e57600080fd5b820183602082011115620000b157600080fd5b80359060200191846020830284011164010000000083111715620000d457600080fd5b919390929091602081019035640100000000811115620000f357600080fd5b8201836020820111156200010657600080fd5b803590602001918460208302840111640100000000831117156200012957600080fd5b9193909290916020810190356401000000008111156200014857600080fd5b8201836020820111156200015b57600080fd5b803590602001918460208302840111640100000000831117156200017e57600080fd5b9193909290916020810190356401000000008111156200019d57600080fd5b820183602082011115620001b057600080fd5b80359060200191846001830284011164010000000083111715620001d357600080fd5b50909250905062000599565b005b6200031160048036036080811015620001f957600080fd5b600160a060020a0382351691908101906040810160208201356401000000008111156200022557600080fd5b8201836020820111156200023857600080fd5b803590602001918460208302840111640100000000831117156200025b57600080fd5b9193909290916020810190356401000000008111156200027a57600080fd5b8201836020820111156200028d57600080fd5b80359060200191846020830284011164010000000083111715620002b057600080fd5b919390929091602081019035640100000000811115620002cf57600080fd5b820183602082011115620002e257600080fd5b803590602001918460208302840111640100000000831117156200030557600080fd5b5090925090506200096e565b604080519115158252519081900360200190f35b6200034e600480360360208110156200033d57600080fd5b5035600160a060020a031662000ce3565b60408051600160a060020a039092168252519081900360200190f35b6200034e60048036036101008110156200038357600080fd5b8101906020810181356401000000008111156200039f57600080fd5b820183602082011115620003b257600080fd5b80359060200191846001830284011164010000000083111715620003d557600080fd5b919390929091602081019035640100000000811115620003f457600080fd5b8201836020820111156200040757600080fd5b803590602001918460018302840111640100000000831117156200042a57600080fd5b9193909290916020810190356401000000008111156200044957600080fd5b8201836020820111156200045c57600080fd5b803590602001918460018302840111640100000000831117156200047f57600080fd5b9193909290916020810190356401000000008111156200049e57600080fd5b820183602082011115620004b157600080fd5b80359060200191846020830284011164010000000083111715620004d457600080fd5b919390929091602081019035640100000000811115620004f357600080fd5b8201836020820111156200050657600080fd5b803590602001918460208302840111640100000000831117156200052957600080fd5b9193909290916020810190356401000000008111156200054857600080fd5b8201836020820111156200055b57600080fd5b803590602001918460208302840111640100000000831117156200057e57600080fd5b9193509150600160a060020a03813516906020013562000cfe565b600160a060020a03898116600090815260208190526040902054163314620005c057600080fd5b600089600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a02815260040160206040518083038186803b158015620005ff57600080fd5b505afa15801562000614573d6000803e3d6000fd5b505050506040513d60208110156200062b57600080fd5b5051905060005b888110156200079b57600160a060020a03821663e869d45f8b8b848181106200065757fe5b90506020020135600160a060020a03168a8a8581811015156200067657fe5b9050602002013589898681811015156200068c57fe5b905060200201357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168f6040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a03168152602001848152602001837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200182600160a060020a0316600160a060020a03168152602001945050505050602060405180830381600087803b1580156200076457600080fd5b505af115801562000779573d6000803e3d6000fd5b505050506040513d60208110156200079057600080fd5b505060010162000632565b50604080517fc9b62eb1000000000000000000000000000000000000000000000000000000008152600160a060020a038c81166024830152600482019283526044820185905283169163c9b62eb191869186918f91908190606401858580828437600081840152601f19601f820116905080830192505050945050505050602060405180830381600087803b1580156200083457600080fd5b505af115801562000849573d6000803e3d6000fd5b505050506040513d60208110156200086057600080fd5b5050604080517f039de01d000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a038c8116602483015291519183169163039de01d916044808201926020929091908290030181600087803b158015620008ce57600080fd5b505af1158015620008e3573d6000803e3d6000fd5b505050506040513d6020811015620008fa57600080fd5b5050600160a060020a038a1660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff19169055815192835290517f9007c9042f12be953f7dbe3909f56c3f088e9fe294dbebbef4a67afa63462b6a9281900390910190a150505050505050505050565b60008584146200097d57600080fd5b8582146200098a57600080fd5b600086116200099857600080fd5b600160a060020a03888116600090815260208190526040902054163314620009bf57600080fd5b60005b8681101562000cd4576000888883818110620009da57fe5b90506020020135600160a060020a0316600160a060020a03161415151562000a0157600080fd5b600086868381811062000a1057fe5b90506020020135111562000b665788600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801562000a5b57600080fd5b505afa15801562000a70573d6000803e3d6000fd5b505050506040513d602081101562000a8757600080fd5b5051600160a060020a0316636407e43287878481811062000aa457fe5b905060200201358a8a85818110151562000aba57fe5b90506020020135600160a060020a03168c6040518463ffffffff1660e060020a0281526004018084815260200183600160a060020a0316600160a060020a0316815260200182600160a060020a0316600160a060020a031681526020019350505050602060405180830381600087803b15801562000b3757600080fd5b505af115801562000b4c573d6000803e3d6000fd5b505050506040513d602081101562000b6357600080fd5b50505b600084848381811062000b7557fe5b90506020020135111562000ccb5788600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801562000bc057600080fd5b505afa15801562000bd5573d6000803e3d6000fd5b505050506040513d602081101562000bec57600080fd5b5051600160a060020a031663eaf994b285858481811062000c0957fe5b905060200201358a8a85818110151562000c1f57fe5b90506020020135600160a060020a03168c6040518463ffffffff1660e060020a0281526004018084815260200183600160a060020a0316600160a060020a0316815260200182600160a060020a0316600160a060020a031681526020019350505050602060405180830381600087803b15801562000c9c57600080fd5b505af115801562000cb1573d6000803e3d6000fd5b505050506040513d602081101562000cc857600080fd5b50505b600101620009c2565b50600198975050505050505050565b600060208190529081526040902054600160a060020a031681565b600062000e848f8f8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508e8e8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508c8c80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808f0282810182019093528e82529093508e92508d9182918501908490808284376000920191909152508c92508b915062000e979050565b9f9e505050505050505050505050505050565b835185516000911462000ea957600080fd5b835186511462000eb857600080fd5b855160001062000ec757600080fd5b600088888460405162000eda9062001746565b60408101829052606080825284519082015283518190602080830191608084019188019080838360005b8381101562000f1e57818101518382015260200162000f04565b50505050905090810190601f16801562000f4c5780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b8381101562000f8157818101518382015260200162000f67565b50505050905090810190601f16801562000faf5780820380516001836020036101000a031916815260200191505b5095505050505050604051809103906000f08015801562000fd4573d6000803e3d6000fd5b509050600060405162000fe79062001754565b604051809103906000f08015801562001004573d6000803e3d6000fd5b50905060008b83836040516200101a9062001762565b600160a060020a03808416602080840191909152908316604083015260608083528551908301528451829160808301919087019080838360005b838110156200106e57818101518382015260200162001054565b50505050905090810190601f1680156200109c5780820380516001836020036101000a031916815260200191505b50945050505050604051809103906000f080158015620010c0573d6000803e3d6000fd5b5090506000805b8a51811015620012d5578a516000908c9083908110620010e357fe5b60209081029091010151600160a060020a031614156200110257600080fd5b60008a828151811015156200111357fe5b906020019060200201511115620011e75784600160a060020a03166340c10f198c838151811015156200114257fe5b906020019060200201518c848151811015156200115b57fe5b906020019060200201516040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015620011b857600080fd5b505af1158015620011cd573d6000803e3d6000fd5b505050506040513d6020811015620011e457600080fd5b50505b60008982815181101515620011f857fe5b906020019060200201511115620012cc5783600160a060020a03166340c10f198c838151811015156200122757fe5b906020019060200201518b848151811015156200124057fe5b906020019060200201516040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156200129d57600080fd5b505af1158015620012b2573d6000803e3d6000fd5b505050506040513d6020811015620012c957600080fd5b50505b600101620010c7565b50600160a060020a0387161515620014ef57600154604080517f9ed93318000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691639ed933189160248083019260209291908290030181600087803b1580156200135057600080fd5b505af115801562001365573d6000803e3d6000fd5b505050506040513d60208110156200137c57600080fd5b5051604080517ff2fde38b000000000000000000000000000000000000000000000000000000008152600160a060020a03808416600483015291519293509084169163f2fde38b9160248082019260009290919082900301818387803b158015620013e657600080fd5b505af1158015620013fb573d6000803e3d6000fd5b5050505083600160a060020a031663f2fde38b826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b1580156200145b57600080fd5b505af115801562001470573d6000803e3d6000fd5b5050505082600160a060020a031663f2fde38b826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b158015620014d057600080fd5b505af1158015620014e5573d6000803e3d6000fd5b50505050620016ce565b50604080517ff2fde38b000000000000000000000000000000000000000000000000000000008152600160a060020a0380891660048301529151889284169163f2fde38b91602480830192600092919082900301818387803b1580156200155557600080fd5b505af11580156200156a573d6000803e3d6000fd5b5050505083600160a060020a031663f2fde38b826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b158015620015ca57600080fd5b505af1158015620015df573d6000803e3d6000fd5b5050505082600160a060020a031663f2fde38b826040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b1580156200163f57600080fd5b505af115801562001654573d6000803e3d6000fd5b5050505086600160a060020a031663b9981364836040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b158015620016b457600080fd5b505af1158015620016c9573d6000803e3d6000fd5b505050505b600160a060020a03821660008181526020818152604091829020805473ffffffffffffffffffffffffffffffffffffffff191633179055815192835290517f244496352f5e67e59ce96b4a53ef9ea7cb88b7db33eb13dc5e771bd04385a60e9281900390910190a1509b9a5050505050505050505050565b610e71806200177183390190565b61096780620025e283390190565b6113598062002f498339019056fe60806040523480156200001157600080fd5b5060405162000e7138038062000e71833981018060405260608110156200003757600080fd5b8101908080516401000000008111156200005057600080fd5b820160208101848111156200006457600080fd5b81516401000000008111828201871017156200007f57600080fd5b505092919060200180516401000000008111156200009c57600080fd5b82016020810184811115620000b057600080fd5b8151640100000000811182820187101715620000cb57600080fd5b505060209091015160038054600160a060020a031916331790819055604051929450909250600160a060020a0316906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a38251620001379060049060208601906200015a565b5081516200014d9060059060208501906200015a565b5060065550620001ff9050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200019d57805160ff1916838001178555620001cd565b82800160010185558215620001cd579182015b82811115620001cd578251825591602001919060010190620001b0565b50620001db929150620001df565b5090565b620001fc91905b80821115620001db5760008155600101620001e6565b90565b610c62806200020f6000396000f3fe608060405234801561001057600080fd5b506004361061013e576000357c01000000000000000000000000000000000000000000000000000000009004806370a08231116100ca57806395d89b411161008e57806395d89b4114610373578063a457c2d71461037b578063a9059cbb146103a7578063dd62ed3e146103d3578063f2fde38b146104015761013e565b806370a08231146102ed578063715018a61461031357806379cc67901461031b5780638da5cb5b146103475780638f32d59b1461036b5761013e565b8063313ce56711610111578063313ce56714610250578063355274ea1461026e578063395093511461027657806340c10f19146102a257806342966c68146102ce5761013e565b806306fdde0314610143578063095ea7b3146101c057806318160ddd1461020057806323b872dd1461021a575b600080fd5b61014b610427565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561018557818101518382015260200161016d565b50505050905090810190601f1680156101b25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ec600480360360408110156101d657600080fd5b50600160a060020a0381351690602001356104b5565b604080519115158252519081900360200190f35b610208610521565b60408051918252519081900360200190f35b6101ec6004803603606081101561023057600080fd5b50600160a060020a03813581169160208101359091169060400135610527565b6102586105de565b6040805160ff9092168252519081900360200190f35b6102086105e3565b6101ec6004803603604081101561028c57600080fd5b50600160a060020a0381351690602001356105e9565b6101ec600480360360408110156102b857600080fd5b50600160a060020a038135169060200135610687565b6102eb600480360360208110156102e457600080fd5b50356106e0565b005b6102086004803603602081101561030357600080fd5b5035600160a060020a03166106ed565b6102eb610708565b6102eb6004803603604081101561033157600080fd5b50600160a060020a038135169060200135610772565b61034f610780565b60408051600160a060020a039092168252519081900360200190f35b6101ec61078f565b61014b6107a0565b6101ec6004803603604081101561039157600080fd5b50600160a060020a0381351690602001356107fb565b6101ec600480360360408110156103bd57600080fd5b50600160a060020a038135169060200135610846565b610208600480360360408110156103e957600080fd5b50600160a060020a0381358116916020013516610853565b6102eb6004803603602081101561041757600080fd5b5035600160a060020a031661087e565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104ad5780601f10610482576101008083540402835291602001916104ad565b820191906000526020600020905b81548152906001019060200180831161049057829003601f168201915b505050505081565b6000600160a060020a03831615156104cc57600080fd5b336000818152600160209081526040808320600160a060020a0388168085529083529281902086905580518681529051929392600080516020610c17833981519152929181900390910190a350600192915050565b60025490565b600160a060020a038316600090815260016020908152604080832033845290915281205461055b908363ffffffff61089a16565b600160a060020a038516600090815260016020908152604080832033845290915290205561058a8484846108af565b600160a060020a038416600081815260016020908152604080832033808552908352928190205481519081529051929392600080516020610c17833981519152929181900390910190a35060019392505050565b601281565b60065481565b6000600160a060020a038316151561060057600080fd5b336000908152600160209081526040808320600160a060020a0387168452909152902054610634908363ffffffff61097c16565b336000818152600160209081526040808320600160a060020a038916808552908352928190208590558051948552519193600080516020610c17833981519152929081900390910190a350600192915050565b600061069161078f565b151561069c57600080fd5b600060065411156106cd576006546106c2836106b6610521565b9063ffffffff61097c16565b11156106cd57600080fd5b6106d78383610995565b50600192915050565b6106ea3382610a3f565b50565b600160a060020a031660009081526020819052604090205490565b61071061078f565b151561071b57600080fd5b600354604051600091600160a060020a0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36003805473ffffffffffffffffffffffffffffffffffffffff19169055565b61077c8282610ae8565b5050565b600354600160a060020a031690565b600354600160a060020a0316331490565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104ad5780601f10610482576101008083540402835291602001916104ad565b6000600160a060020a038316151561081257600080fd5b336000908152600160209081526040808320600160a060020a0387168452909152902054610634908363ffffffff61089a16565b60006106d73384846108af565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b61088661078f565b151561089157600080fd5b6106ea81610b98565b6000828211156108a957600080fd5b50900390565b600160a060020a03821615156108c457600080fd5b600160a060020a0383166000908152602081905260409020546108ed908263ffffffff61089a16565b600160a060020a038085166000908152602081905260408082209390935590841681522054610922908263ffffffff61097c16565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008282018381101561098e57600080fd5b9392505050565b600160a060020a03821615156109aa57600080fd5b6002546109bd908263ffffffff61097c16565b600255600160a060020a0382166000908152602081905260409020546109e9908263ffffffff61097c16565b600160a060020a0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600160a060020a0382161515610a5457600080fd5b600254610a67908263ffffffff61089a16565b600255600160a060020a038216600090815260208190526040902054610a93908263ffffffff61089a16565b600160a060020a038316600081815260208181526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050565b600160a060020a0382166000908152600160209081526040808320338452909152902054610b1c908263ffffffff61089a16565b600160a060020a0383166000908152600160209081526040808320338452909152902055610b4a8282610a3f565b600160a060020a038216600081815260016020908152604080832033808552908352928190205481519081529051929392600080516020610c17833981519152929181900390910190a35050565b600160a060020a0381161515610bad57600080fd5b600354604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556fe8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a165627a7a7230582039abfb3b2801398c521d863578f343dd2a7268926493a03fd209ef190d612a5b002960806040526000805460a060020a60ff0219167412000000000000000000000000000000000000000017905534801561003757600080fd5b5060008054600160a060020a0319163317808255604051600160a060020a039190911691907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a36108d7806100906000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063715018a61161008e578063715018a6146101955780638da5cb5b1461019f5780638f32d59b146101c3578063981b24d0146101cb5780639dc29fac146101e8578063f2fde38b14610214576100c6565b806318160ddd146100cb578063313ce567146100e557806340c10f19146101035780634ee2cd7e1461014357806370a082311461016f575b600080fd5b6100d361023a565b60408051918252519081900360200190f35b6100ed61024b565b6040805160ff9092168252519081900360200190f35b61012f6004803603604081101561011957600080fd5b50600160a060020a03813516906020013561026c565b604080519115158252519081900360200190f35b6100d36004803603604081101561015957600080fd5b50600160a060020a038135169060200135610335565b6100d36004803603602081101561018557600080fd5b5035600160a060020a03166103c7565b61019d6103db565b005b6101a7610445565b60408051600160a060020a039092168252519081900360200190f35b61012f610454565b6100d3600480360360208110156101e157600080fd5b5035610465565b61012f600480360360408110156101fe57600080fd5b50600160a060020a0381351690602001356104b9565b61019d6004803603602081101561022a57600080fd5b5035600160a060020a0316610570565b600061024543610465565b90505b90565b60005474010000000000000000000000000000000000000000900460ff1681565b6000610276610454565b151561028157600080fd5b600061028b61023a565b905082810181111561029c57600080fd5b60006102a7856103c7565b90508381018111156102b857600080fd5b6102c5600285840161058f565b600160a060020a03851660009081526001602052604090206102e99082860161058f565b604080518581529051600160a060020a038716917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885919081900360200190a26001925050505b92915050565b600160a060020a03821660009081526001602052604081205415806103915750600160a060020a03831660009081526001602052604081208054849290811061037a57fe5b6000918252602090912001546001608060020a0316115b1561039e5750600061032f565b600160a060020a03831660009081526001602052604090206103c09083610697565b905061032f565b60006103d38243610335565b90505b919050565b6103e3610454565b15156103ee57600080fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031690565b600054600160a060020a0316331490565b600254600090158061049a5750816002600081548110151561048357fe5b6000918252602090912001546001608060020a0316115b156104a7575060006103d6565b6104b2600283610697565b90506103d6565b60006104c3610454565b15156104ce57600080fd5b60006104d861023a565b90508260006104e6866103c7565b9050818110156104f4578091505b610501600283850361058f565b600160a060020a03861660009081526001602052604090206105259083830361058f565b604080518381529051600160a060020a038816917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a250600195945050505050565b610578610454565b151561058357600080fd5b61058c816107e7565b50565b6001608060020a03811681146105a457600080fd5b815415806105d8575081544390839060001981019081106105c157fe5b6000918252602090912001546001608060020a0316105b1561064c57815460009083906105f18260018301610864565b815481106105fb57fe5b600091825260209091200180546001608060020a03848116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617905550610693565b81546000908390600019810190811061066157fe5b600091825260209091200180546001608060020a03808516700100000000000000000000000000000000029116179055505b5050565b815460009015156106aa5750600061032f565b8254839060001981019081106106bc57fe5b6000918252602090912001546001608060020a03168210610719578254839060001981019081106106e957fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a0316905061032f565b82600081548110151561072857fe5b6000918252602090912001546001608060020a031682101561074c5750600061032f565b8254600090600019015b818111156107a757845460028383016001010490859087908390811061077857fe5b6000918252602090912001546001608060020a03161161079a578092506107a1565b6001810391505b50610756565b84828154811015156107b557fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031695945050505050565b600160a060020a03811615156107fc57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8154818355818111156108885760008381526020902061088891810190830161088d565b505050565b61024891905b808211156108a75760008155600101610893565b509056fea165627a7a723058203bca0af92dfcfede9bd26af6f6a767b02b188e0c1c60a9df19141bf497b87ecc002960806040523480156200001157600080fd5b506040516200135938038062001359833981018060405260608110156200003757600080fd5b8101908080516401000000008111156200005057600080fd5b820160208101848111156200006457600080fd5b81516401000000008111828201871017156200007f57600080fd5b5050602082015160409283015160008054600160a060020a0319163317808255945193965091945092600160a060020a0316917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a38251620000ec90600190602086019062000120565b5060028054600160a060020a03938416600160a060020a0319918216179091556003805492909316911617905550620001c5565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200016357805160ff191683800117855562000193565b8280016001018555821562000193579182015b828111156200019357825182559160200191906001019062000176565b50620001a1929150620001a5565b5090565b620001c291905b80821115620001a15760008155600101620001ac565b90565b61118480620001d56000396000f3fe6080604052600436106100df576000357c0100000000000000000000000000000000000000000000000000000000900480638f32d59b1161009c578063cb16d4a211610076578063cb16d4a2146104ae578063dab0efff146104e7578063e1758bd81461052a578063f2fde38b1461053f576100df565b80638f32d59b1461040d578063ab751f7114610422578063b756d5a214610465576100df565b80631386dc2d146101175780632bf16458146101a1578063715018a6146102e9578063890ac46c1461030057806389ae1c90146103c75780638da5cb5b146103f8575b60408051348152905133917ff32a9f77675fd5917534c7746608fd3e309eac68fbdcbf5925e24ca97a704396919081900360200190a2005b34801561012357600080fd5b5061012c610572565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561016657818101518382015260200161014e565b50505050905090810190601f1680156101935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ad57600080fd5b50610266600480360360608110156101c457600080fd5b600160a060020a0382351691908101906040810160208201356401000000008111156101ef57600080fd5b82018360208201111561020157600080fd5b8035906020019184600183028401116401000000008311171561022357600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050913592506105ff915050565b604051808315151515815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102ad578181015183820152602001610295565b50505050905090810190601f1680156102da5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b3480156102f557600080fd5b506102fe610780565b005b34801561030c57600080fd5b506103b36004803603602081101561032357600080fd5b81019060208101813564010000000081111561033e57600080fd5b82018360208201111561035057600080fd5b8035906020019184600183028401116401000000008311171561037257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506107ea945050505050565b604080519115158252519081900360200190f35b3480156103d357600080fd5b506103dc6108a0565b60408051600160a060020a039092168252519081900360200190f35b34801561040457600080fd5b506103dc6108af565b34801561041957600080fd5b506103b36108be565b34801561042e57600080fd5b506103b36004803603606081101561044557600080fd5b50600160a060020a038135811691602081013590911690604001356108cf565b34801561047157600080fd5b506103b36004803603608081101561048857600080fd5b50600160a060020a0381358116916020810135821691604082013516906060013561094e565b3480156104ba57600080fd5b506103b3600480360360408110156104d157600080fd5b5080359060200135600160a060020a03166109d8565b3480156104f357600080fd5b506103b36004803603606081101561050a57600080fd5b50600160a060020a03813581169160208101359091169060400135610a6c565b34801561053657600080fd5b506103dc610af0565b34801561054b57600080fd5b506102fe6004803603602081101561056257600080fd5b5035600160a060020a0316610aff565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105f75780601f106105cc576101008083540402835291602001916105f7565b820191906000526020600020905b8154815290600101906020018083116105da57829003601f168201915b505050505081565b6000606061060b6108be565b151561061657600080fd5b84600160a060020a031683856040518082805190602001908083835b602083106106515780518252601f199092019160209182019101610632565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146106b3576040519150601f19603f3d011682016040523d82523d6000602084013e6106b8565b606091505b50809250819350505084600160a060020a03167f534b52c783549f909f9e743120524d0b7154058e4a54cdc895c2c0b587a1c7e0858585604051808060200184815260200183151515158152602001828103825285818151815260200191508051906020019080838360005b8381101561073c578181015183820152602001610724565b50505050905090810190601f1680156107695780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a2935093915050565b6107886108be565b151561079357600080fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60006107f46108be565b15156107ff57600080fd5b7ff9deba4938ba20070ec5a45ddf59bccba49cf83124215228ec1232182ef0ba2b826040518080602001828103825283818151815260200191508051906020019080838360005b8381101561085e578181015183820152602001610846565b50505050905090810190601f16801561088b5780820380516001836020036101000a031916815260200191505b509250505060405180910390a1506001919050565b600354600160a060020a031681565b600054600160a060020a031690565b600054600160a060020a0316331490565b60006108d96108be565b15156108e457600080fd5b6108fe600160a060020a038516848463ffffffff610b1e16565b60408051600160a060020a038581168252602082018590528251908716927f3a48a4d6253b30fd10e57a347c1f9bcb0604946481fae0b2fdad6e74f2a9cbb3928290030190a25060019392505050565b60006109586108be565b151561096357600080fd5b61097e600160a060020a03861685858563ffffffff610dbf16565b60408051600160a060020a03868116825285811660208301528183018590529151918716917f179c15de44aa7ab84896301974328eb40b5b40fe01cfe0fee2924ea712c3e8439181900360600190a2506001949350505050565b60006109e26108be565b15156109ed57600080fd5b604051600160a060020a0383169084156108fc029085906000818181858888f19350505050158015610a23573d6000803e3d6000fd5b50604080518481529051600160a060020a038416917f22fca66666089f39bc900dd6605b489df4aae6260cc8ea8257594cfb8c84926c919081900360200190a250600192915050565b6000610a766108be565b1515610a8157600080fd5b610a9b600160a060020a038516848463ffffffff610fb716565b82600160a060020a031684600160a060020a03167f49dc2a60d2599a7b6932d78fb694c30dfc596fe4e0282b5d0fd184b52472c04d846040518082815260200191505060405180910390a35060019392505050565b600254600160a060020a031681565b610b076108be565b1515610b1257600080fd5b610b1b816110ae565b50565b610b3083600160a060020a031661112b565b1515610b3b57600080fd5b801580610bda5750604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152306004820152600160a060020a03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015610bac57600080fd5b505afa158015610bc0573d6000803e3d6000fd5b505050506040513d6020811015610bd657600080fd5b5051155b1515610be557600080fd5b604080518082018252601881527f617070726f766528616464726573732c75696e743235362900000000000000006020918201528151600160a060020a0385811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b60208310610cc05780518252601f199092019160209182019101610ca1565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610d22576040519150601f19603f3d011682016040523d82523d6000602084013e610d27565b606091505b5091509150811515610d3857600080fd5b80511580610dad575080516020148015610dad575080601f815181101515610d5c57fe5b6020910101517f010000000000000000000000000000000000000000000000000000000000000090819004027fff000000000000000000000000000000000000000000000000000000000000001615155b1515610db857600080fd5b5050505050565b610dd184600160a060020a031661112b565b1515610ddc57600080fd5b6000606085600160a060020a03166060604051908101604052806025815260200161113460259139805160209182012060408051600160a060020a03808b166024830152891660448201526064808201899052825180830390910181526084909101825292830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092178252518251909182918083835b60208310610eb75780518252601f199092019160209182019101610e98565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610f19576040519150601f19603f3d011682016040523d82523d6000602084013e610f1e565b606091505b5091509150811515610f2f57600080fd5b80511580610fa4575080516020148015610fa4575080601f815181101515610f5357fe5b6020910101517f010000000000000000000000000000000000000000000000000000000000000090819004027fff000000000000000000000000000000000000000000000000000000000000001615155b1515610faf57600080fd5b505050505050565b610fc983600160a060020a031661112b565b1515610fd457600080fd5b604080518082018252601981527f7472616e7366657228616464726573732c75696e7432353629000000000000006020918201528151600160a060020a0385811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017815292518151600094606094891693929182919080838360208310610cc05780518252601f199092019160209182019101610ca1565b600160a060020a03811615156110c357600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000903b119056fe7472616e7366657246726f6d28616464726573732c616464726573732c75696e7432353629a165627a7a72305820ffe6ff331352287b8becfcffafa58510067ec2d2a7288b921d7c5e51542e8f190029a165627a7a7230582091ceec71275a9d9ef16398809ffaa4ccbb033523a78c3d9c06b51fab0b456769002900000000000000000000000098d9824a9898b375d2d289b27c8168f95bd29bd0

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

00000000000000000000000098d9824a9898b375d2d289b27c8168f95bd29bd0

-----Decoded View---------------
Arg [0] : _controllerCreator (address): 0x98D9824A9898b375D2d289B27C8168F95bD29Bd0

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000098d9824a9898b375d2d289b27c8168f95bd29bd0


Swarm Source

bzzr://91ceec71275a9d9ef16398809ffaa4ccbb033523a78c3d9c06b51fab0b456769
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.