{"eip":2520,"title":"Multiple contenthash records for ENS","description":"ENS support for multiple contenthash records on a single ENS name.","authors":["Filip Štamcar (@filips123)"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2020-02-18","requires":[1577],"discussionsTo":"https://github.com/ethereum/EIPs/issues/2393","repo":"ERCs","label":"ERC-2520","officialUrl":"https://eips.ethereum.org/EIPS/eip-2520","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2520.md","url":"https://eips.huatuo.xyz/eip-2520/","tldr":{"en":"Extends the ENS contenthash record so one name can point to content on several hosting systems at once (IPFS, Swarm, Onion…), keyed by protocol.","ja":"ENS の contenthash レコードを拡張し、1 つの名前が複数のホスティングシステム（IPFS、Swarm、Onion など）上のコンテンツを、プロトコルをキーにして同時に指せるようにする。","ko":"ENS의 contenthash 레코드를 확장해, 하나의 이름이 프로토콜을 키로 여러 호스팅 시스템(IPFS, Swarm, Onion 등)의 콘텐츠를 동시에 가리킬 수 있게 한다.","zh":"扩展 ENS 的 contenthash 记录，使一个名称可以按协议为键，同时指向多个托管系统（IPFS、Swarm、Onion 等）上的内容。"},"tags":["ens","contenthash","ipfs","swarm","resolver"],"explainers":{"en":{"lang":"en","tldr":"Extends the ENS contenthash record so one name can point to content on several hosting systems at once (IPFS, Swarm, Onion…), keyed by protocol.","tags":["ens","contenthash","ipfs","swarm","resolver"],"related":[1577,137,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2520/","markdown":"## What problem does it solve?\n\n[EIP-1577](/eip-1577/) gave ENS names a `contenthash` record, which tells a browser or gateway where a decentralised website lives (an IPFS CID, a Swarm hash, and so on). But a name can hold only **one** contenthash. A site owner who publishes to both IPFS and Swarm has to pick one, and a gateway that only speaks Swarm cannot use an IPFS record.\n\nERC-2520 lets a resolver store one contenthash per protocol, plus a default, so different applications can each fetch the record they understand.\n\n## How it works\n\nThe resolver keeps the original EIP-1577 functions and adds overloads with a `proto` argument:\n\n- `setContenthash(node, proto, hash)` stores a hash for that protocol. Calling the original two-argument version stores the **default** record.\n- `contenthash(node, proto)` returns the hash for that protocol. The original one-argument version returns the default record.\n- A resolver that supports this returns `true` from `supportsInterface(0x6de03e07)` ([ERC-165](/eip-165/)).\n\nGuidance for clients:\n\n- An app that supports only one system (for example an IPFS gateway) **should** ask for the protocol-specific record.\n- An app that supports several systems (the spec's example is MetaMask) **should** ask for the default record, exactly as with EIP-1577.\n\nMultiple records per protocol and priority ordering are deliberately not supported, to keep the design simple.\n\n## Sample code\n\nInterface and a minimal resolver, following the spec's reference implementation (no access control, for illustration only):\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract MultiContentHashResolver {\n    bytes4 constant MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;\n    event ContenthashChanged(bytes32 indexed node, bytes hash);\n\n    mapping(bytes32 =\u003e mapping(bytes =\u003e bytes)) private hashes;\n\n    // In production, restrict to the name's owner (`authorised(node)`).\n    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {\n        hashes[node][proto] = hash;\n        emit ContenthashChanged(node, hash);\n    }\n\n    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {\n        return hashes[node][proto];\n    }\n\n    function supportsInterface(bytes4 id) external pure returns (bool) {\n        return id == MULTI_CONTENT_HASH_INTERFACE_ID;\n    }\n}\n```\n\n## Things to know\n\n- **Status: Stagnant**, and it builds on [EIP-1577](/eip-1577/), which is itself Stagnant. The standard ENS public resolver does not implement this extension, so most tools will only see the single default record.\n- The spec does not define the exact encoding of the `proto` key; implementers would need to agree on it out of band.\n- The security considerations section of the spec is left as \"TBD\". As with any resolver, writes must be restricted to the name's owner or approved operators.\n- Being an overload, it is backwards compatible: older clients keep working and simply receive the default record.\n"},"ja":{"lang":"ja","tldr":"ENS の contenthash レコードを拡張し、1 つの名前が複数のホスティングシステム（IPFS、Swarm、Onion など）上のコンテンツを、プロトコルをキーにして同時に指せるようにする。","tags":["ens","contenthash","ipfs","swarm","resolver"],"related":[1577,137,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2520/","markdown":"## 何を解決するのか\n\n[EIP-1577](/eip-1577/) は ENS 名に `contenthash` レコードを与え、ブラウザーやゲートウェイに分散型ウェブサイトの場所（IPFS の CID、Swarm のハッシュなど）を伝えられるようにしました。しかし、1 つの名前が持てる contenthash は**1 つ**だけです。IPFS と Swarm の両方に公開するサイト所有者はどちらかを選ばなければならず、Swarm しか扱えないゲートウェイは IPFS のレコードを使えません。\n\nERC-2520 は、リゾルバーがプロトコルごとに 1 つの contenthash とデフォルトを保存できるようにし、アプリケーションがそれぞれ理解できるレコードを取得できるようにします。\n\n## 仕組み\n\nリゾルバーは元の EIP-1577 の関数を維持したまま、`proto` 引数を持つオーバーロードを追加します。\n\n- `setContenthash(node, proto, hash)` は、そのプロトコルのハッシュを保存します。元の 2 引数版を呼ぶと**デフォルト**のレコードが保存されます。\n- `contenthash(node, proto)` は、そのプロトコルのハッシュを返します。元の 1 引数版はデフォルトのレコードを返します。\n- これをサポートするリゾルバーは、`supportsInterface(0x6de03e07)`（[ERC-165](/eip-165/)）で `true` を返します。\n\nクライアント向けのガイダンス:\n\n- 1 つのシステムのみをサポートするアプリ（たとえば IPFS ゲートウェイ）は、プロトコル固有のレコードを要求**すべき**です。\n- 複数のシステムをサポートするアプリ（仕様の例は MetaMask）は、EIP-1577 と同様に、デフォルトのレコードを要求**すべき**です。\n\n設計を単純に保つため、プロトコルごとの複数レコードや優先順位付けは意図的にサポートされていません。\n\n## サンプルコード\n\nインターフェースと最小限のリゾルバー。仕様のリファレンス実装に沿っています（アクセス制御なし、説明用）:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract MultiContentHashResolver {\n    bytes4 constant MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;\n    event ContenthashChanged(bytes32 indexed node, bytes hash);\n\n    mapping(bytes32 =\u003e mapping(bytes =\u003e bytes)) private hashes;\n\n    // In production, restrict to the name's owner (`authorised(node)`).\n    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {\n        hashes[node][proto] = hash;\n        emit ContenthashChanged(node, hash);\n    }\n\n    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {\n        return hashes[node][proto];\n    }\n\n    function supportsInterface(bytes4 id) external pure returns (bool) {\n        return id == MULTI_CONTENT_HASH_INTERFACE_ID;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant**。土台となる [EIP-1577](/eip-1577/) も Stagnant です。標準の ENS パブリックリゾルバーはこの拡張を実装していないため、ほとんどのツールからは単一のデフォルトレコードしか見えません。\n- 仕様は `proto` キーの具体的なエンコーディングを定めていません。実装者が帯域外で合意する必要があります。\n- 仕様のセキュリティに関する節は「TBD」のままです。どのリゾルバーでも同様に、書き込みは名前の所有者または承認済みオペレーターに限定する必要があります。\n- オーバーロードなので後方互換です。古いクライアントは引き続き動作し、単にデフォルトのレコードを受け取ります。\n"},"ko":{"lang":"ko","tldr":"ENS의 contenthash 레코드를 확장해, 하나의 이름이 프로토콜을 키로 여러 호스팅 시스템(IPFS, Swarm, Onion 등)의 콘텐츠를 동시에 가리킬 수 있게 한다.","tags":["ens","contenthash","ipfs","swarm","resolver"],"related":[1577,137,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2520/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-1577](/eip-1577/)은 ENS 이름에 `contenthash` 레코드를 주어, 브라우저나 게이트웨이에 탈중앙 웹사이트가 어디 있는지(IPFS CID, Swarm 해시 등) 알려 주게 했습니다. 하지만 이름 하나에는 contenthash를 **하나**만 담을 수 있습니다. IPFS와 Swarm에 모두 게시하는 사이트 소유자는 하나를 골라야 하고, Swarm만 지원하는 게이트웨이는 IPFS 레코드를 쓸 수 없습니다.\n\nERC-2520은 리졸버가 프로토콜별로 contenthash 하나와 기본값 하나를 저장하게 해, 애플리케이션이 각자 이해하는 레코드를 가져갈 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n리졸버는 기존 EIP-1577 함수를 그대로 유지하면서 `proto` 인자를 받는 오버로드를 추가합니다.\n\n- `setContenthash(node, proto, hash)`는 해당 프로토콜의 해시를 저장합니다. 기존 인자 두 개짜리 버전을 호출하면 **기본** 레코드가 저장됩니다.\n- `contenthash(node, proto)`는 해당 프로토콜의 해시를 반환합니다. 기존 인자 하나짜리 버전은 기본 레코드를 반환합니다.\n- 이를 지원하는 리졸버는 `supportsInterface(0x6de03e07)`([ERC-165](/eip-165/))에 대해 `true`를 반환합니다.\n\n클라이언트를 위한 지침:\n\n- 한 가지 시스템만 지원하는 앱(예: IPFS 게이트웨이)은 프로토콜별 레코드를 요청**해야 합니다**.\n- 여러 시스템을 지원하는 앱(스펙의 예시는 MetaMask)은 EIP-1577과 똑같이 기본 레코드를 요청**해야 합니다**.\n\n설계를 단순하게 유지하기 위해 프로토콜별 다중 레코드와 우선순위 정렬은 의도적으로 지원하지 않습니다.\n\n## 샘플 코드\n\n인터페이스와 최소 리졸버로, 스펙의 레퍼런스 구현을 따릅니다(접근 제어 없음, 설명용):\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract MultiContentHashResolver {\n    bytes4 constant MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;\n    event ContenthashChanged(bytes32 indexed node, bytes hash);\n\n    mapping(bytes32 =\u003e mapping(bytes =\u003e bytes)) private hashes;\n\n    // In production, restrict to the name's owner (`authorised(node)`).\n    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {\n        hashes[node][proto] = hash;\n        emit ContenthashChanged(node, hash);\n    }\n\n    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {\n        return hashes[node][proto];\n    }\n\n    function supportsInterface(bytes4 id) external pure returns (bool) {\n        return id == MULTI_CONTENT_HASH_INTERFACE_ID;\n    }\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant**이며, 마찬가지로 Stagnant인 [EIP-1577](/eip-1577/) 위에 만들어졌습니다. 표준 ENS 퍼블릭 리졸버는 이 확장을 구현하지 않으므로 대부분의 도구는 단일 기본 레코드만 보게 됩니다.\n- 스펙은 `proto` 키의 정확한 인코딩을 정의하지 않습니다. 구현자들이 오프체인에서 합의해야 합니다.\n- 스펙의 보안 고려 사항 절은 \"TBD\"로 남아 있습니다. 모든 리졸버와 마찬가지로 쓰기는 이름의 소유자나 승인된 운영자로 제한해야 합니다.\n- 오버로드이므로 하위 호환됩니다. 기존 클라이언트는 계속 동작하며 기본 레코드를 받을 뿐입니다.\n"},"zh":{"lang":"zh","tldr":"扩展 ENS 的 contenthash 记录，使一个名称可以按协议为键，同时指向多个托管系统（IPFS、Swarm、Onion 等）上的内容。","tags":["ens","contenthash","ipfs","swarm","resolver"],"related":[1577,137,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2520/","markdown":"## 它解决什么问题？\n\n[EIP-1577](/eip-1577/) 为 ENS 名称提供了 `contenthash` 记录，用来告诉浏览器或网关去中心化网站的位置（IPFS CID、Swarm 哈希等）。但一个名称只能保存**一个** contenthash。同时发布到 IPFS 和 Swarm 的网站所有者只能二选一，而只支持 Swarm 的网关无法使用 IPFS 记录。\n\nERC-2520 让解析器为每个协议存储一个 contenthash，外加一个默认值，这样不同的应用都可以获取各自能理解的记录。\n\n## 它如何运作\n\n解析器保留 EIP-1577 的原有函数，并增加带有 `proto` 参数的重载：\n\n- `setContenthash(node, proto, hash)` 为该协议存储一个哈希。调用原来的两参数版本则存储**默认**记录。\n- `contenthash(node, proto)` 返回该协议的哈希。原来的单参数版本返回默认记录。\n- 支持此功能的解析器在 `supportsInterface(0x6de03e07)`（[ERC-165](/eip-165/)）上返回 `true`。\n\n给客户端的指引：\n\n- 只支持一种系统的应用（例如 IPFS 网关）**应当**请求特定协议的记录。\n- 支持多种系统的应用（规范中的例子是 MetaMask）**应当**请求默认记录，与 EIP-1577 完全一样。\n\n为保持设计简单，有意不支持每个协议多条记录和优先级排序。\n\n## 示例代码\n\n接口和一个最小解析器，遵循规范的参考实现（无访问控制，仅作演示）：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract MultiContentHashResolver {\n    bytes4 constant MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;\n    event ContenthashChanged(bytes32 indexed node, bytes hash);\n\n    mapping(bytes32 =\u003e mapping(bytes =\u003e bytes)) private hashes;\n\n    // In production, restrict to the name's owner (`authorised(node)`).\n    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {\n        hashes[node][proto] = hash;\n        emit ContenthashChanged(node, hash);\n    }\n\n    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {\n        return hashes[node][proto];\n    }\n\n    function supportsInterface(bytes4 id) external pure returns (bool) {\n        return id == MULTI_CONTENT_HASH_INTERFACE_ID;\n    }\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant**，并且它建立在同为 Stagnant 的 [EIP-1577](/eip-1577/) 之上。标准的 ENS 公共解析器没有实现这一扩展，因此大多数工具只能看到单个默认记录。\n- 规范没有定义 `proto` 键的具体编码；实现者需要在链外就此达成一致。\n- 规范的安全考虑部分仍为「TBD」。与任何解析器一样，写入必须限制为该名称的所有者或获批准的运营者。\n- 由于是重载，它向后兼容：旧客户端继续工作，只会收到默认记录。\n"}}}
