0

I'm trying to get Metadata from ERC721 token. Actually I'm trying to do it via ETHERSCAN and blockcypher APIs but I can't find the metadata in the response (like the Picture URL or the IPFS ID)

Can somebody suggest me how to do it?

It's something I must do client side or can I do it with Nethereum for instance?

Thanks

6

The other answer is incorrect.

See the ERC721 Standard for exactly how to do this. If a token contract properly implements the ERC721 Standard and the ERC721Metadata extension, it will always implement the function

function tokenURI(uint256 _tokenId) external view returns (string);

which will return a URI pointing to that token's metadata. It may be in JSON format, and if it is, see the standard for the structure of the ERC721 Metadata JSON Schema.

Any methods which retrieve token metadata other than this are not part of the ERC721 Standard. This isn't to say that they break any rules set out by the standard, but the only guaranteed way to get ERC721 token Metadata on a properly implemented ERC721 contract is through the method mentioned above.

  • "The metadata extension is OPTIONAL for ERC-721 smart contracts (see "caveats", below). This allows your smart contract to be interrogated for its name and for details about the assets which your NFTs represent." Most the token "ERC721" I worked with DOES NOT implement this method, that's why I proposed a complete example with the other API. – Ziba Leah May 18 '18 at 9:45
  • 1
    Yes, it's optional, but its also the only way of getting Metadata which adheres to the standard - that's the purpose of the extension. The question was about the ERC721 standard, not about random implementations thereof. The whole point of standards is so that all contracts implement identical functions in identical ways, so you dont need to write a specific interface for each contract you work with. – AnAllergyToAnalogy May 18 '18 at 9:50
  • @AnAllergyToAnalogy What guarantee do we have that the data the URI will return is authentic and was not tampered somehow. Since it's stored offchain I don't think there is any guarantee as per that. Is there any hash of this JSON data stored somewhere on the blockchain ? – Tarik Mokafih Jul 6 '18 at 7:15
  • 1
    @TarikMokafih the standard doesn't specify whether/how/where to store the hash of the JSON data on-chain, but if you want to store hashes of the JSON data on-chain, and add another function to access it, then thats fine. – AnAllergyToAnalogy Jul 7 '18 at 12:00
  • so the URI is a centralized link to a json? e.g. example.com/objects/11 which return sth like: {"title": "test object", "type": "object", "properties": { "name": { ...} ... } – Richard Fu Aug 23 '18 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.