ERC-1577 ENS contenthash field (contenthash field for ENS)
Stagnant · Names & metadata · created 2018-11-13
A standard that adds a contenthash field to ENS resolvers so that a single ENS name can point to content on decentralized storage systems such as IPFS and Swarm.
Why it is needed
Applications such as Metamask and Status wanted to resolve ENS names to content stored on IPFS or Swarm, but each decentralized storage system stores content and addresses it differently. With only the existing content and multihash fields, applications had no reliable way to know which protocol's address a value represented, and domain owners could not guarantee how a value they registered would be interpreted. Without a standardized field, each app would have to guess how to interpret the value in its own way, and compatibility problems would recur every time a new storage protocol was added.
In depth
The contenthash field and interface declaration
A new field called contenthash is introduced to ENS resolvers. A resolver that supports this field MUST return true when its supportsInterface function is called with the argument 0xbc1c58d1. This lets applications check in advance whether a given resolver supports contenthash.
Multicodec-based encoding structure
The value returned by contenthash MUST be expressed in a machine-readable multicodec format. The format is <protoCode uvarint><value []byte>, where the protocol code is written as a variable-length integer (uvarint) at the front, followed by the actual value bytes. The protoCodes and their meanings are defined in the multiformats/multicodec repository. Applications must determine what kind of address is encoded by looking at this protoCode and, if supported, MUST interpret it according to that protocol's method.
CID encoding for IPFS and Swarm content
Values with a protoCode of 0xe3 (IPFS) or 0xe4 (Swarm) are encoded as a v1 CID without the base prefix. The structure is <protoCode uvarint><cid-version><multicodec-content-type><multihash-content-address>. For example, IPFS concatenates CID version 1 (0x01), content type dag-pb (0x70), hash function sha2-256 (0x12), hash length 32 bytes (0x20), and the hash value, producing binary in the form 0xe3010170122029f2..., represented in text as ipfs://Qm... Swarm uses content type swarm-manifest (0xfa) and hash function keccak256 (0x1b), producing the form 0xe40101fa011b20..., represented in text as bzz://...
Deprecation of content and multihash, and the grace period
The existing content and multihash fields are deprecated. However, a grace period MUST be provided to give name holders who have already registered an IPFS or Swarm hash in the content field time to update. If a resolver does not support the multihash interface, it should check whether it supports the content interface, and if so, SHOULD interpret that value contextually. This provision MUST remain in place until at least March 31, 2019.
Implementations
A new resolver supporting contenthash (PublicResolver.sol) was developed and deployed at mainnet address 0xd3ddccdd3b25a8a7423b5bee360a42146eb4baf3 and Ropsten address 0xde469c7106a9fbc3fb98912bb00be983a89bddca. Separate JavaScript and Python libraries for encoding and decoding contenthash values also exist.
Proposal status
This ERC is in Stagnant status, a proposal that has stalled without active discussion.