Contract 0x88709acee2a7d5ad8281d76c2d944eda1ee05063

 

Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
Warning: The compiled contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) Solidity Compiler Bugs.

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


Contract Source Code
pragma solidity 0.4.24;
/******************************************************************************\
* Author: Nick Mudge, [email protected]
* Mokens
* Copyright (c) 2018
*
* The getStateHash function returns a hash that represents the state of a moken. 
* This can be used to verify that child non-fungible tokens have not
* been added/removed right before a transfer or sale.
/******************************************************************************/
///////////////////////////////////////////////////////////////////////////////////
//Storage contracts
////////////
//Some delegate contracts are listed with storage contracts they inherit.
///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
//Mokens
///////////////////////////////////////////////////////////////////////////////////
contract Storage0 {
    // funcId => delegate contract
    mapping(bytes4 => address) internal delegates;
}
///////////////////////////////////////////////////////////////////////////////////
//MokenUpdates
//MokenOwner
//QueryMokenDelegates
///////////////////////////////////////////////////////////////////////////////////
contract Storage1 is Storage0 {
    address internal contractOwner;
    bytes[] internal funcSignatures;
    // signature => index+1
    mapping(bytes => uint256) internal funcSignatureToIndex;
}
///////////////////////////////////////////////////////////////////////////////////
//MokensSupportsInterfaces
///////////////////////////////////////////////////////////////////////////////////
contract Storage2 is Storage1 {
    mapping(bytes4 => bool) internal supportedInterfaces;
}
///////////////////////////////////////////////////////////////////////////////////
//MokenRootOwnerOf
//MokenERC721Metadata
///////////////////////////////////////////////////////////////////////////////////
contract Storage3 is Storage2 {
    struct Moken {
        string name;
        uint256 data;
        uint256 parentTokenId;
    }
    //tokenId => moken
    mapping(uint256 => Moken) internal mokens;
    uint256 internal mokensLength;
    // child address => child tokenId => tokenId+1
    mapping(address => mapping(uint256 => uint256)) internal childTokenOwner;
}
///////////////////////////////////////////////////////////////////////////////////
//MokenERC721Enumerable
//MokenLinkHash
///////////////////////////////////////////////////////////////////////////////////
contract Storage4 is Storage3 {
    // root token owner address => (tokenId => approved address)
    mapping(address => mapping(uint256 => address)) internal rootOwnerAndTokenIdToApprovedAddress;
    // token owner => (operator address => bool)
    mapping(address => mapping(address => bool)) internal tokenOwnerToOperators;
    // Mapping from owner to list of owned token IDs
    mapping(address => uint32[]) internal ownedTokens;
}
///////////////////////////////////////////////////////////////////////////////////
//MokenERC998ERC721TopDown
//MokenERC998ERC721TopDownBatch
//MokenERC721
//MokenERC721Batch
///////////////////////////////////////////////////////////////////////////////////
contract Storage5 is Storage4 {
    // tokenId => (child address => array of child tokens)
    mapping(uint256 => mapping(address => uint256[])) internal childTokens;
    // tokenId => (child address => (child token => child index)
    mapping(uint256 => mapping(address => mapping(uint256 => uint256))) internal childTokenIndex;
    // tokenId => (child address => contract index)
    mapping(uint256 => mapping(address => uint256)) internal childContractIndex;
    // tokenId => child contract
    mapping(uint256 => address[]) internal childContracts;
}
///////////////////////////////////////////////////////////////////////////////////
//MokenERC998ERC20TopDown
//MokenStateChange
///////////////////////////////////////////////////////////////////////////////////
contract Storage6 is Storage5 {
    // tokenId => token contract
    mapping(uint256 => address[]) internal erc20Contracts;
    // tokenId => (token contract => token contract index)
    mapping(uint256 => mapping(address => uint256)) erc20ContractIndex;
    // tokenId => (token contract => balance)
    mapping(uint256 => mapping(address => uint256)) internal erc20Balances;
}

contract MokenStateChange is Storage6 {
    uint256 constant MOKEN_LINK_HASH_MASK = 0xffffffffffffffff000000000000000000000000000000000000000000000000;

    function getStateHash(uint256 _tokenId) public view returns (bytes32 stateHash) {
        uint256 linkHash = mokens[_tokenId].data & MOKEN_LINK_HASH_MASK;
        stateHash = keccak256(stateHash, linkHash);
        address[] memory childContracts_ = childContracts[_tokenId];
        uint256 length = childContracts_.length;
        uint256 i;
        if(length > 0) {
            stateHash = keccak256(stateHash, childContracts_);
            for (i = 0; i < length; i++) {
                stateHash = keccak256(stateHash, childTokens[_tokenId][childContracts_[i]]);
            }
        }
        address[] memory erc20Contracts_ = erc20Contracts[_tokenId];
        length = erc20Contracts_.length;
        if(length > 0) {
            stateHash = keccak256(stateHash, erc20Contracts_);
            for (i = 0; i < length; i++) {
                stateHash = keccak256(stateHash, erc20Balances[_tokenId][erc20Contracts_[i]]);
            }
        }
        return stateHash;
    }
}

Contract ABI
[{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getStateHash","outputs":[{"name":"stateHash","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"}]

Contract Creation Code
608060405234801561001057600080fd5b506103d5806100206000396000f3006080604052600436106100405763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166354823e668114610045575b600080fd5b34801561005157600080fd5b5061005d60043561006f565b60408051918252519081900360200190f35b60008181526005602090815260408083206001015481518481527fffffffffffffffff00000000000000000000000000000000000000000000000090911681840181905282519182900383018220868652600e855283862080548087028501870190955284845290959194606094929384938693919283018282801561012b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610100575b5050505050935083519250600083111561025557604051868152845187918691602080830191818501910280838360005b8381101561017457818101518382015260200161015c565b505050509050019250505060405180910390209550600091505b82821015610255576000878152600b6020526040812085518892908790869081106101b557fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020604051808360001916600019168152602001828054801561023957602002820191906000526020600020905b815481526020019060010190808311610225575b50506040519081900390209850506001909301925061018e9050565b6000878152600f6020908152604091829020805483518184028101840190945280845290918301828280156102c057602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610295575b5050505050905080519250600083111561039f57604051868152815187918391602080830191818501910280838360005b838110156103095781810151838201526020016102f1565b505050509050019250505060405180910390209550600091505b8282101561039f576000878152601160205260408120825188929084908690811061034a57fe5b602090810290910181015173ffffffffffffffffffffffffffffffffffffffff168252818101929092526040908101600020548151938452918301919091528051918290030190209550600190910190610323565b50505050509190505600a165627a7a7230582098d0f2354f27118ab7f4dcad04522a77e81f68f96010cc642972f50ffa2bfae10029


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