Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 12 txns
 Latest 12 txns

TxHash Age From To Value [TxFee]
0xe5bfd4498cdca2a782a269cdc8e92e1e539d12584be266e2244c9c73516413ca143 days 7 hrs ago0x7c58b414ff08842f7652951c7adf5a0e9a0f4eb0  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.000340692
0xa80251284f7fc6983e99f6303b2ec70b6bbbca2d7e5a6bfe48b30f99a65d6363197 days 3 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.001282029
0x8d273d089aa7a3b6495765ae28068e1c0fd56ffe6660ca3ad8a09a916b22e205218 days 7 hrs ago0xeca46592d25c07f72bbf6ed5ee10c31b24fa9d1d  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.000170019
0x329f3290d853b19b73dde66916f16381460e562f04ab28f330dbdd98848ab4d6218 days 7 hrs ago0x25cfaa868033d02cc26edec57d2b3a65ef1a803e  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.002323593
0xa073672d49da666035d0b2a78ff20996db3920b7aee865a67e8b86939fe5e88b218 days 8 hrs ago0xeca46592d25c07f72bbf6ed5ee10c31b24fa9d1d  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410.598958333333333 Ether0.000092298
0xe3de253f35967f97ecb90265ba9b08464b2acc283618d55d4761bc9f4ced2cdb218 days 16 hrs ago0xf0333b94f895eb5aab3822da376f9cbcfce8a19c  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132411.038990712583216 Ether0.000456225
0x6cdf73f8e129222d9127425000b027d6cd2b9a95b140c10f60102b2288866f12219 days 8 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.00035483
0xbe43df65e7bff02cd4373de312aaf0ca66c3dda7cc96034f5fc753a17e11ec70219 days 8 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.00035323
0x0c310f31e451d9de01b4c23fe2eea95f2884eaf2c18f54d4e314d2d66a54e099219 days 8 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.00035259
0xb4c7df1952b5474044a4033d0864f51dbd9944efb1a669d0b02d834ea5288502219 days 8 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.00042791
0xbb7cbd36819aeb1d17cedf75378bee16075baccbe934f55196a6c2d4106e4686219 days 9 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN   0xca82cfcfbe9eed35f7afee9c17755c679be132410 Ether0.00015486
0x48aff49237cf6040ef2e0e58f2cd1ee3c9c82cae87be7f96f2f57d696e92bc3d219 days 9 hrs ago0x7418b3c8842421626c95a663e37b8c0466dd2145  IN    Contract Creation0 Ether0.00847664
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 2 Internal Transactions

ParentTxHash Block Age From To Value
0xe3de253f35967f97ecb90265ba9b08464b2acc283618d55d4761bc9f4ced2cdb5253237218 days 16 hrs ago0xca82cfcfbe9eed35f7afee9c17755c679be132410x7418b3c8842421626c95a663e37b8c0466dd21450.051949535629160845 Ether
0xe3de253f35967f97ecb90265ba9b08464b2acc283618d55d4761bc9f4ced2cdb5253237218 days 16 hrs ago0xca82cfcfbe9eed35f7afee9c17755c679be132410xb327d112a560f832765a12c72451de40af3c2be20.987041176954056055 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity), NestedArrayFunctionCallDecoder (medium-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: CoreContract
Compiler Text: v0.4.20+commit.3155dd80
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.18; // solhint-disable-line

library SafeMath {

  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    if (a == 0) {
      return 0;
    }
    uint256 c = a * b;
    assert(c / a == b);
    return c;
  }

  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a / b;
    return c;
  }

  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    assert(c >= a);
    return c;
  }
}

contract ERC721 {
    function approve(address _to, uint256 _tokenID) public;
    function balanceOf(address _owner) public view returns (uint256 balance);
    function implementsERC721() public pure returns (bool);
    function ownerOf(uint256 _tokenID) public view returns (address addr);
    function takeOwnership(uint256 _tokenID) public;
    function totalSupply() public view returns (uint256 total);
    function transferFrom(address _from, address _to, uint256 _tokenID) public;
    function transfer(address _to, uint256 _tokenID) public;

    event Transfer(address indexed from, address indexed to, uint256 tokenID); // solhint-disable-line
    event Approval(address indexed owner, address indexed approved, uint256 tokenID);

    function name() public pure returns (string);
    function symbol() public pure returns (string);
}

contract Ownable {
  address public owner;

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

  function Ownable() public {
    owner = msg.sender;
  }

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

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

contract Manageable is Ownable {

    address public manager;
    bool public contractLock;

    event ManagerTransferred(address indexed previousManager, address indexed newManager);
    event ContractLockChanged(address admin, bool state);

    function Manageable() public {
        manager = msg.sender;
        contractLock = false;
    }

    modifier onlyManager() {
        require(msg.sender == manager);
        _;
    }

    modifier onlyAdmin() {
        require((msg.sender == manager) || (msg.sender == owner));
        _;
    }

    modifier isUnlocked() {
        require(!contractLock);
        _;
    }

    function transferManager(address newManager) public onlyAdmin {
        require(newManager != address(0));
        ManagerTransferred(manager, newManager);
        manager = newManager;
    }

    function setContractLock(bool setting) public onlyAdmin {
        contractLock = setting;
        ContractLockChanged(msg.sender, setting);
    }

    function payout(address _to) public onlyOwner {
        if (_to == address(0)) {
            owner.transfer(this.balance);
        } else {
            _to.transfer(this.balance);
        }
    }

    function withdrawFunds(address _to, uint256 amount) public onlyOwner {
        require(this.balance >= amount);
        if (_to == address(0)) {
            owner.transfer(amount);
        } else {
            _to.transfer(amount);
        }
    }
}

contract TokenLayer is ERC721, Manageable {

    using SafeMath for uint256;

/********************************************** EVENTS **********************************************/
    event TokenCreated(uint256 tokenId, bytes32 name, uint256 parentId, address owner);
    event TokenDeleted(uint256 tokenId);

    event TokenSold(
        uint256 tokenId, uint256 oldPrice,
        uint256 newPrice, address prevOwner,
        address winner, bytes32 name,
        uint256 parentId
    );

    event PriceChanged(uint256 tokenId, uint256 oldPrice, uint256 newPrice);
    event ParentChanged(uint256 tokenId, uint256 oldParentId, uint256 newParentId);
    event NameChanged(uint256 tokenId, bytes32 oldName, bytes32 newName);
    event MetaDataChanged(uint256 tokenId, bytes32 oldMeta, bytes32 newMeta);
/****************************************************************************************************/

/******************************************** STORAGE ***********************************************/
    uint256 private constant DEFAULTPARENT = 123456789;

    mapping (uint256 => Token)   private tokenIndexToToken;
    mapping (address => uint256) private ownershipTokenCount;

    address public gameAddress;
    address public parentAddr;

    uint256 private totalTokens;
    uint256 public devFee = 50;
    uint256 public ownerFee = 200;
    uint256[10] private chainFees = [10];

    struct Token {
        bool exists;
        address approved;
        address owner;
        bytes32 metadata;
        bytes32 name;
        uint256 lastBlock;
        uint256 parentId;
        uint256 price;
    }
/****************************************************************************************************/

/******************************************* MODIFIERS **********************************************/
    modifier onlySystem() {
        require((msg.sender == gameAddress) || (msg.sender == manager));
        _;
    }
/****************************************************************************************************/

/****************************************** CONSTRUCTOR *********************************************/
    function TokenLayer(address _gameAddress, address _parentAddr) public {
        gameAddress = _gameAddress;
        parentAddr = _parentAddr;
    }
/****************************************************************************************************/

/********************************************** PUBLIC **********************************************/
    function implementsERC721() public pure returns (bool) {
        return true;
    }

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

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

    function approve(address _to, uint256 _tokenId, address _from) public onlySystem {
        _approve(_to, _tokenId, _from);
    }

    function approve(address _to, uint256 _tokenId) public isUnlocked {
        _approve(_to, _tokenId, msg.sender);
    }

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

    function bundleToken(uint256 _tokenId) public view returns(uint256[8] _tokenData) {
        Token storage token = tokenIndexToToken[_tokenId];

        uint256[8] memory tokenData;

        tokenData[0] = uint256(token.name);
        tokenData[1] = token.parentId;
        tokenData[2] = token.price;
        tokenData[3] = uint256(token.owner);
        tokenData[4] = _getNextPrice(_tokenId);
        tokenData[5] = devFee+getChainFees(_tokenId);
        tokenData[6] = uint256(token.approved);
        tokenData[7] = uint256(token.metadata);
        return tokenData;
    }

    function takeOwnership(uint256 _tokenId, address _to) public onlySystem {
        _takeOwnership(_tokenId, _to);
    }

    function takeOwnership(uint256 _tokenId) public isUnlocked {
        _takeOwnership(_tokenId, msg.sender);
    }

    function tokensOfOwner(address _owner) public view returns (uint256[] ownerTokens) {
        uint256 tokenCount = balanceOf(_owner);
        if (tokenCount == 0) {
            return new uint256[](0);
        } else {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 _totalTokens = totalSupply();
            uint256 resultIndex = 0;

            uint256 tokenId = 0;
            uint256 tokenIndex = 0;
            while (tokenIndex <= _totalTokens) {
                if (exists(tokenId)) {
                    tokenIndex++;
                    if (tokenIndexToToken[tokenId].owner == _owner) {
                        result[resultIndex] = tokenId;
                        resultIndex++;
                    }
                }
                tokenId++;
            }
            return result;
        }
    }

    function totalSupply() public view returns (uint256 total) {
        return totalTokens;
    }

    function transfer(address _to, address _from, uint256 _tokenId) public onlySystem {
        _checkThenTransfer(_from, _to, _tokenId);
    }

    function transfer(address _to, uint256 _tokenId) public isUnlocked {
        _checkThenTransfer(msg.sender, _to, _tokenId);
    }

    function transferFrom(address _from, address _to, uint256 _tokenId) public onlySystem {
        _transferFrom(_from, _to, _tokenId);
    }

    function transferFrom(address _from, uint256 _tokenId) public isUnlocked {
        _transferFrom(_from, msg.sender, _tokenId);
    }

    function createToken(
        uint256 _tokenId, address _owner,
        bytes32 _name, uint256 _parentId,
        uint256 _price, bytes32 _metadata
    ) public onlyAdmin {
        require(_price > 0);
        require(_addressNotNull(_owner));
        require(_tokenId == uint256(uint32(_tokenId)));
        require(!exists(_tokenId));

        totalTokens++;

        Token memory _token = Token({
            name: _name,
            parentId: _parentId,
            exists: true,
            price: _price,
            owner: _owner,
            approved : 0,
            lastBlock : block.number,
            metadata : _metadata
        });

        tokenIndexToToken[_tokenId] = _token;

        TokenCreated(_tokenId, _name, _parentId, _owner);

        _transfer(address(0), _owner, _tokenId);
    }

    function createTokens(
        uint256[] _tokenIds, address[] _owners,
        bytes32[] _names, uint256[] _parentIds,
        uint256[] _prices, bytes32[] _metadatas
    ) public onlyAdmin {
        for (uint256 id = 0; id < _tokenIds.length; id++) {
            createToken(
                _tokenIds[id], _owners[id], _names[id],
                _parentIds[id], _prices[id], _metadatas[id]
                );
        }
    }

    function deleteToken(uint256 _tokenId) public onlyAdmin {
        require(_tokenId == uint256(uint32(_tokenId)));
        require(exists(_tokenId));
        totalTokens--;

        address oldOwner = tokenIndexToToken[_tokenId].owner;

        ownershipTokenCount[oldOwner] = ownershipTokenCount[oldOwner]--;
        delete tokenIndexToToken[_tokenId];
        TokenDeleted(_tokenId);
    }

    function incrementPrice(uint256 _tokenId, address _to) public onlySystem {
        require(exists(_tokenId));
        uint256 _price = tokenIndexToToken[_tokenId].price;
        address _owner = tokenIndexToToken[_tokenId].owner;
        uint256 _totalFees = getChainFees(_tokenId);
        tokenIndexToToken[_tokenId].price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees));

        TokenSold(
            _tokenId, _price, tokenIndexToToken[_tokenId].price,
            _owner, _to, tokenIndexToToken[_tokenId].name,
            tokenIndexToToken[_tokenId].parentId
        );
    }

    function ownerOf(uint256 _tokenId) public view returns (address _owner) {
        require(exists(_tokenId));
        _owner = tokenIndexToToken[_tokenId].owner;
    }

    function blocked(uint256 _tokenId) public view returns (bool _blocked) {
        return (tokenIndexToToken[_tokenId].lastBlock == block.number);
    }

    function exists(uint256 _tokenId) public view returns(bool) {
        return (tokenIndexToToken[_tokenId].exists);
    }
/****************************************************************************************************/

/********************************************** SETTERS *********************************************/
    function setLayerParent(address _parent) public onlyAdmin {
        parentAddr = _parent;
    }

    function setGame(address _gameAddress) public onlyAdmin {
        gameAddress = _gameAddress;
    }

    function setPrice(uint256 _tokenId, uint256 _price, address _owner) public onlySystem {
        require(_owns(_owner, _tokenId));
        uint256 oldPrice = tokenIndexToToken[_tokenId].price;
        tokenIndexToToken[_tokenId].price = _price;
        PriceChanged(_tokenId, oldPrice, _price);
    }

    function setParent(uint256 _tokenId, uint256 _parentId) public onlyAdmin {
        require(exists(_tokenId));
        uint256 oldParentId = tokenIndexToToken[_tokenId].parentId;
        tokenIndexToToken[_tokenId].parentId = _parentId;
        ParentChanged(_tokenId, oldParentId, _parentId);
    }

    function setName(uint256 _tokenId, bytes32 _name) public onlyAdmin {
        require(exists(_tokenId));
        bytes32 oldName = tokenIndexToToken[_tokenId].name;
        tokenIndexToToken[_tokenId].name = _name;
        NameChanged(_tokenId, oldName, _name);
    }

    function setMetadata(uint256 _tokenId, bytes32 _metadata) public onlyAdmin {
        require(exists(_tokenId));
        bytes32 oldMeta = tokenIndexToToken[_tokenId].metadata;
        tokenIndexToToken[_tokenId].metadata = _metadata;
        MetaDataChanged(_tokenId, oldMeta, _metadata);
    }

    function setDevFee(uint256 _devFee) public onlyAdmin {
        devFee = _devFee;
    }

    function setOwnerFee(uint256 _ownerFee) public onlyAdmin {
        ownerFee = _ownerFee;
    }

    function setChainFees(uint256[10] _chainFees) public onlyAdmin {
        chainFees = _chainFees;
    }
/****************************************************************************************************/

/********************************************** GETTERS *********************************************/
    function getToken(uint256 _tokenId) public view returns
    (
        bytes32 tokenName, uint256 parentId, uint256 price,
        address _owner, uint256 nextPrice, uint256 nextPriceFees,
        address approved, bytes32 metadata
    ) {
        Token storage token = tokenIndexToToken[_tokenId];

        tokenName = token.name;
        parentId = token.parentId;
        price = token.price;
        _owner = token.owner;
        nextPrice = _getNextPrice(_tokenId);
        nextPriceFees = devFee+getChainFees(_tokenId);
        metadata = token.metadata;
        approved = token.approved;
    }

    function getChainFees(uint256 _tokenId) public view returns (uint256 _total) {
        uint256 chainLength = _getChainLength(_tokenId);
        uint256 totalFee = 0;
        for (uint id = 0; id < chainLength; id++) {
            totalFee = totalFee + chainFees[id];
        }
        return(totalFee);
    }

    function getChainFeeArray() public view returns (uint256[10] memory _chainFees) {
        return(chainFees);
    }

    function getPriceOf(uint256 _tokenId) public view returns (uint256 price) {
        require(exists(_tokenId));
        return tokenIndexToToken[_tokenId].price;
    }

    function getParentOf(uint256 _tokenId) public view returns (uint256 parentId) {
        require(exists(_tokenId));
        return tokenIndexToToken[_tokenId].parentId;
    }

    function getMetadataOf(uint256 _tokenId) public view returns (bytes32 metadata) {
        require(exists(_tokenId));
        return (tokenIndexToToken[_tokenId].metadata);
    }

    function getChain(uint256 _tokenId) public view returns (address[10] memory _owners) {
        require(exists(_tokenId));

        uint256 _parentId = getParentOf(_tokenId);
        address _parentAddr = parentAddr;

        address[10] memory result;

        if (_parentId != DEFAULTPARENT && _addressNotNull(_parentAddr)) {
            uint256 resultIndex = 0;

            TokenLayer layer = TokenLayer(_parentAddr);
            bool parentExists = layer.exists(_parentId);

            while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) {
                parentExists = layer.exists(_parentId);
                if (!parentExists) {
                    return(result);
                }
                result[resultIndex] = layer.ownerOf(_parentId);
                resultIndex++;

                _parentId = layer.getParentOf(_parentId);
                _parentAddr = layer.parentAddr();

                layer = TokenLayer(_parentAddr);
            }

            return(result);
        }
    }
/****************************************************************************************************/

/******************************************** PRIVATE ***********************************************/
    function _addressNotNull(address _to) private pure returns (bool) {
        return _to != address(0);
    }

    function _approved(address _to, uint256 _tokenId) private view returns (bool) {
        return (tokenIndexToToken[_tokenId].approved == _to);
    }

    function _owns(address claimant, uint256 _tokenId) private view returns (bool) {
        return claimant == tokenIndexToToken[_tokenId].owner;
    }

    function _checkThenTransfer(address _from, address _to, uint256 _tokenId) private {
        require(_owns(_from, _tokenId));
        require(_addressNotNull(_to));
        require(exists(_tokenId));
        _transfer(_from, _to, _tokenId);
    }

    function _transfer(address _from, address _to, uint256 _tokenId) private {
        ownershipTokenCount[_to]++;
        tokenIndexToToken[_tokenId].owner = _to;
        tokenIndexToToken[_tokenId].lastBlock = block.number;

        if (_from != address(0)) {
            ownershipTokenCount[_from]--;
            tokenIndexToToken[_tokenId].approved = 0;
        }

        Transfer(_from, _to, _tokenId);
    }

    function _approve(address _to, uint256 _tokenId, address _from) private {
        require(_owns(_from, _tokenId));

        tokenIndexToToken[_tokenId].approved = _to;

        Approval(_from, _to, _tokenId);
    }

    function _takeOwnership(uint256 _tokenId, address _to) private {
        address newOwner = _to;
        address oldOwner = tokenIndexToToken[_tokenId].owner;

        require(_addressNotNull(newOwner));
        require(_approved(newOwner, _tokenId));

        _transfer(oldOwner, newOwner, _tokenId);
    }

    function _transferFrom(address _from, address _to, uint256 _tokenId) private {
        require(_owns(_from, _tokenId));
        require(_approved(_to, _tokenId));
        require(_addressNotNull(_to));

        _transfer(_from, _to, _tokenId);
    }

    function _getChainLength(uint256 _tokenId) private view returns (uint256 _length) {
        uint256 length;

        uint256 _parentId = getParentOf(_tokenId);
        address _parentAddr = parentAddr;
        if (_parentId == DEFAULTPARENT || !_addressNotNull(_parentAddr)) {
            return 0;
        }

        TokenLayer layer = TokenLayer(_parentAddr);
        bool parentExists = layer.exists(_parentId);

        while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) {
            parentExists = layer.exists(_parentId);
            if(!parentExists) {
                    return(length);
            }
            _parentId = layer.getParentOf(_parentId);
            _parentAddr = layer.parentAddr();
            layer = TokenLayer(_parentAddr);
            length++;
        }

        return(length);
    }

    function _getNextPrice(uint256 _tokenId) private view returns (uint256 _nextPrice) {
        uint256 _price = tokenIndexToToken[_tokenId].price;
        uint256 _totalFees = getChainFees(_tokenId);
        _price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees));
        return(_price);
    }
}

contract CoreContract is Manageable {

    using SafeMath for uint256;

/******************************************** STORAGE ***********************************************/

    bool public priceLocked = true;
    uint256 private constant DEFAULTPARENT = 123456789;

    uint256 public layerCount;
    mapping(uint256 => address) public getLayerFromId;
    mapping(uint256 => bytes32) public getLayerNameFromId;
    mapping(address => bool) private blacklisted;

    bool public blackListActive;
    bool public blockLockActive;


/********************************************** PUBLIC **********************************************/
    function approve(address _to, uint256 _tokenId, uint256 layerId) public isUnlocked {
        address layerAddr = getLayerFromId[layerId];
        TokenLayer layer = TokenLayer(layerAddr);
        layer.approve(_to, _tokenId, msg.sender);
    }

    function takeOwnership(uint256 _tokenId, uint256 layerId) public isUnlocked {
        address layerAddr = getLayerFromId[layerId];
        TokenLayer layer = TokenLayer(layerAddr);
        layer.takeOwnership(_tokenId, msg.sender);
    }

    function transfer(address _to, uint256 _tokenId, uint256 layerId) public isUnlocked {
        address layerAddr = getLayerFromId[layerId];
        TokenLayer layer = TokenLayer(layerAddr);
        layer.transfer(_to, msg.sender, _tokenId);
    }

    function setPrice(uint256 _tokenId, uint256 _price, uint256 layerId) public isUnlocked {
        address layerAddr = getLayerFromId[layerId];
        require(!priceLocked);
        TokenLayer layer = TokenLayer(layerAddr);
        layer.setPrice(_tokenId, _price, msg.sender);
    }

    function transferFrom(address _from, uint256 _tokenId, uint256 layerId) public isUnlocked {
        address layerAddr = getLayerFromId[layerId];
        TokenLayer layer = TokenLayer(layerAddr);
        layer.transferFrom(_from, msg.sender, _tokenId);
    }

    function purchase(uint256 _tokenId, uint256 layerId) public payable isUnlocked {
        if (!_blackListed(msg.sender)) {
            address layerAddr = getLayerFromId[layerId];
            TokenLayer layer = TokenLayer(layerAddr);

            address _owner = layer.ownerOf(_tokenId);
            uint256 price = layer.getPriceOf(_tokenId);

            uint256 excess = msg.value.sub(price);
            require(_owner != msg.sender);

            require(msg.value >= price);

            require(!blockLockActive || !layer.blocked(_tokenId));

            layer.incrementPrice(_tokenId, msg.sender);
            layer.transfer(msg.sender, _owner, _tokenId);

            uint256 payment = _updatePayment(_tokenId, layerAddr, price);

            if (_owner != address(this)) {
                _owner.transfer(payment);
            }

            _payChain(_tokenId, layerAddr, price);

            msg.sender.transfer(excess);
            owner.transfer(this.balance);
        }
    }

    function addLayer(address _layerAddr, uint256 layerId, bytes32 _name) public onlyAdmin {
        require(!_addressNotNull(getLayerFromId[layerId]));
        getLayerFromId[layerId] = _layerAddr;
        getLayerNameFromId[layerId] = _name;
        layerCount++;
    }

    function deleteLayer(uint256 layerId) public onlyAdmin {
        require(_addressNotNull(getLayerFromId[layerId]));
        getLayerFromId[layerId] = address(0);
        getLayerNameFromId[layerId] = "";
        layerCount--;
    }

    function getToken(uint256 _tokenId, uint256 layerId) public view returns(
            bytes32 tokenName, uint256 parentId, uint256 price,
            address _owner, uint256 nextPrice, uint256 nextPriceFees,
            address approved, bytes32 metadata
        ) {
        address layerAddr = getLayerFromId[layerId];
        TokenLayer layer = TokenLayer(layerAddr);

        uint256[8] memory tokenData = layer.bundleToken(_tokenId);

        tokenName = bytes32(tokenData[0]);
        parentId = tokenData[1];
        price = tokenData[2];
        _owner = address(tokenData[3]);

        nextPrice = tokenData[4];
        nextPriceFees = tokenData[5];
        approved = address(tokenData[6]);
        metadata = bytes32(tokenData[7]);
    }

    function setPriceLocked(bool setting) public onlyAdmin {
        priceLocked = setting;
    }

    function setBlacklist(bool setting) public onlyAdmin {
        blackListActive = setting;
    }

    function setBlockLock(bool setting) public onlyAdmin {
        blockLockActive = setting;
    }

    function addToBlacklist(address _to) public onlyAdmin {
        blacklisted[_to] = true;
    }

    function removeFromBlacklist(address _to) public onlyAdmin {
        blacklisted[_to] = false;
    }
/****************************************************************************************************/

/******************************************** PRIVATE ***********************************************/
    function _payChain(uint256 _tokenId, address layerAddr, uint256 _price) public
    {
        TokenLayer mainLayer = TokenLayer(layerAddr);

        uint256[10] memory _chainFees = mainLayer.getChainFeeArray();
        address[10] memory _owners = mainLayer.getChain(_tokenId);

        for (uint256 i = 0; i < 10; i++) {
            if (_addressNotNull(_owners[i])) {
                _owners[i].transfer(_price.mul(_chainFees[i]).div(1000));
            }
        }
    }

    function _updatePayment(uint256 _tokenId, address layerAddr, uint _price) private view returns(uint256 _payment) {
        TokenLayer layer = TokenLayer(layerAddr);

        uint256 devFee = layer.devFee();
        uint256 totalFee = layer.getChainFees(_tokenId);

        uint256 payment = _price.mul(1000-(devFee+totalFee)).div(1000);

        return(payment);
    }

    function _addressNotNull(address _to) private pure returns (bool) {
        return _to != address(0);
    }

    function _blackListed(address _payer) private view returns (bool) {
        return (blacklisted[_payer]) && (blackListActive);
    }
}

    Contract ABI  
[{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"takeOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"setting","type":"bool"}],"name":"setPriceLocked","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"payout","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_layerAddr","type":"address"},{"name":"layerId","type":"uint256"},{"name":"_name","type":"bytes32"}],"name":"addLayer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"setting","type":"bool"}],"name":"setBlockLock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"addToBlacklist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"setting","type":"bool"}],"name":"setBlacklist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"manager","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"removeFromBlacklist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"setting","type":"bool"}],"name":"setContractLock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"layerCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"purchase","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"getLayerFromId","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"blackListActive","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"layerAddr","type":"address"},{"name":"_price","type":"uint256"}],"name":"_payChain","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"getToken","outputs":[{"name":"tokenName","type":"bytes32"},{"name":"parentId","type":"uint256"},{"name":"price","type":"uint256"},{"name":"_owner","type":"address"},{"name":"nextPrice","type":"uint256"},{"name":"nextPriceFees","type":"uint256"},{"name":"approved","type":"address"},{"name":"metadata","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"layerId","type":"uint256"}],"name":"setPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newManager","type":"address"}],"name":"transferManager","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"getLayerNameFromId","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"amount","type":"uint256"}],"name":"withdrawFunds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"contractLock","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"blockLockActive","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"layerId","type":"uint256"}],"name":"deleteLayer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"priceLocked","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousManager","type":"address"},{"indexed":true,"name":"newManager","type":"address"}],"name":"ManagerTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"admin","type":"address"},{"indexed":false,"name":"state","type":"bool"}],"name":"ContractLockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

  Contract Creation Code Switch To Opcodes View
60606040526001805460008054600160a060020a033316600160a060020a0319918216811790925560a060020a60ff021960a860020a60ff02199093167501000000000000000000000000000000000000000000171617169055611789806100686000396000f30060606040526004361061015b5763ffffffff60e060020a60003504166306c1860081146101605780630932c3c61461017b578063095bcdb6146101935780630b7e9c44146101b857806322c5b279146101d757806323a31463146101fc578063426a84931461021457806344337ea11461023957806344c4bf1014610258578063481c6a7514610270578063537df3b61461029f57806353ebf6bd146102be57806356e7f6c7146102d657806370876c98146102fb57806377dbbd76146103095780638301e7091461032e5780638da5cb5b14610344578063a0c567a214610357578063a1169d721461037e578063a4fd3cea146103a3578063aa585d561461040c578063ba0e930a14610428578063bbfd32d214610447578063c10753291461045d578063cf837fad1461047f578063d537c3e314610492578063de67fd05146104a5578063ea2470ab146104bb578063f2fde38b146104ce575b600080fd5b341561016b57600080fd5b6101796004356024356104ed565b005b341561018657600080fd5b6101796004351515610590565b341561019e57600080fd5b610179600160a060020a0360043516602435604435610608565b34156101c357600080fd5b610179600160a060020a03600435166106b9565b34156101e257600080fd5b610179600160a060020a0360043516602435604435610762565b341561020757600080fd5b6101796004351515610813565b341561021f57600080fd5b610179600160a060020a0360043516602435604435610863565b341561024457600080fd5b610179600160a060020a03600435166108f8565b341561026357600080fd5b6101796004351515610952565b341561027b57600080fd5b61028361099b565b604051600160a060020a03909116815260200160405180910390f35b34156102aa57600080fd5b610179600160a060020a03600435166109aa565b34156102c957600080fd5b6101796004351515610a01565b34156102e157600080fd5b6102e9610aa8565b60405190815260200160405180910390f35b610179600435602435610aae565b341561031457600080fd5b610179600160a060020a0360043516602435604435610e44565b341561033957600080fd5b610283600435610eda565b341561034f57600080fd5b610283610ef5565b341561036257600080fd5b61036a610f04565b604051901515815260200160405180910390f35b341561038957600080fd5b610179600435600160a060020a0360243516604435610f0d565b34156103ae57600080fd5b6103bc6004356024356110a8565b6040519788526020880196909652604080880195909552600160a060020a039384166060880152608087019290925260a08601521660c084015260e0830191909152610100909101905180910390f35b341561041757600080fd5b6101796004356024356044356111a5565b341561043357600080fd5b610179600160a060020a0360043516611266565b341561045257600080fd5b6102e960043561131c565b341561046857600080fd5b610179600160a060020a036004351660243561132e565b341561048a57600080fd5b61036a6113de565b341561049d57600080fd5b61036a6113ee565b34156104b057600080fd5b6101796004356113fc565b34156104c657600080fd5b61036a61149e565b34156104d957600080fd5b610179600160a060020a03600435166114c0565b600154600090819060a060020a900460ff161561050957600080fd5b50506000818152600360205260409081902054600160a060020a0316908190819063ff5f8b4b90869033905160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561057657600080fd5b6102c65a03f1151561058757600080fd5b50505050505050565b60015433600160a060020a03908116911614806105bb575060005433600160a060020a039081169116145b15156105c657600080fd5b6001805491151575010000000000000000000000000000000000000000000275ff00000000000000000000000000000000000000000019909216919091179055565b600154600090819060a060020a900460ff161561062457600080fd5b50506000818152600360205260409081902054600160a060020a0316908190819063beabacc8908790339088905160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b151561069e57600080fd5b6102c65a03f115156106af57600080fd5b5050505050505050565b60005433600160a060020a039081169116146106d457600080fd5b600160a060020a038116151561072257600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050151561071d57600080fd5b61075f565b80600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f19350505050151561075f57600080fd5b50565b60015433600160a060020a039081169116148061078d575060005433600160a060020a039081169116145b151561079857600080fd5b6000828152600360205260409020546107b990600160a060020a031661155b565b156107c357600080fd5b6000918252600360209081526040808420805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0396909616959095179094556004905291902055600280546001019055565b60015433600160a060020a039081169116148061083e575060005433600160a060020a039081169116145b151561084957600080fd5b600680549115156101000261ff0019909216919091179055565b600154600090819060a060020a900460ff161561087f57600080fd5b50506000818152600360205260409081902054600160a060020a03169081908190631271f09a908790879033905160e060020a63ffffffff8616028152600160a060020a03938416600482015260248101929092529091166044820152606401600060405180830381600087803b151561069e57600080fd5b60015433600160a060020a0390811691161480610923575060005433600160a060020a039081169116145b151561092e57600080fd5b600160a060020a03166000908152600560205260409020805460ff19166001179055565b60015433600160a060020a039081169116148061097d575060005433600160a060020a039081169116145b151561098857600080fd5b6006805460ff1916911515919091179055565b600154600160a060020a031681565b60015433600160a060020a03908116911614806109d5575060005433600160a060020a039081169116145b15156109e057600080fd5b600160a060020a03166000908152600560205260409020805460ff19169055565b60015433600160a060020a0390811691161480610a2c575060005433600160a060020a039081169116145b1515610a3757600080fd5b6001805474ff0000000000000000000000000000000000000000191660a060020a831515021790557fd1b3ccafda2b2f8613e51c6ac4f6e844932f92b0058df6d7ee800b152f55a00d3382604051600160a060020a039092168252151560208201526040908101905180910390a150565b60025481565b600080600080600080600160149054906101000a900460ff16151515610ad357600080fd5b610adc33611569565b15156106af5760008781526003602052604080822054600160a060020a031697508796508691636352211e918b9190516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610b4657600080fd5b6102c65a03f11515610b5757600080fd5b5050506040518051945050600160a060020a03851663b54b4fb98960006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610bb157600080fd5b6102c65a03f11515610bc257600080fd5b50505060405180519350610bde9050348463ffffffff61159916565b915033600160a060020a031684600160a060020a031614151515610c0157600080fd5b3483901015610c0f57600080fd5b600654610100900460ff161580610c8d575084600160a060020a031663d5182b708960006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610c7057600080fd5b6102c65a03f11515610c8157600080fd5b50505060405180519050155b1515610c9857600080fd5b84600160a060020a031663b7d9549c893360405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515610ced57600080fd5b6102c65a03f11515610cfe57600080fd5b50505084600160a060020a031663beabacc833868b60405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b1515610d6257600080fd5b6102c65a03f11515610d7357600080fd5b505050610d818887856115ab565b905030600160a060020a031684600160a060020a0316141515610dcf57600160a060020a03841681156108fc0282604051600060405180830381858888f193505050501515610dcf57600080fd5b610dda888785610f0d565b600160a060020a03331682156108fc0283604051600060405180830381858888f193505050501515610e0b57600080fd5b600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f1935050505015156106af57600080fd5b600154600090819060a060020a900460ff1615610e6057600080fd5b50506000818152600360205260409081902054600160a060020a031690819081906323b872dd908790339088905160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b151561069e57600080fd5b600360205260009081526040902054600160a060020a031681565b600054600160a060020a031681565b60065460ff1681565b6000610f176116f1565b610f1f611719565b600085935083600160a060020a031663ce2c6ad5600060405161014001526040518163ffffffff1660e060020a02815260040161014060405180830381600087803b1515610f6c57600080fd5b6102c65a03f11515610f7d57600080fd5b5050506040518061014001604052925083600160a060020a031663b6791ad4886000604051610140015260405160e060020a63ffffffff8416028152600481019190915260240161014060405180830381600087803b1515610fde57600080fd5b6102c65a03f11515610fef57600080fd5b50505060405180610140016040529150600090505b600a811015610587576110268282600a811061101c57fe5b602002015161155b565b156110a0578181600a811061103757fe5b6020020151600160a060020a03166108fc61107b6103e861106f8786600a811061105d57fe5b60200201518a9063ffffffff6116a416565b9063ffffffff6116da16565b9081150290604051600060405180830381858888f1935050505015156110a057600080fd5b600101611004565b6000806000806000806000806000806110bf611742565b600360008d815260200190815260200160002060009054906101000a9004600160a060020a0316925082915081600160a060020a031663645cd0468e6000604051610100015260405160e060020a63ffffffff8416028152600481019190915260240161010060405180830381600087803b151561113c57600080fd5b6102c65a03f1151561114d57600080fd5b5050506040516101008101604052905080519a506020810151995060408101519850606081015197506080810151965060a0810151955060c0810151945060e081015160010293505050509295985092959890939650565b600154600090819060a060020a900460ff16156111c157600080fd5b600083815260036020526040902054600154600160a060020a0390911692507501000000000000000000000000000000000000000000900460ff161561120657600080fd5b5080600160a060020a03811663f83fcdea86863360405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b151561069e57600080fd5b60015433600160a060020a0390811691161480611291575060005433600160a060020a039081169116145b151561129c57600080fd5b600160a060020a03811615156112b157600080fd5b600154600160a060020a0380831691167f9cb45c728de594dab506a1f1a8554e24c8eeaf983618d5ec5dd7bc6f3c49feee60405160405180910390a36001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60046020526000908152604090205481565b60005433600160a060020a0390811691161461134957600080fd5b600160a060020a033016318190101561136157600080fd5b600160a060020a03821615156113a957600054600160a060020a031681156108fc0282604051600060405180830381858888f1935050505015156113a457600080fd5b6113da565b600160a060020a03821681156108fc0282604051600060405180830381858888f1935050505015156113da57600080fd5b5050565b60015460a060020a900460ff1681565b600654610100900460ff1681565b60015433600160a060020a0390811691161480611427575060005433600160a060020a039081169116145b151561143257600080fd5b60008181526003602052604090205461145390600160a060020a031661155b565b151561145e57600080fd5b6000908152600360209081526040808320805473ffffffffffffffffffffffffffffffffffffffff19169055600490915281205560028054600019019055565b6001547501000000000000000000000000000000000000000000900460ff1681565b60005433600160a060020a039081169116146114db57600080fd5b600160a060020a03811615156114f057600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a0316151590565b600160a060020a03811660009081526005602052604081205460ff168015611593575060065460ff165b92915050565b6000828211156115a557fe5b50900390565b600082818080600160a060020a038416636827e76482604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156115f657600080fd5b6102c65a03f1151561160757600080fd5b5050506040518051935050600160a060020a038416639d77e4f88960006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561166157600080fd5b6102c65a03f1151561167257600080fd5b5050506040518051925061169890506103e861106f88868601830363ffffffff6116a416565b98975050505050505050565b6000808315156116b757600091506116d3565b508282028284828115156116c757fe5b04146116cf57fe5b8091505b5092915050565b60008082848115156116e857fe5b04949350505050565b610140604051908101604052600a815b60008152602001906001900390816117015790505090565b610140604051908101604052600a815b6000815260001990910190602001816117295790505090565b610100604051908101604052600081526007602082016117015600a165627a7a72305820f90ebad929ba5724fd348e8bdfa27e5b62d709c2eb45dfee2b318db465e92ffc0029

   Swarm Source:
bzzr://f90ebad929ba5724fd348e8bdfa27e5b62d709c2eb45dfee2b318db465e92ffc

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.