Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not make a new memory variable to save the storage variable and compare the two memory variable? #4

Open
flyq opened this issue Aug 9, 2018 · 2 comments

Comments

@flyq
Copy link

flyq commented Aug 9, 2018

https://forum.ethereum.org/discussion/3238/string-compare-in-solidity

@flyq
Copy link
Author

flyq commented Aug 9, 2018

AjoyBhatia's post

@flyq
Copy link
Author

flyq commented Aug 9, 2018

    function registerByAdmin(address _user, string _ipfsAddr)
        public
        onlyAdmins
        whenNotPaused
    {
        require(isOnAdmin == true);
        require(indexOfIpfs[_ipfsAddr] == 0 && keccak256(abi.encodePacked(ipfsAddrOf[0])) != keccak256(abi.encodePacked(_ipfsAddr)));
        uint256 _tokenId = allTokens.length;
        require(!exists(_tokenId));

        _mint(_user, _tokenId);
        ipfsAddrOf[_tokenId] = _ipfsAddr;
        indexOfIpfs[_ipfsAddr] = _tokenId;
    }

ipfsAddrOf[0] is a storage, ipfsAddr is memory. and code above is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant