ETH Price: $3,447.72 (-0.95%)
Gas: 7 Gwei

Contract

0x1d9Bdf492e59A306DDa59E5aA13E7F1C7D89197A
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x6060604052544992018-03-14 15:27:042317 days ago1521041224IN
 Create: APMRegistry
0 ETH0.011025324

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
APMRegistry

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

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

//File: contracts/lib/ens/AbstractENS.sol
pragma solidity ^0.4.15;


interface AbstractENS {
    function owner(bytes32 _node) constant returns (address);
    function resolver(bytes32 _node) constant returns (address);
    function ttl(bytes32 _node) constant returns (uint64);
    function setOwner(bytes32 _node, address _owner);
    function setSubnodeOwner(bytes32 _node, bytes32 label, address _owner);
    function setResolver(bytes32 _node, address _resolver);
    function setTTL(bytes32 _node, uint64 _ttl);

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

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

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

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

//File: contracts/lib/ens/PublicResolver.sol
pragma solidity ^0.4.0;



/**
 * A simple resolver anyone can use; only allows the owner of a node to set its
 * address.
 */
contract PublicResolver {
    bytes4 constant INTERFACE_META_ID = 0x01ffc9a7;
    bytes4 constant ADDR_INTERFACE_ID = 0x3b3b57de;
    bytes4 constant CONTENT_INTERFACE_ID = 0xd8389dc5;
    bytes4 constant NAME_INTERFACE_ID = 0x691f3431;
    bytes4 constant ABI_INTERFACE_ID = 0x2203ab56;
    bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233;
    bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c;

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

    struct PublicKey {
        bytes32 x;
        bytes32 y;
    }

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

    AbstractENS ens;
    mapping(bytes32=>Record) records;

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

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

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

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

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

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

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

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

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

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

    /**
     * Sets the ABI associated with an ENS node.
     * Nodes may have one ABI of each content type. To remove an ABI, set it to
     * the empty string.
     * @param node The node to update.
     * @param contentType The content type of the ABI
     * @param data The ABI data.
     */
    function setABI(bytes32 node, uint256 contentType, bytes data) only_owner(node) {
        // Content types must be powers of 2
        if (((contentType - 1) & contentType) != 0) throw;

        records[node].abis[contentType] = data;
        ABIChanged(node, contentType);
    }

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

    /**
     * Sets the SECP256k1 public key associated with an ENS node.
     * @param node The ENS node to query
     * @param x the X coordinate of the curve point for the public key.
     * @param y the Y coordinate of the curve point for the public key.
     */
    function setPubkey(bytes32 node, bytes32 x, bytes32 y) only_owner(node) {
        records[node].pubkey = PublicKey(x, y);
        PubkeyChanged(node, x, y);
    }

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

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

//File: contracts/ens/ENSConstants.sol
pragma solidity ^0.4.18;


contract ENSConstants {
    bytes32 constant public ENS_ROOT = bytes32(0);
    bytes32 constant public ETH_TLD_LABEL = keccak256("eth");
    bytes32 constant public ETH_TLD_NODE = keccak256(ENS_ROOT, ETH_TLD_LABEL);
    bytes32 constant public PUBLIC_RESOLVER_LABEL = keccak256("resolver");
    bytes32 constant public PUBLIC_RESOLVER_NODE = keccak256(ETH_TLD_NODE, PUBLIC_RESOLVER_LABEL);
}

//File: contracts/acl/IACL.sol
pragma solidity ^0.4.18;


interface IACL {
    function initialize(address permissionsCreator) public;
    function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
}

//File: contracts/kernel/IKernel.sol
pragma solidity ^0.4.18;



interface IKernel {
    event SetApp(bytes32 indexed namespace, bytes32 indexed name, bytes32 indexed id, address app);

    function acl() public view returns (IACL);
    function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);

    function setApp(bytes32 namespace, bytes32 name, address app) public returns (bytes32 id);
    function getApp(bytes32 id) public view returns (address);
}
//File: contracts/apps/AppStorage.sol
pragma solidity ^0.4.18;




contract AppStorage {
    IKernel public kernel;
    bytes32 public appId;
    address internal pinnedCode; // used by Proxy Pinned
    uint256 internal initializationBlock; // used by Initializable
    uint256[95] private storageOffset; // forces App storage to start at after 100 slots
    uint256 private offset;
}

//File: contracts/common/Initializable.sol
pragma solidity ^0.4.18;




contract Initializable is AppStorage {
    modifier onlyInit {
        require(initializationBlock == 0);
        _;
    }

    /**
    * @return Block number in which the contract was initialized
    */
    function getInitializationBlock() public view returns (uint256) {
        return initializationBlock;
    }

    /**
    * @dev Function to be called by top level contract after initialization has finished.
    */
    function initialized() internal onlyInit {
        initializationBlock = getBlockNumber();
    }

    /**
    * @dev Returns the current block number.
    *      Using a function rather than `block.number` allows us to easily mock the block number in
    *      tests.
    */
    function getBlockNumber() internal view returns (uint256) {
        return block.number;
    }
}

//File: contracts/evmscript/IEVMScriptExecutor.sol
pragma solidity ^0.4.18;


interface IEVMScriptExecutor {
    function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes);
}

//File: contracts/evmscript/IEVMScriptRegistry.sol
pragma solidity 0.4.18;


contract EVMScriptRegistryConstants {
    bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = keccak256("evmreg.aragonpm.eth");
    bytes32 constant public EVMSCRIPT_REGISTRY_APP = keccak256(keccak256("app"), EVMSCRIPT_REGISTRY_APP_ID);
}


interface IEVMScriptRegistry {
    function addScriptExecutor(address executor) external returns (uint id);
    function disableScriptExecutor(uint256 executorId) external;

    function getScriptExecutor(bytes script) public view returns (address);
}
//File: contracts/evmscript/ScriptHelpers.sol
pragma solidity 0.4.18;


library ScriptHelpers {
    // To test with JS and compare with actual encoder. Maintaining for reference.
    // t = function() { return IEVMScriptExecutor.at('0x4bcdd59d6c77774ee7317fc1095f69ec84421e49').contract.execScript.getData(...[].slice.call(arguments)).slice(10).match(/.{1,64}/g) }
    // run = function() { return ScriptHelpers.new().then(sh => { sh.abiEncode.call(...[].slice.call(arguments)).then(a => console.log(a.slice(2).match(/.{1,64}/g)) ) }) }
    // This is truly not beautiful but lets no daydream to the day solidity gets reflection features

    function abiEncode(bytes _a, bytes _b, address[] _c) public pure returns (bytes d) {
        return encode(_a, _b, _c);
    }

    function encode(bytes memory _a, bytes memory _b, address[] memory _c) internal pure returns (bytes memory d) {
        // A is positioned after the 3 position words
        uint256 aPosition = 0x60;
        uint256 bPosition = aPosition + 32 * abiLength(_a);
        uint256 cPosition = bPosition + 32 * abiLength(_b);
        uint256 length = cPosition + 32 * abiLength(_c);

        d = new bytes(length);
        assembly {
            // Store positions
            mstore(add(d, 0x20), aPosition)
            mstore(add(d, 0x40), bPosition)
            mstore(add(d, 0x60), cPosition)
        }

        // Copy memory to correct position
        copy(d, getPtr(_a), aPosition, _a.length);
        copy(d, getPtr(_b), bPosition, _b.length);
        copy(d, getPtr(_c), cPosition, _c.length * 32); // 1 word per address
    }

    function abiLength(bytes memory _a) internal pure returns (uint256) {
        // 1 for length +
        // memory words + 1 if not divisible for 32 to offset word
        return 1 + (_a.length / 32) + (_a.length % 32 > 0 ? 1 : 0);
    }

    function abiLength(address[] _a) internal pure returns (uint256) {
        // 1 for length + 1 per item
        return 1 + _a.length;
    }

    function copy(bytes _d, uint256 _src, uint256 _pos, uint256 _length) internal pure {
        uint dest;
        assembly {
            dest := add(add(_d, 0x20), _pos)
        }
        memcpy(dest, _src, _length + 32);
    }

    function getPtr(bytes memory _x) internal pure returns (uint256 ptr) {
        assembly {
            ptr := _x
        }
    }

    function getPtr(address[] memory _x) internal pure returns (uint256 ptr) {
        assembly {
            ptr := _x
        }
    }

    function getSpecId(bytes _script) internal pure returns (uint32) {
        return uint32At(_script, 0);
    }

    function uint256At(bytes _data, uint256 _location) internal pure returns (uint256 result) {
        assembly {
            result := mload(add(_data, add(0x20, _location)))
        }
    }

    function addressAt(bytes _data, uint256 _location) internal pure returns (address result) {
        uint256 word = uint256At(_data, _location);

        assembly {
            result := div(and(word, 0xffffffffffffffffffffffffffffffffffffffff000000000000000000000000),
            0x1000000000000000000000000)
        }
    }

    function uint32At(bytes _data, uint256 _location) internal pure returns (uint32 result) {
        uint256 word = uint256At(_data, _location);

        assembly {
            result := div(and(word, 0xffffffff00000000000000000000000000000000000000000000000000000000),
            0x100000000000000000000000000000000000000000000000000000000)
        }
    }

    function locationOf(bytes _data, uint256 _location) internal pure returns (uint256 result) {
        assembly {
            result := add(_data, add(0x20, _location))
        }
    }

    function toBytes(bytes4 _sig) internal pure returns (bytes) {
        bytes memory payload = new bytes(4);
        payload[0] = bytes1(_sig);
        payload[1] = bytes1(_sig << 8);
        payload[2] = bytes1(_sig << 16);
        payload[3] = bytes1(_sig << 24);
        return payload;
    }

    function memcpy(uint _dest, uint _src, uint _len) public pure {
        uint256 src = _src;
        uint256 dest = _dest;
        uint256 len = _len;

        // Copy word-length chunks while possible
        for (; len >= 32; len -= 32) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += 32;
            src += 32;
        }

        // Copy remaining bytes
        uint mask = 256 ** (32 - len) - 1;
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }
}
//File: contracts/evmscript/EVMScriptRunner.sol
pragma solidity ^0.4.18;








contract EVMScriptRunner is AppStorage, EVMScriptRegistryConstants {
    using ScriptHelpers for bytes;

    function runScript(bytes _script, bytes _input, address[] _blacklist) protectState internal returns (bytes output) {
        // TODO: Too much data flying around, maybe extracting spec id here is cheaper
        address executorAddr = getExecutor(_script);
        require(executorAddr != address(0));

        bytes memory calldataArgs = _script.encode(_input, _blacklist);
        bytes4 sig = IEVMScriptExecutor(0).execScript.selector;

        require(executorAddr.delegatecall(sig, calldataArgs));

        return returnedDataDecoded();
    }

    function getExecutor(bytes _script) public view returns (IEVMScriptExecutor) {
        return IEVMScriptExecutor(getExecutorRegistry().getScriptExecutor(_script));
    }

    // TODO: Internal
    function getExecutorRegistry() internal view returns (IEVMScriptRegistry) {
        address registryAddr = kernel.getApp(EVMSCRIPT_REGISTRY_APP);
        return IEVMScriptRegistry(registryAddr);
    }

    /**
    * @dev copies and returns last's call data. Needs to ABI decode first
    */
    function returnedDataDecoded() internal view returns (bytes ret) {
        assembly {
            let size := returndatasize
            switch size
            case 0 {}
            default {
                ret := mload(0x40) // free mem ptr get
                mstore(0x40, add(ret, add(size, 0x20))) // free mem ptr set
                returndatacopy(ret, 0x20, sub(size, 0x20)) // copy return data
            }
        }
        return ret;
    }

    modifier protectState {
        address preKernel = kernel;
        bytes32 preAppId = appId;
        _; // exec
        require(kernel == preKernel);
        require(appId == preAppId);
    }
}
//File: contracts/acl/ACLSyntaxSugar.sol
pragma solidity 0.4.18;


contract ACLSyntaxSugar {
    function arr() internal pure returns (uint256[] r) {}

    function arr(bytes32 _a) internal pure returns (uint256[] r) {
        return arr(uint256(_a));
    }

    function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b));
    }

    function arr(address _a) internal pure returns (uint256[] r) {
        return arr(uint256(_a));
    }

    function arr(address _a, address _b) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b));
    }

    function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
        return arr(uint256(_a), _b, _c);
    }

    function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b));
    }

    function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b), _c, _d, _e);
    }

    function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b), uint256(_c));
    }

    function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) {
        return arr(uint256(_a), uint256(_b), uint256(_c));
    }

    function arr(uint256 _a) internal pure returns (uint256[] r) {
        r = new uint256[](1);
        r[0] = _a;
    }

    function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) {
        r = new uint256[](2);
        r[0] = _a;
        r[1] = _b;
    }

    function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
        r = new uint256[](3);
        r[0] = _a;
        r[1] = _b;
        r[2] = _c;
    }

    function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
        r = new uint256[](4);
        r[0] = _a;
        r[1] = _b;
        r[2] = _c;
        r[3] = _d;
    }

    function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
        r = new uint256[](5);
        r[0] = _a;
        r[1] = _b;
        r[2] = _c;
        r[3] = _d;
        r[4] = _e;
    }
}


contract ACLHelpers {
    function decodeParamOp(uint256 _x) internal pure returns (uint8 b) {
        return uint8(_x >> (8 * 30));
    }

    function decodeParamId(uint256 _x) internal pure returns (uint8 b) {
        return uint8(_x >> (8 * 31));
    }

    function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) {
        a = uint32(_x);
        b = uint32(_x >> (8 * 4));
        c = uint32(_x >> (8 * 8));
    }
}

//File: contracts/apps/AragonApp.sol
pragma solidity ^0.4.18;







contract AragonApp is AppStorage, Initializable, ACLSyntaxSugar, EVMScriptRunner {
    modifier auth(bytes32 _role) {
        require(canPerform(msg.sender, _role, new uint256[](0)));
        _;
    }

    modifier authP(bytes32 _role, uint256[] params) {
        require(canPerform(msg.sender, _role, params));
        _;
    }

    function canPerform(address _sender, bytes32 _role, uint256[] params) public view returns (bool) {
        bytes memory how; // no need to init memory as it is never used
        if (params.length > 0) {
            uint256 byteLength = params.length * 32;
            assembly {
                how := params // forced casting
                mstore(how, byteLength)
            }
        }
        return address(kernel) == 0 || kernel.hasPermission(_sender, address(this), _role, how);
    }
}

//File: contracts/ens/ENSSubdomainRegistrar.sol
pragma solidity 0.4.18;








contract ENSSubdomainRegistrar is AragonApp, ENSConstants {
    bytes32 constant public CREATE_NAME_ROLE = bytes32(1);
    bytes32 constant public DELETE_NAME_ROLE = bytes32(2);
    bytes32 constant public POINT_ROOTNODE_ROLE = bytes32(3);

    AbstractENS public ens;
    bytes32 public rootNode;

    event NewName(bytes32 indexed node, bytes32 indexed label);
    event DeleteName(bytes32 indexed node, bytes32 indexed label);

    function initialize(AbstractENS _ens, bytes32 _rootNode) onlyInit public {
        initialized();

        // We need ownership to create subnodes
        require(_ens.owner(_rootNode) == address(this));

        ens = _ens;
        rootNode = _rootNode;
    }

    function createName(bytes32 _label, address _owner) auth(CREATE_NAME_ROLE) external returns (bytes32 node) {
        return _createName(_label, _owner);
    }

    function createNameAndPoint(bytes32 _label, address _target) auth(CREATE_NAME_ROLE) external returns (bytes32 node) {
        node = _createName(_label, this);
        _pointToResolverAndResolve(node, _target);
    }

    function deleteName(bytes32 _label) auth(DELETE_NAME_ROLE) external {
        bytes32 node = keccak256(rootNode, _label);

        address currentOwner = ens.owner(node);

        require(currentOwner != address(0)); // fail if deleting unset name

        if (currentOwner != address(this)) { // needs to reclaim ownership so it can set resolver
            ens.setSubnodeOwner(rootNode, _label, this);
        }

        ens.setResolver(node, address(0)); // remove resolver so it ends resolving
        ens.setOwner(node, address(0));

        DeleteName(node, _label);
    }

    function pointRootNode(address _target) auth(POINT_ROOTNODE_ROLE) external {
        _pointToResolverAndResolve(rootNode, _target);
    }

    function _createName(bytes32 _label, address _owner) internal returns (bytes32 node) {
        node = keccak256(rootNode, _label);
        require(ens.owner(node) == address(0)); // avoid name reset

        ens.setSubnodeOwner(rootNode, _label, _owner);

        NewName(node, _label);
    }

    function _pointToResolverAndResolve(bytes32 _node, address _target) internal {
        address publicResolver = getAddr(PUBLIC_RESOLVER_NODE);
        ens.setResolver(_node, publicResolver);

        PublicResolver(publicResolver).setAddr(_node, _target);
    }

    function getAddr(bytes32 node) internal view returns (address) {
        address resolver = ens.resolver(node);
        return PublicResolver(resolver).addr(node);
    }
}

//File: contracts/apps/IAppProxy.sol
pragma solidity 0.4.18;

interface IAppProxy {
    function isUpgradeable() public pure returns (bool);
    function getCode() public view returns (address);
}

//File: contracts/common/DelegateProxy.sol
pragma solidity 0.4.18;


contract DelegateProxy {
    /**
    * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
    * @param _dst Destination address to perform the delegatecall
    * @param _calldata Calldata for the delegatecall
    */
    function delegatedFwd(address _dst, bytes _calldata) internal {
        require(isContract(_dst));
        assembly {
            let result := delegatecall(sub(gas, 10000), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
            let size := returndatasize

            let ptr := mload(0x40)
            returndatacopy(ptr, 0, size)

            // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
            // if the call returned error data, forward it
            switch result case 0 { revert(ptr, size) }
            default { return(ptr, size) }
        }
    }

    function isContract(address _target) internal view returns (bool) {
        uint256 size;
        assembly { size := extcodesize(_target) }
        return size > 0;
    }
}

//File: contracts/kernel/KernelStorage.sol
pragma solidity 0.4.18;


contract KernelConstants {
    bytes32 constant public CORE_NAMESPACE = keccak256("core");
    bytes32 constant public APP_BASES_NAMESPACE = keccak256("base");
    bytes32 constant public APP_ADDR_NAMESPACE = keccak256("app");

    bytes32 constant public KERNEL_APP_ID = keccak256("kernel.aragonpm.eth");
    bytes32 constant public KERNEL_APP = keccak256(CORE_NAMESPACE, KERNEL_APP_ID);

    bytes32 constant public ACL_APP_ID = keccak256("acl.aragonpm.eth");
    bytes32 constant public ACL_APP = keccak256(APP_ADDR_NAMESPACE, ACL_APP_ID);
}


contract KernelStorage is KernelConstants {
    mapping (bytes32 => address) public apps;
}

//File: contracts/apps/AppProxyBase.sol
pragma solidity 0.4.18;







contract AppProxyBase is IAppProxy, AppStorage, DelegateProxy, KernelConstants {
    /**
    * @dev Initialize AppProxy
    * @param _kernel Reference to organization kernel for the app
    * @param _appId Identifier for app
    * @param _initializePayload Payload for call to be made after setup to initialize
    */
    function AppProxyBase(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
        kernel = _kernel;
        appId = _appId;

        // Implicit check that kernel is actually a Kernel
        // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
        // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
        // it.
        address appCode = getAppBase(appId);

        // If initialize payload is provided, it will be executed
        if (_initializePayload.length > 0) {
            require(isContract(appCode));
            // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
            // returns ending execution context and halts contract deployment
            require(appCode.delegatecall(_initializePayload));
        }
    }

    function getAppBase(bytes32 _appId) internal view returns (address) {
        return kernel.getApp(keccak256(APP_BASES_NAMESPACE, _appId));
    }

    function () payable public {
        address target = getCode();
        require(target != 0); // if app code hasn't been set yet, don't call
        delegatedFwd(target, msg.data);
    }
}
//File: contracts/apps/AppProxyUpgradeable.sol
pragma solidity 0.4.18;




contract AppProxyUpgradeable is AppProxyBase {
    address public pinnedCode;

    /**
    * @dev Initialize AppProxyUpgradeable (makes it an upgradeable Aragon app)
    * @param _kernel Reference to organization kernel for the app
    * @param _appId Identifier for app
    * @param _initializePayload Payload for call to be made after setup to initialize
    */
    function AppProxyUpgradeable(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
             AppProxyBase(_kernel, _appId, _initializePayload) public
    {

    }

    function getCode() public view returns (address) {
        return getAppBase(appId);
    }

    function isUpgradeable() public pure returns (bool) {
        return true;
    }
}

//File: contracts/apps/AppProxyPinned.sol
pragma solidity 0.4.18;




contract AppProxyPinned is AppProxyBase {
    /**
    * @dev Initialize AppProxyPinned (makes it an un-upgradeable Aragon app)
    * @param _kernel Reference to organization kernel for the app
    * @param _appId Identifier for app
    * @param _initializePayload Payload for call to be made after setup to initialize
    */
    function AppProxyPinned(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
             AppProxyBase(_kernel, _appId, _initializePayload) public
    {
        pinnedCode = getAppBase(appId);
        require(pinnedCode != address(0));
    }

    function getCode() public view returns (address) {
        return pinnedCode;
    }

    function isUpgradeable() public pure returns (bool) {
        return false;
    }

    function () payable public {
        delegatedFwd(getCode(), msg.data);
    }
}
//File: contracts/factory/AppProxyFactory.sol
pragma solidity 0.4.18;





contract AppProxyFactory {
    event NewAppProxy(address proxy);

    function newAppProxy(IKernel _kernel, bytes32 _appId) public returns (AppProxyUpgradeable) {
        return newAppProxy(_kernel, _appId, new bytes(0));
    }

    function newAppProxy(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyUpgradeable) {
        AppProxyUpgradeable proxy = new AppProxyUpgradeable(_kernel, _appId, _initializePayload);
        NewAppProxy(address(proxy));
        return proxy;
    }

    function newAppProxyPinned(IKernel _kernel, bytes32 _appId) public returns (AppProxyPinned) {
        return newAppProxyPinned(_kernel, _appId, new bytes(0));
    }

    function newAppProxyPinned(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyPinned) {
        AppProxyPinned proxy = new AppProxyPinned(_kernel, _appId, _initializePayload);
        NewAppProxy(address(proxy));
        return proxy;
    }
}

//File: contracts/acl/ACL.sol
pragma solidity 0.4.18;






interface ACLOracle {
    function canPerform(address who, address where, bytes32 what) public view returns (bool);
}


contract ACL is IACL, AragonApp, ACLHelpers {
    bytes32 constant public CREATE_PERMISSIONS_ROLE = keccak256("CREATE_PERMISSIONS_ROLE");

    // whether a certain entity has a permission
    mapping (bytes32 => bytes32) permissions; // 0 for no permission, or parameters id
    mapping (bytes32 => Param[]) public permissionParams;

    // who is the manager of a permission
    mapping (bytes32 => address) permissionManager;

    enum Op { NONE, EQ, NEQ, GT, LT, GTE, LTE, NOT, AND, OR, XOR, IF_ELSE, RET } // op types

    struct Param {
        uint8 id;
        uint8 op;
        uint240 value; // even though value is an uint240 it can store addresses
        // in the case of 32 byte hashes losing 2 bytes precision isn't a huge deal
        // op and id take less than 1 byte each so it can be kept in 1 sstore
    }

    uint8 constant BLOCK_NUMBER_PARAM_ID = 200;
    uint8 constant TIMESTAMP_PARAM_ID    = 201;
    uint8 constant SENDER_PARAM_ID       = 202;
    uint8 constant ORACLE_PARAM_ID       = 203;
    uint8 constant LOGIC_OP_PARAM_ID     = 204;
    uint8 constant PARAM_VALUE_PARAM_ID  = 205;
    // TODO: Add execution times param type?

    bytes32 constant public EMPTY_PARAM_HASH = keccak256(uint256(0));
    address constant ANY_ENTITY = address(-1);

    modifier onlyPermissionManager(address _app, bytes32 _role) {
        require(msg.sender == getPermissionManager(_app, _role));
        _;
    }

    event SetPermission(address indexed entity, address indexed app, bytes32 indexed role, bool allowed);
    event ChangePermissionManager(address indexed app, bytes32 indexed role, address indexed manager);

    /**
    * @dev Initialize can only be called once. It saves the block number in which it was initialized.
    * @notice Initializes an ACL instance and sets `_permissionsCreator` as the entity that can create other permissions
    * @param _permissionsCreator Entity that will be given permission over createPermission
    */
    function initialize(address _permissionsCreator) onlyInit public {
        initialized();
        require(msg.sender == address(kernel));

        _createPermission(_permissionsCreator, this, CREATE_PERMISSIONS_ROLE, _permissionsCreator);
    }

    /**
    * @dev Creates a permission that wasn't previously set. Access is limited by the ACL.
    *      If a created permission is removed it is possible to reset it with createPermission.
    * @notice Create a new permission granting `_entity` the ability to perform actions of role `_role` on `_app` (setting `_manager` as the permission manager)
    * @param _entity Address of the whitelisted entity that will be able to perform the role
    * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL)
    * @param _role Identifier for the group of actions in app given access to perform
    * @param _manager Address of the entity that will be able to grant and revoke the permission further.
    */
    function createPermission(address _entity, address _app, bytes32 _role, address _manager) external {
        require(hasPermission(msg.sender, address(this), CREATE_PERMISSIONS_ROLE));

        _createPermission(_entity, _app, _role, _manager);
    }

    /**
    * @dev Grants permission if allowed. This requires `msg.sender` to be the permission manager
    * @notice Grants `_entity` the ability to perform actions of role `_role` on `_app`
    * @param _entity Address of the whitelisted entity that will be able to perform the role
    * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL)
    * @param _role Identifier for the group of actions in app given access to perform
    */
    function grantPermission(address _entity, address _app, bytes32 _role)
        external
    {
        grantPermissionP(_entity, _app, _role, new uint256[](0));
    }

    /**
    * @dev Grants a permission with parameters if allowed. This requires `msg.sender` to be the permission manager
    * @notice Grants `_entity` the ability to perform actions of role `_role` on `_app`
    * @param _entity Address of the whitelisted entity that will be able to perform the role
    * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL)
    * @param _role Identifier for the group of actions in app given access to perform
    * @param _params Permission parameters
    */
    function grantPermissionP(address _entity, address _app, bytes32 _role, uint256[] _params)
        onlyPermissionManager(_app, _role)
        public
    {
        require(!hasPermission(_entity, _app, _role));

        bytes32 paramsHash = _params.length > 0 ? _saveParams(_params) : EMPTY_PARAM_HASH;
        _setPermission(_entity, _app, _role, paramsHash);
    }

    /**
    * @dev Revokes permission if allowed. This requires `msg.sender` to be the the permission manager
    * @notice Revokes `_entity` the ability to perform actions of role `_role` on `_app`
    * @param _entity Address of the whitelisted entity to revoke access from
    * @param _app Address of the app in which the role will be revoked
    * @param _role Identifier for the group of actions in app being revoked
    */
    function revokePermission(address _entity, address _app, bytes32 _role)
        onlyPermissionManager(_app, _role)
        external
    {
        require(hasPermission(_entity, _app, _role));

        _setPermission(_entity, _app, _role, bytes32(0));
    }

    /**
    * @notice Sets `_newManager` as the manager of the permission `_role` in `_app`
    * @param _newManager Address for the new manager
    * @param _app Address of the app in which the permission management is being transferred
    * @param _role Identifier for the group of actions being transferred
    */
    function setPermissionManager(address _newManager, address _app, bytes32 _role)
        onlyPermissionManager(_app, _role)
        external
    {
        _setPermissionManager(_newManager, _app, _role);
    }

    /**
    * @dev Get manager for permission
    * @param _app Address of the app
    * @param _role Identifier for a group of actions in app
    * @return address of the manager for the permission
    */
    function getPermissionManager(address _app, bytes32 _role) public view returns (address) {
        return permissionManager[roleHash(_app, _role)];
    }

    /**
    * @dev Function called by apps to check ACL on kernel or to check permission statu
    * @param _who Sender of the original call
    * @param _where Address of the app
    * @param _where Identifier for a group of actions in app
    * @param _how Permission parameters
    * @return boolean indicating whether the ACL allows the role or not
    */
    function hasPermission(address _who, address _where, bytes32 _what, bytes memory _how) public view returns (bool) {
        uint256[] memory how;
        uint256 intsLength = _how.length / 32;
        assembly {
            how := _how // forced casting
            mstore(how, intsLength)
        }
        // _how is invalid from this point fwd
        return hasPermission(_who, _where, _what, how);
    }

    function hasPermission(address _who, address _where, bytes32 _what, uint256[] memory _how) public view returns (bool) {
        bytes32 whoParams = permissions[permissionHash(_who, _where, _what)];
        if (whoParams != bytes32(0) && evalParams(whoParams, _who, _where, _what, _how)) {
            return true;
        }

        bytes32 anyParams = permissions[permissionHash(ANY_ENTITY, _where, _what)];
        if (anyParams != bytes32(0) && evalParams(anyParams, ANY_ENTITY, _where, _what, _how)) {
            return true;
        }

        return false;
    }

    function hasPermission(address _who, address _where, bytes32 _what) public view returns (bool) {
        uint256[] memory empty = new uint256[](0);
        return hasPermission(_who, _where, _what, empty);
    }

    /**
    * @dev Internal createPermission for access inside the kernel (on instantiation)
    */
    function _createPermission(address _entity, address _app, bytes32 _role, address _manager) internal {
        // only allow permission creation (or re-creation) when there is no manager
        require(getPermissionManager(_app, _role) == address(0));

        _setPermission(_entity, _app, _role, EMPTY_PARAM_HASH);
        _setPermissionManager(_manager, _app, _role);
    }

    /**
    * @dev Internal function called to actually save the permission
    */
    function _setPermission(address _entity, address _app, bytes32 _role, bytes32 _paramsHash) internal {
        permissions[permissionHash(_entity, _app, _role)] = _paramsHash;

        SetPermission(_entity, _app, _role, _paramsHash != bytes32(0));
    }

    function _saveParams(uint256[] _encodedParams) internal returns (bytes32) {
        bytes32 paramHash = keccak256(_encodedParams);
        Param[] storage params = permissionParams[paramHash];

        if (params.length == 0) { // params not saved before
            for (uint256 i = 0; i < _encodedParams.length; i++) {
                uint256 encodedParam = _encodedParams[i];
                Param memory param = Param(decodeParamId(encodedParam), decodeParamOp(encodedParam), uint240(encodedParam));
                params.push(param);
            }
        }

        return paramHash;
    }

    function evalParams(
        bytes32 _paramsHash,
        address _who,
        address _where,
        bytes32 _what,
        uint256[] _how
    ) internal view returns (bool)
    {
        if (_paramsHash == EMPTY_PARAM_HASH) {
            return true;
        }

        return evalParam(_paramsHash, 0, _who, _where, _what, _how);
    }

    function evalParam(
        bytes32 _paramsHash,
        uint32 _paramId,
        address _who,
        address _where,
        bytes32 _what,
        uint256[] _how
    ) internal view returns (bool)
    {
        if (_paramId >= permissionParams[_paramsHash].length) {
            return false; // out of bounds
        }

        Param memory param = permissionParams[_paramsHash][_paramId];

        if (param.id == LOGIC_OP_PARAM_ID) {
            return evalLogic(param, _paramsHash, _who, _where, _what, _how);
        }

        uint256 value;
        uint256 comparedTo = uint256(param.value);

        // get value
        if (param.id == ORACLE_PARAM_ID) {
            value = ACLOracle(param.value).canPerform(_who, _where, _what) ? 1 : 0;
            comparedTo = 1;
        } else if (param.id == BLOCK_NUMBER_PARAM_ID) {
            value = blockN();
        } else if (param.id == TIMESTAMP_PARAM_ID) {
            value = time();
        } else if (param.id == SENDER_PARAM_ID) {
            value = uint256(msg.sender);
        } else if (param.id == PARAM_VALUE_PARAM_ID) {
            value = uint256(param.value);
        } else {
            if (param.id >= _how.length) {
                return false;
            }
            value = uint256(uint240(_how[param.id])); // force lost precision
        }

        if (Op(param.op) == Op.RET) {
            return uint256(value) > 0;
        }

        return compare(value, Op(param.op), comparedTo);
    }

    function evalLogic(Param _param, bytes32 _paramsHash, address _who, address _where, bytes32 _what, uint256[] _how) internal view returns (bool) {
        if (Op(_param.op) == Op.IF_ELSE) {
            var (condition, success, failure) = decodeParamsList(uint256(_param.value));
            bool result = evalParam(_paramsHash, condition, _who, _where, _what, _how);

            return evalParam(_paramsHash, result ? success : failure, _who, _where, _what, _how);
        }

        var (v1, v2,) = decodeParamsList(uint256(_param.value));
        bool r1 = evalParam(_paramsHash, v1, _who, _where, _what, _how);

        if (Op(_param.op) == Op.NOT) {
            return !r1;
        }

        if (r1 && Op(_param.op) == Op.OR) {
            return true;
        }

        if (!r1 && Op(_param.op) == Op.AND) {
            return false;
        }

        bool r2 = evalParam(_paramsHash, v2, _who, _where, _what, _how);

        if (Op(_param.op) == Op.XOR) {
            return (r1 && !r2) || (!r1 && r2);
        }

        return r2; // both or and and depend on result of r2 after checks
    }

    function compare(uint256 _a, Op _op, uint256 _b) internal pure returns (bool) {
        if (_op == Op.EQ)  return _a == _b;                              // solium-disable-line lbrace
        if (_op == Op.NEQ) return _a != _b;                              // solium-disable-line lbrace
        if (_op == Op.GT)  return _a > _b;                               // solium-disable-line lbrace
        if (_op == Op.LT)  return _a < _b;                               // solium-disable-line lbrace
        if (_op == Op.GTE) return _a >= _b;                              // solium-disable-line lbrace
        if (_op == Op.LTE) return _a <= _b;                              // solium-disable-line lbrace
        return false;
    }

    /**
    * @dev Internal function that sets management
    */
    function _setPermissionManager(address _newManager, address _app, bytes32 _role) internal {
        permissionManager[roleHash(_app, _role)] = _newManager;
        ChangePermissionManager(_app, _role, _newManager);
    }

    function roleHash(address _where, bytes32 _what) pure internal returns (bytes32) {
        return keccak256(uint256(1), _where, _what);
    }

    function permissionHash(address _who, address _where, bytes32 _what) pure internal returns (bytes32) {
        return keccak256(uint256(2), _who, _where, _what);
    }

    function time() internal view returns (uint64) { return uint64(block.timestamp); } // solium-disable-line security/no-block-members

    function blockN() internal view returns (uint256) { return block.number; }
}

//File: contracts/apm/Repo.sol
pragma solidity ^0.4.15;




contract Repo is AragonApp {
    struct Version {
        uint16[3] semanticVersion;
        address contractAddress;
        bytes contentURI;
    }

    Version[] versions;
    mapping (bytes32 => uint256) versionIdForSemantic;
    mapping (address => uint256) latestVersionIdForContract;

    bytes32 constant public CREATE_VERSION_ROLE = bytes32(1);

    event NewVersion(uint256 versionId, uint16[3] semanticVersion);

    /**
    * @notice Create new version for repo
    * @param _newSemanticVersion Semantic version for new repo version
    * @param _contractAddress address for smart contract logic for version (if set to 0, it uses last versions' contractAddress)
    * @param _contentURI External URI for fetching new version's content
    */
    function newVersion(
        uint16[3] _newSemanticVersion,
        address _contractAddress,
        bytes _contentURI
    ) auth(CREATE_VERSION_ROLE) public
    {
        address contractAddress = _contractAddress;
        if (versions.length > 0) {
            Version storage lastVersion = versions[versions.length - 1];
            require(isValidBump(lastVersion.semanticVersion, _newSemanticVersion));
            if (contractAddress == 0) {
                contractAddress = lastVersion.contractAddress;
            }
            // Only allows smart contract change on major version bumps
            require(lastVersion.contractAddress == contractAddress || _newSemanticVersion[0] > lastVersion.semanticVersion[0]);
        } else {
            versions.length += 1;
            uint16[3] memory zeroVersion;
            require(isValidBump(zeroVersion, _newSemanticVersion));
        }

        uint versionId = versions.push(Version(_newSemanticVersion, contractAddress, _contentURI)) - 1;
        versionIdForSemantic[semanticVersionHash(_newSemanticVersion)] = versionId;
        latestVersionIdForContract[contractAddress] = versionId;

        NewVersion(versionId, _newSemanticVersion);
    }

    function getLatest() public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) {
        return getByVersionId(versions.length - 1);
    }

    function getLatestForContractAddress(address _contractAddress) public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) {
        return getByVersionId(latestVersionIdForContract[_contractAddress]);
    }

    function getBySemanticVersion(uint16[3] _semanticVersion) public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) {
        return getByVersionId(versionIdForSemantic[semanticVersionHash(_semanticVersion)]);
    }

    function getByVersionId(uint _versionId) public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) {
        require(_versionId > 0);
        Version storage version = versions[_versionId];
        return (version.semanticVersion, version.contractAddress, version.contentURI);
    }

    function getVersionsCount() public view returns (uint256) {
        uint256 len = versions.length;
        return len > 0 ? len - 1 : 0;
    }

    function isValidBump(uint16[3] _oldVersion, uint16[3] _newVersion) public pure returns (bool) {
        bool hasBumped;
        uint i = 0;
        while (i < 3) {
            if (hasBumped) {
                if (_newVersion[i] != 0) {
                    return false;
                }
            } else if (_newVersion[i] != _oldVersion[i]) {
                if (_oldVersion[i] > _newVersion[i] || _newVersion[i] - _oldVersion[i] != 1) {
                    return false;
                }
                hasBumped = true;
            }
            i++;
        }
        return hasBumped;
    }

    function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) {
        return keccak256(version[0], version[1], version[2]);
    }
}

//File: contracts/apm/APMRegistry.sol
pragma solidity 0.4.18;









contract APMRegistryConstants {
    // Cant have a regular APM appId because it is used to build APM
    // TODO: recheck this
    string constant public APM_APP_NAME = "apm-registry";
    string constant public REPO_APP_NAME = "apm-repo";
    string constant public ENS_SUB_APP_NAME = "apm-enssub";
}


contract APMRegistry is AragonApp, AppProxyFactory, APMRegistryConstants {
    AbstractENS ens;
    ENSSubdomainRegistrar public registrar;

    bytes32 constant public CREATE_REPO_ROLE = bytes32(1);

    event NewRepo(bytes32 id, string name, address repo);

    /**
    * NEEDS CREATE_NAME_ROLE and POINT_ROOTNODE_ROLE permissions on registrar
    * @param _registrar ENSSubdomainRegistrar instance that holds registry root node ownership
    */
    function initialize(ENSSubdomainRegistrar _registrar) onlyInit public {
        initialized();

        registrar = _registrar;
        ens = registrar.ens();

        registrar.pointRootNode(this);

        // Check APM has all permissions it needss
        ACL acl = ACL(kernel.acl());
        require(acl.hasPermission(this, registrar, registrar.CREATE_NAME_ROLE()));
        require(acl.hasPermission(this, acl, acl.CREATE_PERMISSIONS_ROLE()));
    }

    /**
    * @notice Create new repo in registry with `_name`
    * @param _name Repo name, must be ununsed
    * @param _dev Address that will be given permission to create versions
    */
    function newRepo(string _name, address _dev) auth(CREATE_REPO_ROLE) public returns (Repo) {
        return _newRepo(_name, _dev);
    }

    /**
    * @notice Create new repo in registry with `_name` and first repo version
    * @param _name Repo name
    * @param _dev Address that will be given permission to create versions
    * @param _initialSemanticVersion Semantic version for new repo version
    * @param _contractAddress address for smart contract logic for version (if set to 0, it uses last versions' contractAddress)
    * @param _contentURI External URI for fetching new version's content
    */
    function newRepoWithVersion(
        string _name,
        address _dev,
        uint16[3] _initialSemanticVersion,
        address _contractAddress,
        bytes _contentURI
    ) auth(CREATE_REPO_ROLE) public returns (Repo)
    {
        Repo repo = _newRepo(_name, this); // need to have permissions to create version
        repo.newVersion(_initialSemanticVersion, _contractAddress, _contentURI);

        // Give permissions to _dev
        ACL acl = ACL(kernel.acl());
        acl.revokePermission(this, repo, repo.CREATE_VERSION_ROLE());
        acl.grantPermission(_dev, repo, repo.CREATE_VERSION_ROLE());
        acl.setPermissionManager(_dev, repo, repo.CREATE_VERSION_ROLE());
        return repo;
    }

    function _newRepo(string _name, address _dev) internal returns (Repo) {
        require(bytes(_name).length > 0);

        Repo repo = newClonedRepo();

        ACL(kernel.acl()).createPermission(_dev, repo, repo.CREATE_VERSION_ROLE(), _dev);

        // Creates [name] subdomain in the rootNode and sets registry as resolver
        // This will fail if repo name already exists
        bytes32 node = registrar.createNameAndPoint(keccak256(_name), repo);

        NewRepo(node, _name, repo);

        return repo;
    }

    function newClonedRepo() internal returns (Repo) {
        return Repo(newAppProxy(kernel, repoAppId()));
    }

    function repoAppId() internal view returns (bytes32) {
        return keccak256(registrar.rootNode(), keccak256(REPO_APP_NAME));
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[],"name":"REPO_APP_NAME","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"APM_APP_NAME","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ENS_SUB_APP_NAME","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"registrar","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_dev","type":"address"},{"name":"_initialSemanticVersion","type":"uint16[3]"},{"name":"_contractAddress","type":"address"},{"name":"_contentURI","type":"bytes"}],"name":"newRepoWithVersion","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"CREATE_REPO_ROLE","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"EVMSCRIPT_REGISTRY_APP_ID","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"appId","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInitializationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"EVMSCRIPT_REGISTRY_APP","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_sender","type":"address"},{"name":"_role","type":"bytes32"},{"name":"params","type":"uint256[]"}],"name":"canPerform","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_dev","type":"address"}],"name":"newRepo","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_registrar","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_kernel","type":"address"},{"name":"_appId","type":"bytes32"},{"name":"_initializePayload","type":"bytes"}],"name":"newAppProxyPinned","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"kernel","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_kernel","type":"address"},{"name":"_appId","type":"bytes32"}],"name":"newAppProxy","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_kernel","type":"address"},{"name":"_appId","type":"bytes32"},{"name":"_initializePayload","type":"bytes"}],"name":"newAppProxy","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_script","type":"bytes"}],"name":"getExecutor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_kernel","type":"address"},{"name":"_appId","type":"bytes32"}],"name":"newAppProxyPinned","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"id","type":"bytes32"},{"indexed":false,"name":"name","type":"string"},{"indexed":false,"name":"repo","type":"address"}],"name":"NewRepo","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proxy","type":"address"}],"name":"NewAppProxy","type":"event"}]

6060604052341561000f57600080fd5b61289c8061001e6000396000f300606060405260043610620001015763ffffffff60e060020a600035041663023d6c038114620001065780631219d5c81462000196578063231cb6ab14620001ac5780632b20e39714620001c257806332ab6af014620001f45780635e1f3fa814620002cd57806360b1e05714620002f557806380afdea8146200030b5780638b3dd74914620003215780639b3fdf4c1462000337578063a1658fad146200034d578063b0927de714620003c7578063c4d66de81462000426578063d162f8b0146200044a578063d4aae0c414620004b2578063e156a8f314620004c8578063ede658b014620004ed578063f92a79ff1462000555578063ff289fc514620005a9575b600080fd5b34156200011257600080fd5b6200011c620005ce565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156200015a57808201518382015260200162000140565b50505050905090810190601f168015620001885780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3415620001a257600080fd5b6200011c62000605565b3415620001b857600080fd5b6200011c6200063c565b3415620001ce57600080fd5b620001d862000673565b604051600160a060020a03909116815260200160405180910390f35b34156200020057600080fd5b620001d860046024813581810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496600160a060020a03873516969095506080810194506020019250600391506060905060405190810160405291908282606080828437509395600160a060020a038635169590945060408082019450602091820135860180830194503592508291601f8301819004810201905190810160405281815292919060208401838380828437509496506200068295505050505050565b3415620002d957600080fd5b620002e362000ad7565b60405190815260200160405180910390f35b34156200030157600080fd5b620002e362000adc565b34156200031757600080fd5b620002e362000b10565b34156200032d57600080fd5b620002e362000b16565b34156200034357600080fd5b620002e362000b1c565b34156200035957600080fd5b620003b360048035600160a060020a031690602480359190606490604435908101908301358060208082020160405190810160405280939291908181526020018383602002808284375094965062000b9895505050505050565b604051901515815260200160405180910390f35b3415620003d357600080fd5b620001d860046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965050509235600160a060020a0316925062000cdf915050565b34156200043257600080fd5b62000448600160a060020a036004351662000d2e565b005b34156200045657600080fd5b620001d860048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620010a395505050505050565b3415620004be57600080fd5b620001d862001197565b3415620004d457600080fd5b620001d8600160a060020a0360043516602435620011a6565b3415620004f957600080fd5b620001d860048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620011e095505050505050565b34156200056157600080fd5b620001d860046024813581810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620011f095505050505050565b3415620005b557600080fd5b620001d8600160a060020a0360043516602435620012d3565b60408051908101604052600881527f61706d2d7265706f000000000000000000000000000000000000000000000000602082015281565b60408051908101604052600c81527f61706d2d72656769737472790000000000000000000000000000000000000000602082015281565b60408051908101604052600a81527f61706d2d656e7373756200000000000000000000000000000000000000000000602082015281565b606554600160a060020a031681565b600080806001620006b43382846040518059106200069d5750595b908082528060200260200182016040525062000b98565b1515620006c057600080fd5b620006cc893062001306565b925082600160a060020a0316637305341088888860405160e060020a63ffffffff86160281526004018084606080838360005b8381101562000719578082015183820152602001620006ff565b5050505090500183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156200077357808201518382015260200162000759565b50505050905090810190601f168015620007a15780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1515620007c257600080fd5b6102c65a03f11515620007d457600080fd5b505060008054600160a060020a0316915063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200082157600080fd5b6102c65a03f115156200083357600080fd5b50505060405180519050915081600160a060020a0316639d0effdb308586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200089757600080fd5b6102c65a03f11515620008a957600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b15156200090357600080fd5b6102c65a03f115156200091557600080fd5b50505081600160a060020a0316630a8ed3db898586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200097057600080fd5b6102c65a03f115156200098257600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b1515620009dc57600080fd5b6102c65a03f11515620009ee57600080fd5b50505081600160a060020a031663afd925df898586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000a4957600080fd5b6102c65a03f1151562000a5b57600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b151562000ab557600080fd5b6102c65a03f1151562000ac757600080fd5b50939a9950505050505050505050565b600181565b6040517f65766d7265672e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b60015481565b60035490565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b600062000ba462001830565b6000808451111562000bbe57835160200290508391508082525b600054600160a060020a0316158062000cd5575060008054600160a060020a03169063fdef91069088903090899087906040516020015260405160e060020a63ffffffff8716028152600160a060020a0380861660048301908152908516602483015260448201849052608060648301908152909160840183818151815260200191508051906020019080838360005b8381101562000c6857808201518382015260200162000c4e565b50505050905090810190601f16801562000c965780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b151562000cb857600080fd5b6102c65a03f1151562000cca57600080fd5b505050604051805190505b9695505050505050565b6000600162000d0e3382846040518059106200069d575059908082528060200260200182016040525062000b98565b151562000d1a57600080fd5b62000d26848462001306565b949350505050565b6003546000901562000d3f57600080fd5b62000d4962001607565b6065805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03848116919091179182905516633f15457f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000db557600080fd5b6102c65a03f1151562000dc757600080fd5b50505060405180516064805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392831617905560655416905063db6069313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151562000e4357600080fd5b6102c65a03f1151562000e5557600080fd5b505060008054600160a060020a0316915063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000ea257600080fd5b6102c65a03f1151562000eb457600080fd5b5050506040518051606554909250600160a060020a038084169250636d6712d8913091168063fef47e386000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000f1657600080fd5b6102c65a03f1151562000f2857600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151562000f8b57600080fd5b6102c65a03f1151562000f9d57600080fd5b50505060405180519050151562000fb357600080fd5b600160a060020a038116636d6712d8308383633d6ab68f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200100257600080fd5b6102c65a03f115156200101457600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156200107757600080fd5b6102c65a03f115156200108957600080fd5b5050506040518051905015156200109f57600080fd5b5050565b600080848484620010b362001842565b600160a060020a03841681526020810183905260606040820181815290820183818151815260200191508051906020019080838360005b8381101562001104578082015183820152602001620010ea565b50505050905090810190601f168015620011325780820380516001836020036101000a031916815260200191505b50945050505050604051809103906000f08015156200115057600080fd5b90507fe28f1412cafe58e22073759128eddcccfd9c1e3326665df874bdaf26077231a981604051600160a060020a03909116815260200160405180910390a1949350505050565b600054600160a060020a031681565b6000620011d983836000604051805910620011be5750595b818152601f19601f83011681016020016040529050620011e0565b9392505050565b600080848484620010b362001853565b6000620011fc62001624565b600160a060020a03166304bf2a7f836000604051602001526040518263ffffffff1660e060020a0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015620012655780820151838201526020016200124b565b50505050905090810190601f168015620012935780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b1515620012b257600080fd5b6102c65a03f11515620012c457600080fd5b50505060405180519392505050565b6000620011d983836000604051805910620012eb5750595b818152601f19601f83011681016020016040529050620010a3565b6000806000808551116200131957600080fd5b62001323620016f1565b60008054919350600160a060020a039091169063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200137257600080fd5b6102c65a03f115156200138457600080fd5b50505060405180519050600160a060020a031663be038478858485600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515620013e557600080fd5b6102c65a03f11515620013f757600080fd5b505050604051805190508860405160e060020a63ffffffff8716028152600160a060020a039485166004820152928416602484015260448301919091529091166064820152608401600060405180830381600087803b15156200145957600080fd5b6102c65a03f115156200146b57600080fd5b5050606554600160a060020a031690506365b0bc85866040518082805190602001908083835b60208310620014b25780518252601f19909201916020918201910162001491565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390208460006040516020015260405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401602060405180830381600087803b15156200152d57600080fd5b6102c65a03f115156200153f57600080fd5b5050506040518051905090507f526d4ccf8c3d7b6f0b6d4cc0de526d515c87d1ea3bd264ace0b5c2e70d1b2208818684604051838152600160a060020a038216604082015260606020820181815290820184818151815260200191508051906020019080838360005b83811015620015c2578082015183820152602001620015a8565b50505050905090810190601f168015620015f05780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1509392505050565b600354156200161557600080fd5b6200161f62001718565b600355565b600080548190600160a060020a03166342c71f1d6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515620012b257600080fd5b600080546200171390600160a060020a03166200170d6200171c565b620011a6565b905090565b4390565b606554600090600160a060020a031663faff50a882604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200176757600080fd5b6102c65a03f115156200177957600080fd5b50505060405180519050604080519081016040908152600882527f61706d2d7265706f0000000000000000000000000000000000000000000000006020830152518082805190602001908083835b60208310620017e85780518252601f199092019160209182019101620017c7565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390206040519182526020820152604090810190518091039020905090565b60206040519081016040526000815290565b6040516107fe806200186583390190565b60405161080e80620020638339019056006060604052341561000f57600080fd5b6040516107fe3803806107fe83398101604052808051919060200180519190602001805160008054600160a060020a031916600160a060020a0387161781556001859055920191849150839083906100738364010000000061017881026104901704565b9050600082511115610124576100958164010000000061048861024b82021704565b15156100a057600080fd5b80600160a060020a03168260405180828051906020019080838360005b838110156100d55780820151838201526020016100bd565b50505050905090810190601f1680156101025780820380516001836020036101000a031916815260200191505b509150506000604051808303818561646e5a03f4915050151561012457600080fd5b5050505061014660015461017864010000000002610490176401000000009004565b60028054600160a060020a031916600160a060020a03928316179081905516151561017057600080fd5b505050610253565b60008054600160a060020a03166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b151561022b57600080fd5b6102c65a03f1151561023c57600080fd5b50505060405180519392505050565b6000903b1190565b61059c806102626000396000f3006060604052600436106100ae5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631113ed0d81146100f1578063178e6079146101165780632501269914610129578063756f60491461013c57806380afdea81461014f578063a3b4b07f14610162578063cbcc65eb14610175578063d4aae0c414610188578063daa3a163146101c4578063db8a61d4146101eb578063ea879634146101fe575b6100ef6100b961020d565b6000368080601f016020809104026020016040519081016040528181529291906020840183838082843750610229945050505050565b005b34156100fc57600080fd5b610104610265565b60405190815260200160405180910390f35b341561012157600080fd5b610104610299565b341561013457600080fd5b6101046102cd565b341561014757600080fd5b610104610349565b341561015a57600080fd5b61010461037d565b341561016d57600080fd5b610104610383565b341561018057600080fd5b6101046103ff565b341561019357600080fd5b61019b610433565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34156101cf57600080fd5b6101d761044f565b604051901515815260200160405180910390f35b34156101f657600080fd5b610104610454565b341561020957600080fd5b61019b5b60025473ffffffffffffffffffffffffffffffffffffffff1690565b61023282610488565b151561023d57600080fd5b600080825160208401856127105a03f43d604051816000823e828015610261578282f35b8282fd5b6040517f6b65726e656c2e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b6040517f61707000000000000000000000000000000000000000000000000000000000008152600301604051809103902081565b6040517f636f726500000000000000000000000000000000000000000000000000000000815260040160405180910390206040517f6b65726e656c2e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b6040517f636f7265000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b60015481565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f61636c2e617261676f6e706d2e6574680000000000000000000000000000000081526010016040518091039020604051918252602082015260409081019051809103902081565b6040517f61636c2e617261676f6e706d2e657468000000000000000000000000000000008152601001604051809103902081565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600090565b6040517f62617365000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b6000903b1190565b6000805473ffffffffffffffffffffffffffffffffffffffff166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b151561055057600080fd5b6102c65a03f1151561056157600080fd5b505050604051805193925050505600a165627a7a72305820665aceb50b2de4c7ccc666fb0982e83d663fd09048c2d292d0df8d7414a83f8900296060604052341561000f57600080fd5b60405161080e38038061080e83398101604052808051919060200180519190602001805160008054600160a060020a031916600160a060020a0387161781556001859055920191849150839083906100738364010000000061013081026104e01704565b905060008251111561012457610095816401000000006105c061020382021704565b15156100a057600080fd5b80600160a060020a03168260405180828051906020019080838360005b838110156100d55780820151838201526020016100bd565b50505050905090810190601f1680156101025780820380516001836020036101000a031916815260200191505b509150506000604051808303818561646e5a03f4915050151561012457600080fd5b5050505050505061020b565b60008054600160a060020a03166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b15156101e357600080fd5b6102c65a03f115156101f457600080fd5b50505060405180519392505050565b6000903b1190565b6105f48061021a6000396000f3006060604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631113ed0d8114610124578063178e607914610149578063250126991461015c5780633bc7ebac1461016f578063756f6049146101ab57806380afdea8146101be578063a3b4b07f146101d1578063cbcc65eb146101e4578063d4aae0c4146101f7578063daa3a1631461020a578063db8a61d414610231578063ea87963414610244575b60006100c3610253565b905073ffffffffffffffffffffffffffffffffffffffff811615156100e757600080fd5b610121816000368080601f016020809104026020016040519081016040528181529291906020840183838082843750610265945050505050565b50005b341561012f57600080fd5b6101376102a1565b60405190815260200160405180910390f35b341561015457600080fd5b6101376102d5565b341561016757600080fd5b610137610309565b341561017a57600080fd5b610182610385565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34156101b657600080fd5b6101376103a1565b34156101c957600080fd5b6101376103d5565b34156101dc57600080fd5b6101376103db565b34156101ef57600080fd5b610137610457565b341561020257600080fd5b61018261048b565b341561021557600080fd5b61021d6104a7565b604051901515815260200160405180910390f35b341561023c57600080fd5b6101376104ac565b341561024f57600080fd5b6101825b60006102606001546104e0565b905090565b61026e826105c0565b151561027957600080fd5b600080825160208401856127105a03f43d604051816000823e82801561029d578282f35b8282fd5b6040517f6b65726e656c2e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b6040517f61707000000000000000000000000000000000000000000000000000000000008152600301604051809103902081565b6040517f636f726500000000000000000000000000000000000000000000000000000000815260040160405180910390206040517f6b65726e656c2e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b60645473ffffffffffffffffffffffffffffffffffffffff1681565b6040517f636f7265000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b60015481565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f61636c2e617261676f6e706d2e6574680000000000000000000000000000000081526010016040518091039020604051918252602082015260409081019051809103902081565b6040517f61636c2e617261676f6e706d2e657468000000000000000000000000000000008152601001604051809103902081565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600190565b6040517f62617365000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b6000805473ffffffffffffffffffffffffffffffffffffffff166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b15156105a057600080fd5b6102c65a03f115156105b157600080fd5b50505060405180519392505050565b6000903b11905600a165627a7a72305820386770980f0f3b576866c1845bfb9ffa0abfbff2e304c1b51c02da11456c55200029a165627a7a72305820643d3696dfe7257cb4cc3d0debd89f59fd6959dac5751924b7523ad1b7504b6b0029

Deployed Bytecode

0x606060405260043610620001015763ffffffff60e060020a600035041663023d6c038114620001065780631219d5c81462000196578063231cb6ab14620001ac5780632b20e39714620001c257806332ab6af014620001f45780635e1f3fa814620002cd57806360b1e05714620002f557806380afdea8146200030b5780638b3dd74914620003215780639b3fdf4c1462000337578063a1658fad146200034d578063b0927de714620003c7578063c4d66de81462000426578063d162f8b0146200044a578063d4aae0c414620004b2578063e156a8f314620004c8578063ede658b014620004ed578063f92a79ff1462000555578063ff289fc514620005a9575b600080fd5b34156200011257600080fd5b6200011c620005ce565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156200015a57808201518382015260200162000140565b50505050905090810190601f168015620001885780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3415620001a257600080fd5b6200011c62000605565b3415620001b857600080fd5b6200011c6200063c565b3415620001ce57600080fd5b620001d862000673565b604051600160a060020a03909116815260200160405180910390f35b34156200020057600080fd5b620001d860046024813581810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496600160a060020a03873516969095506080810194506020019250600391506060905060405190810160405291908282606080828437509395600160a060020a038635169590945060408082019450602091820135860180830194503592508291601f8301819004810201905190810160405281815292919060208401838380828437509496506200068295505050505050565b3415620002d957600080fd5b620002e362000ad7565b60405190815260200160405180910390f35b34156200030157600080fd5b620002e362000adc565b34156200031757600080fd5b620002e362000b10565b34156200032d57600080fd5b620002e362000b16565b34156200034357600080fd5b620002e362000b1c565b34156200035957600080fd5b620003b360048035600160a060020a031690602480359190606490604435908101908301358060208082020160405190810160405280939291908181526020018383602002808284375094965062000b9895505050505050565b604051901515815260200160405180910390f35b3415620003d357600080fd5b620001d860046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965050509235600160a060020a0316925062000cdf915050565b34156200043257600080fd5b62000448600160a060020a036004351662000d2e565b005b34156200045657600080fd5b620001d860048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620010a395505050505050565b3415620004be57600080fd5b620001d862001197565b3415620004d457600080fd5b620001d8600160a060020a0360043516602435620011a6565b3415620004f957600080fd5b620001d860048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620011e095505050505050565b34156200056157600080fd5b620001d860046024813581810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650620011f095505050505050565b3415620005b557600080fd5b620001d8600160a060020a0360043516602435620012d3565b60408051908101604052600881527f61706d2d7265706f000000000000000000000000000000000000000000000000602082015281565b60408051908101604052600c81527f61706d2d72656769737472790000000000000000000000000000000000000000602082015281565b60408051908101604052600a81527f61706d2d656e7373756200000000000000000000000000000000000000000000602082015281565b606554600160a060020a031681565b600080806001620006b43382846040518059106200069d5750595b908082528060200260200182016040525062000b98565b1515620006c057600080fd5b620006cc893062001306565b925082600160a060020a0316637305341088888860405160e060020a63ffffffff86160281526004018084606080838360005b8381101562000719578082015183820152602001620006ff565b5050505090500183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156200077357808201518382015260200162000759565b50505050905090810190601f168015620007a15780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1515620007c257600080fd5b6102c65a03f11515620007d457600080fd5b505060008054600160a060020a0316915063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200082157600080fd5b6102c65a03f115156200083357600080fd5b50505060405180519050915081600160a060020a0316639d0effdb308586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200089757600080fd5b6102c65a03f11515620008a957600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b15156200090357600080fd5b6102c65a03f115156200091557600080fd5b50505081600160a060020a0316630a8ed3db898586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200097057600080fd5b6102c65a03f115156200098257600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b1515620009dc57600080fd5b6102c65a03f11515620009ee57600080fd5b50505081600160a060020a031663afd925df898586600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000a4957600080fd5b6102c65a03f1151562000a5b57600080fd5b5050506040518051905060405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b151562000ab557600080fd5b6102c65a03f1151562000ac757600080fd5b50939a9950505050505050505050565b600181565b6040517f65766d7265672e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b60015481565b60035490565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b600062000ba462001830565b6000808451111562000bbe57835160200290508391508082525b600054600160a060020a0316158062000cd5575060008054600160a060020a03169063fdef91069088903090899087906040516020015260405160e060020a63ffffffff8716028152600160a060020a0380861660048301908152908516602483015260448201849052608060648301908152909160840183818151815260200191508051906020019080838360005b8381101562000c6857808201518382015260200162000c4e565b50505050905090810190601f16801562000c965780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b151562000cb857600080fd5b6102c65a03f1151562000cca57600080fd5b505050604051805190505b9695505050505050565b6000600162000d0e3382846040518059106200069d575059908082528060200260200182016040525062000b98565b151562000d1a57600080fd5b62000d26848462001306565b949350505050565b6003546000901562000d3f57600080fd5b62000d4962001607565b6065805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03848116919091179182905516633f15457f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000db557600080fd5b6102c65a03f1151562000dc757600080fd5b50505060405180516064805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392831617905560655416905063db6069313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151562000e4357600080fd5b6102c65a03f1151562000e5557600080fd5b505060008054600160a060020a0316915063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000ea257600080fd5b6102c65a03f1151562000eb457600080fd5b5050506040518051606554909250600160a060020a038084169250636d6712d8913091168063fef47e386000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151562000f1657600080fd5b6102c65a03f1151562000f2857600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151562000f8b57600080fd5b6102c65a03f1151562000f9d57600080fd5b50505060405180519050151562000fb357600080fd5b600160a060020a038116636d6712d8308383633d6ab68f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200100257600080fd5b6102c65a03f115156200101457600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156200107757600080fd5b6102c65a03f115156200108957600080fd5b5050506040518051905015156200109f57600080fd5b5050565b600080848484620010b362001842565b600160a060020a03841681526020810183905260606040820181815290820183818151815260200191508051906020019080838360005b8381101562001104578082015183820152602001620010ea565b50505050905090810190601f168015620011325780820380516001836020036101000a031916815260200191505b50945050505050604051809103906000f08015156200115057600080fd5b90507fe28f1412cafe58e22073759128eddcccfd9c1e3326665df874bdaf26077231a981604051600160a060020a03909116815260200160405180910390a1949350505050565b600054600160a060020a031681565b6000620011d983836000604051805910620011be5750595b818152601f19601f83011681016020016040529050620011e0565b9392505050565b600080848484620010b362001853565b6000620011fc62001624565b600160a060020a03166304bf2a7f836000604051602001526040518263ffffffff1660e060020a0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015620012655780820151838201526020016200124b565b50505050905090810190601f168015620012935780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b1515620012b257600080fd5b6102c65a03f11515620012c457600080fd5b50505060405180519392505050565b6000620011d983836000604051805910620012eb5750595b818152601f19601f83011681016020016040529050620010a3565b6000806000808551116200131957600080fd5b62001323620016f1565b60008054919350600160a060020a039091169063de28735990604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200137257600080fd5b6102c65a03f115156200138457600080fd5b50505060405180519050600160a060020a031663be038478858485600160a060020a031663aa61924a6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515620013e557600080fd5b6102c65a03f11515620013f757600080fd5b505050604051805190508860405160e060020a63ffffffff8716028152600160a060020a039485166004820152928416602484015260448301919091529091166064820152608401600060405180830381600087803b15156200145957600080fd5b6102c65a03f115156200146b57600080fd5b5050606554600160a060020a031690506365b0bc85866040518082805190602001908083835b60208310620014b25780518252601f19909201916020918201910162001491565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390208460006040516020015260405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401602060405180830381600087803b15156200152d57600080fd5b6102c65a03f115156200153f57600080fd5b5050506040518051905090507f526d4ccf8c3d7b6f0b6d4cc0de526d515c87d1ea3bd264ace0b5c2e70d1b2208818684604051838152600160a060020a038216604082015260606020820181815290820184818151815260200191508051906020019080838360005b83811015620015c2578082015183820152602001620015a8565b50505050905090810190601f168015620015f05780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1509392505050565b600354156200161557600080fd5b6200161f62001718565b600355565b600080548190600160a060020a03166342c71f1d6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515620012b257600080fd5b600080546200171390600160a060020a03166200170d6200171c565b620011a6565b905090565b4390565b606554600090600160a060020a031663faff50a882604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156200176757600080fd5b6102c65a03f115156200177957600080fd5b50505060405180519050604080519081016040908152600882527f61706d2d7265706f0000000000000000000000000000000000000000000000006020830152518082805190602001908083835b60208310620017e85780518252601f199092019160209182019101620017c7565b6001836020036101000a038019825116818451161790925250505091909101925060409150505180910390206040519182526020820152604090810190518091039020905090565b60206040519081016040526000815290565b6040516107fe806200186583390190565b60405161080e80620020638339019056006060604052341561000f57600080fd5b6040516107fe3803806107fe83398101604052808051919060200180519190602001805160008054600160a060020a031916600160a060020a0387161781556001859055920191849150839083906100738364010000000061017881026104901704565b9050600082511115610124576100958164010000000061048861024b82021704565b15156100a057600080fd5b80600160a060020a03168260405180828051906020019080838360005b838110156100d55780820151838201526020016100bd565b50505050905090810190601f1680156101025780820380516001836020036101000a031916815260200191505b509150506000604051808303818561646e5a03f4915050151561012457600080fd5b5050505061014660015461017864010000000002610490176401000000009004565b60028054600160a060020a031916600160a060020a03928316179081905516151561017057600080fd5b505050610253565b60008054600160a060020a03166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b151561022b57600080fd5b6102c65a03f1151561023c57600080fd5b50505060405180519392505050565b6000903b1190565b61059c806102626000396000f3006060604052600436106100ae5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631113ed0d81146100f1578063178e6079146101165780632501269914610129578063756f60491461013c57806380afdea81461014f578063a3b4b07f14610162578063cbcc65eb14610175578063d4aae0c414610188578063daa3a163146101c4578063db8a61d4146101eb578063ea879634146101fe575b6100ef6100b961020d565b6000368080601f016020809104026020016040519081016040528181529291906020840183838082843750610229945050505050565b005b34156100fc57600080fd5b610104610265565b60405190815260200160405180910390f35b341561012157600080fd5b610104610299565b341561013457600080fd5b6101046102cd565b341561014757600080fd5b610104610349565b341561015a57600080fd5b61010461037d565b341561016d57600080fd5b610104610383565b341561018057600080fd5b6101046103ff565b341561019357600080fd5b61019b610433565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34156101cf57600080fd5b6101d761044f565b604051901515815260200160405180910390f35b34156101f657600080fd5b610104610454565b341561020957600080fd5b61019b5b60025473ffffffffffffffffffffffffffffffffffffffff1690565b61023282610488565b151561023d57600080fd5b600080825160208401856127105a03f43d604051816000823e828015610261578282f35b8282fd5b6040517f6b65726e656c2e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b6040517f61707000000000000000000000000000000000000000000000000000000000008152600301604051809103902081565b6040517f636f726500000000000000000000000000000000000000000000000000000000815260040160405180910390206040517f6b65726e656c2e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b6040517f636f7265000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b60015481565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f61636c2e617261676f6e706d2e6574680000000000000000000000000000000081526010016040518091039020604051918252602082015260409081019051809103902081565b6040517f61636c2e617261676f6e706d2e657468000000000000000000000000000000008152601001604051809103902081565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600090565b6040517f62617365000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b6000903b1190565b6000805473ffffffffffffffffffffffffffffffffffffffff166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b151561055057600080fd5b6102c65a03f1151561056157600080fd5b505050604051805193925050505600a165627a7a72305820665aceb50b2de4c7ccc666fb0982e83d663fd09048c2d292d0df8d7414a83f8900296060604052341561000f57600080fd5b60405161080e38038061080e83398101604052808051919060200180519190602001805160008054600160a060020a031916600160a060020a0387161781556001859055920191849150839083906100738364010000000061013081026104e01704565b905060008251111561012457610095816401000000006105c061020382021704565b15156100a057600080fd5b80600160a060020a03168260405180828051906020019080838360005b838110156100d55780820151838201526020016100bd565b50505050905090810190601f1680156101025780820380516001836020036101000a031916815260200191505b509150506000604051808303818561646e5a03f4915050151561012457600080fd5b5050505050505061020b565b60008054600160a060020a03166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b15156101e357600080fd5b6102c65a03f115156101f457600080fd5b50505060405180519392505050565b6000903b1190565b6105f48061021a6000396000f3006060604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631113ed0d8114610124578063178e607914610149578063250126991461015c5780633bc7ebac1461016f578063756f6049146101ab57806380afdea8146101be578063a3b4b07f146101d1578063cbcc65eb146101e4578063d4aae0c4146101f7578063daa3a1631461020a578063db8a61d414610231578063ea87963414610244575b60006100c3610253565b905073ffffffffffffffffffffffffffffffffffffffff811615156100e757600080fd5b610121816000368080601f016020809104026020016040519081016040528181529291906020840183838082843750610265945050505050565b50005b341561012f57600080fd5b6101376102a1565b60405190815260200160405180910390f35b341561015457600080fd5b6101376102d5565b341561016757600080fd5b610137610309565b341561017a57600080fd5b610182610385565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34156101b657600080fd5b6101376103a1565b34156101c957600080fd5b6101376103d5565b34156101dc57600080fd5b6101376103db565b34156101ef57600080fd5b610137610457565b341561020257600080fd5b61018261048b565b341561021557600080fd5b61021d6104a7565b604051901515815260200160405180910390f35b341561023c57600080fd5b6101376104ac565b341561024f57600080fd5b6101825b60006102606001546104e0565b905090565b61026e826105c0565b151561027957600080fd5b600080825160208401856127105a03f43d604051816000823e82801561029d578282f35b8282fd5b6040517f6b65726e656c2e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b6040517f61707000000000000000000000000000000000000000000000000000000000008152600301604051809103902081565b6040517f636f726500000000000000000000000000000000000000000000000000000000815260040160405180910390206040517f6b65726e656c2e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b60645473ffffffffffffffffffffffffffffffffffffffff1681565b6040517f636f7265000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b60015481565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f61636c2e617261676f6e706d2e6574680000000000000000000000000000000081526010016040518091039020604051918252602082015260409081019051809103902081565b6040517f61636c2e617261676f6e706d2e657468000000000000000000000000000000008152601001604051809103902081565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600190565b6040517f62617365000000000000000000000000000000000000000000000000000000008152600401604051809103902081565b6000805473ffffffffffffffffffffffffffffffffffffffff166342c71f1d6040517f6261736500000000000000000000000000000000000000000000000000000000815260040160405180910390208460405191825260208201526040908101905180910390206000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401602060405180830381600087803b15156105a057600080fd5b6102c65a03f115156105b157600080fd5b50505060405180519392505050565b6000903b11905600a165627a7a72305820386770980f0f3b576866c1845bfb9ffa0abfbff2e304c1b51c02da11456c55200029a165627a7a72305820643d3696dfe7257cb4cc3d0debd89f59fd6959dac5751924b7523ad1b7504b6b0029

Swarm Source

bzzr://643d3696dfe7257cb4cc3d0debd89f59fd6959dac5751924b7523ad1b7504b6b

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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