loomnetwork / erc721x

ERC721x is an extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tokenURI is pointing at a Loom domain. Make it abstract

mattkanwisher opened this issue · comments

    function tokenURI(uint256 _tokenId) public view returns (string tokenUri) {
        require(exists(_tokenId), "Token doesn't exist");
        tokenUri = "https://loom.games/erc721/zmb/000000.json";

        bytes memory _uriBytes = bytes(tokenUri);
        _uriBytes[39] = byte(48+(_tokenId / 10000) % 10);
        _uriBytes[40] = byte(48+(_tokenId / 1000) % 10);
        _uriBytes[41] = byte(48+(_tokenId / 100) % 10);
        _uriBytes[42] = byte(48+(_tokenId / 10) % 10);
        _uriBytes[43] = byte(48+(_tokenId / 1) % 10);

        return tokenUri;
    }

would be nice to give this as an example but make the function abstract to override it

why does this fuction return tokenuri and not uribytes?

Rather than constructing each tokenURI on chain it might be worth exploring something like a baseTokenURI property that can be used to construct individual token uris off chain.

e.g. if the baseTokenURI is https://loom.games/erc721/zmb and we want the details of the 1st token then we know we can look it up at https://loom.games/erc721/zmb/1.json.

Fixed in db5928a, now the URI is passed via the constructor