---
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/ko/eip-1577/
lang: ko
tldr: ENS 리졸버에 contenthash 레코드를 추가해, 이름이 자기 기술형 multicodec 형식으로 IPFS, Swarm 등 여러 네트워크의 콘텐츠를 가리킬 수 있게 한다.
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:** ENS 리졸버에 contenthash 레코드를 추가해, 이름이 자기 기술형 multicodec 형식으로 IPFS, Swarm 등 여러 네트워크의 콘텐츠를 가리킬 수 있게 한다.

## 어떤 문제를 해결하나요?

지갑과 브라우저는 ENS 이름을 IPFS나 Swarm 같은 분산 스토리지에 호스팅된 웹사이트로 해석하기 시작했습니다. 이전의 리졸버 필드(`content`와 `multihash`)는 해시가 *어느* 네트워크의 것인지 명확히 알려 주지 않아 앱은 추측해야 했고, 이름 소유자도 자기 콘텐츠가 어떻게 로드될지 확신할 수 없었습니다.

ERC-1577은 이를 값 자체에 프로토콜 식별자를 담은 하나의 필드 `contenthash`로 대체합니다.

## 어떻게 동작하나요?

- 이 필드를 지원하는 리졸버는 [ERC-165](/eip-165/)의 `supportsInterface(0xbc1c58d1)`에서 `true`를 반환합니다.
- `contenthash(node)`는 [multicodec](https://github.com/multiformats/multicodec) 형식의 원시 바이트를 반환합니다.

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

- IPFS(`0xe3`)와 Swarm(`0xe4`)에서 값은 베이스 접두사가 없는 CIDv1입니다.

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

- 클라이언트는 먼저 프로토콜 코드를 읽고, 지원한다면 일치하는 네트워크로 주소를 해석해야 합니다(MUST).
- 이전의 `content`와 `multihash` 필드는 더 이상 쓰이지 않습니다. 명세는 최소 2019년 3월 31일까지의 유예 기간을 요구했으며, 그동안 클라이언트는 그 필드로 폴백했습니다.

명세의 IPFS 예시를 분해하면 다음과 같습니다.

| 바이트 | 의미 |
| --- | --- |
| `e3 01` | IPFS 네임스페이스(`0xe3`을 uvarint로 표현한 것) |
| `01` | CID 버전 1 |
| `70` | 콘텐츠 타입 dag-pb |
| `12 20` | sha2-256, 32바이트 다이제스트 |
| `29f2…3f1f` | 해시 |

## 샘플 코드

명세의 예시입니다.

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

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

ethers v6로 이름의 콘텐츠 해시를 읽는 예입니다. 흔한 프로토콜은 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")));
```

리졸버 컨트랙트 내부:

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

## 알아둘 점

- EIP 저장소에서의 상태는 **Stagnant**이지만, `contenthash`는 ENS 리졸버와 ENS를 지원하는 게이트웨이·브라우저가 분산 웹사이트에 사용하는 레코드입니다.
- 인코딩만 표준화되어 있습니다. 클라이언트가 실제로 콘텐츠를 가져올 수 있는지는 해당 프로토콜 지원 여부에 달려 있습니다.
- 값을 인코딩할 때는 바이트를 직접 조립하지 말고 라이브러리(예: 명세가 링크한 `content-hash` 패키지)를 사용하세요.
- 이름 해석 자체는 [ENS (EIP-137)](/eip-137/)가 정의하며, 텍스트 레코드는 [EIP-634](/eip-634/)에 있습니다.


---

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