Thanks for putting this together. A specification for the metadata format that most tokens already use is long overdue, and the draft gets many of the hard details right. Here are a few points of feedback, based on my own test suites and knowledge of deployed collections. Feel free to treat them as you like.
SUBSTANTIVE: Raw JSON returned from tokenURI or uri
Section: Specification > Resolving URIs; Deployed forms
Issue. Some marketplaces (notably OpenSea) accept raw JSON returned from ERC-721 tokenURI or ERC-1155 uri. Both standards define the return value as a URI, so this behavior is unspecified and persists only because some clients tolerate it.
As a result, implementers currently have to guess. Some clients check for a leading { and parse the value, while others treat it as a malformed URI, so the same token renders in one product and fails in another. This is the kind of divergence the proposal aims to remove.
“Producers MUST use absolute URIs” already makes raw JSON non-conformant for producers, but only implicitly, and the draft does not specify client behavior. Raw JSON also differs from the existing deployed forms. ipfs://ipfs/<cid> or an object-valued attributes has a single unambiguous reading, whereas a non-URI string can only be identified as JSON heuristically.
Suggested text (Resolving URIs, new paragraph):
“A metadata URI that is not an absolute URI, such as raw JSON, is not conformant. Producers MUST NOT return raw JSON from tokenURI or uri. Clients SHOULD NOT process it as a metadata document. Producers that build metadata onchain SHOULD return it as a data:application/json;base64, URI.”
Alternative. If you prefer to keep such tokens readable, raw JSON could instead be listed under Deployed forms. In that case the ERC should also define how clients recognize it, so that every client applies the same heuristic.
SCOPE: ERC-1155 {id} substitution and deployed practice
Section: Specification > Resolving URIs
For ERC-1155 tokens, clients MUST apply ERC-1155’s {id} substitution to the metadata URI and to string values in the document.
Issue. ERC-1155 (Metadata) requires {id} to be replaced with the token ID in hexadecimal form: lowercase, without a 0x prefix, and zero-padded to 64 characters. In practice, most ERC-1155 collections that use {id} do not conform. They serve their documents at the decimal ID instead.
Data. I sampled Ethereum mainnet: every contract that emitted TransferSingle in 60 evenly spaced windows of 1,000 blocks, from block 6,500,000 (late 2018) to 26,404,722. About 16% of these contracts return a {id} template. Of the 323 whose servers still respond, 181 (56%) are non-conformant, almost all because only the decimal ID resolves. For IPFS directory templates (ipfs://<cid>/{id}) the proportion is 68%. A likely cause is that directories are uploaded with files named 1, 2, 3 and cannot be changed afterwards.
A client that implements the requirement as written therefore fails on a majority of these collections. A client that tries the hexadecimal form first and falls back to the decimal ID resolves 319 of the 323.
Question. This may well be out of scope, since the rule is defined by ERC-1155. However, the draft restates it as a client requirement, so if you consider it in scope, I would suggest taking an explicit position, for example:
Suggested text (Resolving URIs, new paragraph):
“Producers SHOULD return a complete URI from uri(uint256) rather than a {id} template. A producer that returns a template MUST serve the document at the hexadecimal form defined by ERC-1155.”
Suggested text (Deployed forms, new item):
“A {id} template whose documents are served only at the decimal token ID. When the hexadecimal URI does not resolve to a metadata document, clients SHOULD retry once with the decimal token ID.”
The dataset (contract, token ID, template, and the result of both lookups) is available on request.
TECHNICAL: Non-conformant data: URI used as an example
Section: Specification > Resolving URIs; Test Cases
Issue. The example of an unencoded payload, data:application/json;utf8,{"name":"Example"}, is not a valid URI. The characters {, } and " are not permitted unencoded (RFC 3986, Section 2), and ;utf8 is not a valid parameter, since RFC 2397 (Section 3) requires the form attribute=value, for example ;charset=utf-8. Clients accepting it is reasonable. However, because the Test Cases table lists it without qualification, readers may take it as an example of a conformant URI.
Suggested change (Test Cases, first table):
OLD:
| `data:application/json;utf8,{"name":"Example"}` | `{"name":"Example"}` |
NEW:
| `data:application/json,%7B%22name%22%3A%22Example%22%7D` | `{"name":"Example"}` |
| `data:application/json;utf8,{"name":"Example"}` | Not conformant. Read as `{"name":"Example"}` by clients that accept it. |
Suggested text (Resolving URIs, after the data URI paragraph):
“Producers that do not use base64 MUST percent-encode the payload.”
QUESTION: Fragment handling in unencoded data: URIs
Section: Specification > Resolving URIs; Rationale
Clients … MUST percent-decode an unencoded payload exactly once before parsing it, as the Fetch Standard does for data: URLs.
Issue. This fixes the decoding step, but it does not say whether clients also remove everything from the first # onwards, as the Fetch Standard’s data: URL processor does. Every parser has to make this choice, and the draft currently leaves it to each implementation.
The choice matters in practice because an unescaped # is very common in non-base64 payloads that are not percent-encoded correctly (the ;utf8, style). It appears in names such as Creature #42, as the Rationale notes, and above all in onchain SVG embedded in the JSON, where hex colors like fill="#ff0000" are everywhere. Meanwhile, a fragment on a data: URI can also be intentional, for example on an HTML animation_url.
A strict rule that follows Fetch cuts these payloads at the first #, so they fail to parse. A lenient rule keeps them readable but departs from what browsers do. In my view, letting those tokens break is acceptable, since they are non-conformant anyway. What matters is that the choice is made explicitly in the ERC, so that all clients break, or succeed, on the same tokens.
Question. Is this intentionally left unspecified? If not, I would suggest stating the rule and pinning it with a test case, for example for the strict reading:
Suggested text (Resolving URIs, after the data URI paragraph):
“Clients MUST remove the fragment, starting at the first #, before decoding an unencoded payload, as the Fetch Standard does. Producers MUST percent-encode # in an unencoded payload as %23.”
Suggested test case (Test Cases, first table):
| `data:application/json;utf8,{"name":"Creature #42"}` | Not conformant. The payload ends at `#` and does not parse. |
SECURITY: Integrity of content fetched through gateways
Section: Specification > Resolving URIs; Security Considerations
Issue. The draft permits clients to “fetch ipfs and ar content through any gateway”, and the Security Considerations rely on content addressing (“Content-addressed URIs change only when the contract returns a new one”). That property holds only if the content is verified. A gateway can return bytes that do not match the requested CID.
Suggested text (Security Considerations, new item):
“A gateway can return content that does not match the requested CID. Clients that fetch ipfs content through a gateway they do not operate SHOULD verify it against the CID, for example by requesting raw blocks or a CAR file from a trustless gateway, and SHOULD otherwise treat it as unverified.”
INFORMATIONAL: URIs in image_data
Section: Specification > Other fields; Deployed forms
A notable share of deployed tokens place a URI in image_data, likely because OpenSea has historically accepted URIs there. As image_data is already a legacy field, no change is necessary. If Deployed forms is intended to be exhaustive, this case could be added to it.
I have a few further minor comments (media type detection, IPFS gateway URLs as a deployed form, and additional test vectors) and can follow up on them separately if useful. I am also happy to open a PR against the draft for any of the suggested text above.