---
eip: 1577
label: ERC-1577
title: contenthash field for ENS
status: Stagnant
type: Standards Track
category: ERC
created: 2018-11-13
official: https://eips.ethereum.org/EIPS/eip-1577
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1577.md
canonical: https://eips.huatuo.xyz/eip-1577/
lang: en
tldr: Adds a contenthash record to ENS resolvers so a name can point to content on IPFS, Swarm and other networks using a self-describing multicodec format.
tags: [ens, ipfs, swarm, resolver, dweb]
---

# ERC-1577: contenthash field for ENS

> This EIP introduces the new contenthash field for ENS resolvers, allowing for a better defined system of mapping names to network and content addresses. Additionally the content and multihash fields are deprecated.

**TL;DR:** Adds a contenthash record to ENS resolvers so a name can point to content on IPFS, Swarm and other networks using a self-describing multicodec format.

## What problem does it solve?

Wallets and browsers began resolving ENS names to websites hosted on decentralised storage such as IPFS and Swarm. The older resolver fields (`content` and `multihash`) did not clearly say *which* network a hash belonged to, so apps had to guess, and name owners could not be sure how their content would be loaded.

ERC-1577 replaces them with one field, `contenthash`, whose value carries its own protocol identifier.

## How it works

- A resolver supporting the field returns `true` from [ERC-165](/eip-165/) `supportsInterface(0xbc1c58d1)`.
- `contenthash(node)` returns raw bytes in [multicodec](https://github.com/multiformats/multicodec) form:

```text
<protoCode uvarint><value []byte>
```

- For IPFS (`0xe3`) and Swarm (`0xe4`), the value is a CIDv1 without a base prefix:

```text
<protoCode uvarint><cid-version><multicodec-content-type><multihash-content-address>
```

- Clients MUST read the protocol code first and resolve the address with the matching network, if they support it.
- The old `content` and `multihash` fields are deprecated. The spec required a grace period, until at least 31 March 2019, during which clients fell back to them.

Breaking down the spec's IPFS example:

| Bytes | Meaning |
| --- | --- |
| `e3 01` | IPFS namespace (`0xe3` as a uvarint) |
| `01` | CID version 1 |
| `70` | content type dag-pb |
| `12 20` | sha2-256, 32-byte digest |
| `29f2…3f1f` | the hash |

## Sample code

The spec's examples:

```text
IPFS  binary: 0xe3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f
      text:   ipfs://QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4

Swarm binary: 0xe40101fa011b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
      text:   bzz://d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
```

Reading a name's content hash with ethers v6, which decodes common protocols to a URL:

```ts
import { JsonRpcProvider, Contract, namehash } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const resolver = await provider.getResolver("vitalik.eth");
console.log(await resolver?.getContentHash()); // e.g. "ipfs://..."

// Or call the resolver directly for the raw bytes
const r = new Contract(resolver!.address,
  ["function contenthash(bytes32 node) view returns (bytes)"], provider);
console.log(await r.contenthash(namehash("vitalik.eth")));
```

Inside a resolver contract:

```solidity
function contenthash(bytes32 node) external view returns (bytes memory);
event ContenthashChanged(bytes32 indexed node, bytes hash);
```

## Things to know

- **Status: Stagnant** in the EIP repository, but `contenthash` is the record that ENS resolvers and ENS-aware gateways and browsers use for decentralised websites.
- Only the encoding is standardised; whether a client can actually fetch the content depends on its support for that protocol.
- Use a library (for example the `content-hash` packages the spec links) to encode values instead of assembling bytes by hand.
- Name resolution itself is defined by [ENS (EIP-137)](/eip-137/); text records are in [EIP-634](/eip-634/).


---

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