---
eip: 2520
label: ERC-2520
title: Multiple contenthash records for ENS
status: Stagnant
type: Standards Track
category: ERC
created: 2020-02-18
requires: 1577
official: https://eips.ethereum.org/EIPS/eip-2520
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2520.md
canonical: https://eips.huatuo.xyz/eip-2520/
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]
---

# ERC-2520: Multiple contenthash records for ENS

> ENS support for multiple contenthash records on a single ENS name.

**TL;DR:** Extends the ENS contenthash record so one name can point to content on several hosting systems at once (IPFS, Swarm, Onion…), keyed by protocol.

## What problem does it solve?

[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.

ERC-2520 lets a resolver store one contenthash per protocol, plus a default, so different applications can each fetch the record they understand.

## How it works

The resolver keeps the original EIP-1577 functions and adds overloads with a `proto` argument:

- `setContenthash(node, proto, hash)` stores a hash for that protocol. Calling the original two-argument version stores the **default** record.
- `contenthash(node, proto)` returns the hash for that protocol. The original one-argument version returns the default record.
- A resolver that supports this returns `true` from `supportsInterface(0x6de03e07)` ([ERC-165](/eip-165/)).

Guidance for clients:

- An app that supports only one system (for example an IPFS gateway) **should** ask for the protocol-specific record.
- An app that supports several systems (the spec's example is MetaMask) **should** ask for the default record, exactly as with EIP-1577.

Multiple records per protocol and priority ordering are deliberately not supported, to keep the design simple.

## Sample code

Interface and a minimal resolver, following the spec's reference implementation (no access control, for illustration only):

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

contract MultiContentHashResolver {
    bytes4 constant MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;
    event ContenthashChanged(bytes32 indexed node, bytes hash);

    mapping(bytes32 => mapping(bytes => bytes)) private hashes;

    // In production, restrict to the name's owner (`authorised(node)`).
    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {
        hashes[node][proto] = hash;
        emit ContenthashChanged(node, hash);
    }

    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {
        return hashes[node][proto];
    }

    function supportsInterface(bytes4 id) external pure returns (bool) {
        return id == MULTI_CONTENT_HASH_INTERFACE_ID;
    }
}
```

## Things to know

- **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.
- The spec does not define the exact encoding of the `proto` key; implementers would need to agree on it out of band.
- 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.
- Being an overload, it is backwards compatible: older clients keep working and simply receive the default record.


---

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