---
eip: 7087
label: ERC-7087
title: MIME type for Web3 URL in Auto Mode
status: Draft
type: Standards Track
category: ERC
created: 2023-05-28
requires: 6860
official: https://eips.ethereum.org/EIPS/eip-7087
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7087.md
canonical: https://eips.huatuo.xyz/eip-7087/
lang: en
tldr: "Draft extension to web3:// URLs that adds mime.* query parameters, so data returned by ordinary contracts in auto mode is served with the right Content-Type."
tags: [web3-url, mime, content-type, dapp, hosting]
---

# ERC-7087: MIME type for Web3 URL in Auto Mode

> Add ability to indicate or determine the MIME type of the data returned by a Web3 URL in auto mode

**TL;DR:** Draft extension to web3:// URLs that adds mime.* query parameters, so data returned by ordinary contracts in auto mode is served with the right Content-Type.

## What problem does it solve?

`web3://` URLs ([ERC-6860](/eip-6860/), the revision of [ERC-4804](/eip-4804/)) let a browser or gateway fetch data straight from a contract. In **auto mode**, which applies to any contract that doesn't declare otherwise, the URL path is turned into an ABI function call, e.g. `/tokenURI/100`.

The returned bytes come with no type information. A browser that doesn't know an SVG is an SVG, or that a string is JSON, may display it wrongly or not at all. Contracts written for `web3://` can advertise a type, but the vast majority of existing contracts (NFTs, on-chain art) were never designed for it. ERC-7087 lets the **URL** say what type the result is.

## How it works

Three new query parameters (the last one present wins):

| Parameter | Effect |
| --- | --- |
| `mime.content=<type>` | Use this MIME type (RFC 6838 syntax, URL-encoded, e.g. `image/svg%2Bxml`) as `Content-Type`. Invalid syntax is an error. |
| `mime.type=<ext>` | Derive the MIME type from a file extension such as `svg` or `png`. An unknown extension is an error. |
| `mime.dataurl` | Treat the returned bytes as an RFC 2397 `data:` URL: decode it, serve the decoded body, and use the MIME type it declares. Unparseable data is an error. |

Rules of precedence:

- No `mime.*` parameter → `Content-Type` is decided by ERC-6860 as before.
- If the ERC-6860 `returns` parameter is present, `mime.*` is ignored.

Adding parameters is safe because in auto mode the query string is not part of the calldata sent to the contract.

## Sample code

Example URLs from the spec:

```text
# Force SVG for a function returning raw SVG text
web3://0x91cf36c92feb5c11d3f5fe3e8b9e212f7472ec14/accessorizedImageOf/1289?mime.content=image/svg%2Bxml

# Same, using a file extension
web3://0x91cf36c92feb5c11d3f5fe3e8b9e212f7472ec14/accessorizedImageOf/1289?mime.type=svg

# tokenURI returns 'data:application/json,["xx"]' -> served as JSON body ["xx"]
web3://0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7/tokenURI/100?mime.dataurl
```

How a gateway might choose the header (TypeScript sketch):

```ts
function contentType(q: URLSearchParams, body: Uint8Array) {
  if (q.has("returns") || q.has("returnTypes")) return { type: "application/json", body };
  const keys = [...q.keys()].filter(k => k.startsWith("mime."));
  const last = keys.at(-1);
  if (last === "mime.content") return { type: q.get(last)!, body };
  if (last === "mime.type") return { type: lookupByExtension(q.get(last)!), body };
  if (last === "mime.dataurl") return decodeDataUrl(body); // { type, body }
  return null; // fall back to ERC-6860 default handling
}
```

## Things to know

- **Status: Draft**, as is the underlying ERC-6860.
- Major **XSS risk**: anyone who can influence a string a contract returns could craft a link with `mime.content=text/html` that runs their script under a trusted-looking web3 hostname, reading browser storage or triggering wallet prompts. The spec recommends discouraging auto-mode websites and documenting this vector.
- Contracts that control their own output should signal the type themselves (manual mode, or the [ERC-6944](/eip-6944/) 5219 mode) rather than rely on URL parameters.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7087
