I am new to ERC721 tokens so this may be a stupid question.
I want to create my own ERC721 which can be integrated with opensea using the metadata, as far as I understand you have to store the tokenUri which is an HTTP link in a server or using IPFS, my question becomes, what happens if I don't follow the standard json and I add random fields ?
Does the tokenUri only store a link and inside of that you have to put the json ?
Best Answer
You have a lot of questions in there. Let's find the relevant references first.
Specification
The standard is specified at https://eips.ethereum.org/EIPS/eip-721
The specifications are the
tokenURI
documentation:and the JSON metadata schema specification:
Your questions
You need to read the above very literally (i.e. using RFC 2119) and know about URIs to answer the questions. Your questions are, implicitly, "how can I do this?" and "will an implementation that does this be a valid ERC-721 implementation as specified by the standard?"
... the
tokenUri
[is] an HTTP link in a server or using IPFS ...Typically, yes. To my knowledge, every implementation does use URLs. I have never seen a deployed project using data URIs.
But not necessarily. The set of all URIs include uniform resource locators like HTTP and IPFS links, but URIs also include uniform resource names. There is also a literal "data URI" syntax that you could use.
is my implementation compliant with the standard if I add random fields to the JSON
Yes. The JSON schema only attributes meaning to specific fields. It does not restrict you from adding additional fields. The only way you could make a JSON file that is NOT compliant with the ERC721 Metadata JSON Schema is if it does any of the following:
name
and the value of thatname
is not of the string typedescription
and the value of thatdescription
is not of the string typeimage
and the value of thatimage
is not of the string typeimage
and the value of thatimage
is a string but it is not a URI pointing to a resource with mime type image/* representing the asset to which this NFT representsAlso, to be perfectly clear it is not required that
tokenUri
point to a valid JSON document satisfying the ERC721 Metadata JSON Schema.If this sounds wishy-washy then you need to understand that ERC-721 was written to make many possible implementations be considered valid. It also allows you to adopt other conventions if you would like additional interoperability.
what happens on OpenSea if I add random fields
OpenSea will show them to people that buy your stuff.
Does the
tokenUri
only store a link and inside of that you have to put the json?This is the most popular implementation. You could store other stuff in
tokenUri
. And you could use other ways to point thetokenUri
to a JSON file. See above.