Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-1062, which proposes registering and retrieving IPFS hashes through ENS.
This explanation translates, summarizes, and expands on the following specification.
For other EIPs, see https://cardene.dev/proposals.
Overview
ERC-1062 proposes a mapping between resources stored in IPFS (InterPlanetary File System) and ENS (Ethereum Name Service).
By integrating IPFS cryptographic hashes with the ENS Public Resolver, it provides functionality for setting and retrieving references to IPFS resources through ENS.
Developers and communities can build additional use cases, while users can access decentralized resources through human-readable ENS names. The proposal regards IPFS and ENS integration as a foundational technology for Web3 services.
Motivation
Fully decentralized web services need decentralized file storage. IPFS offers several relevant advantages.
- Managing and identifying large datasets: Content is identified using cryptographic hashes, supporting integrity verification.
- Efficient peer-to-peer distribution: IPFS distributes data through a P2P network, reducing reliance on centralized servers and potentially reducing bandwidth costs.
- Version management and deduplication: Content addressing supports deduplication and can be combined with version-tracking structures, improving storage efficiency.
These characteristics make IPFS suitable for integration with ENS. With compatible browser or gateway support, users can access IPFS content by entering an ENS name.
Specification
The IPFS identifiers discussed in the proposal use Base58 encoding, whereas Ethereum APIs represent binary data using hexadecimal strings. Registering and retrieving these identifiers therefore requires conversion between Base58 and hexadecimal.
A binary buffer bridges the two encodings.
- Decode the Base58 IPFS string into a binary buffer.
- Convert the buffer into hexadecimal and store it in the ENS contract.
- When retrieving the IPFS reference, read the hexadecimal value, convert it back into a buffer, and encode it as a Base58 string.
This associates ENS records with IPFS resources without losing the underlying identifier.
Implementation
The proposal requires two functions in the ENS Public Resolver.
- setMultihash: registers an IPFS hash for a specific ENS node.
- multihash: retrieves the registered IPFS hash.
setMultihash
function setMultihash(bytes32 node, bytes hash) public only_owner(node);Stores the IPFS hash for an ENS node. The Base58 identifier is converted to its binary representation, expressed as hexadecimal when interacting with the contract. Only the owner of the relevant node may call this function.
Parameters
- node: the 32-byte ENS node identifier corresponding to a name.
- hash: the IPFS hash represented as bytes.
multihash
function multihash(bytes32 node) public view returns (bytes);Retrieves the IPFS hash associated with an ENS node. The returned bytes can be encoded back into Base58 to obtain the corresponding IPFS resource identifier.
Parameter
- node: the 32-byte ENS node identifier.
Return Value
- bytes: the stored IPFS hash.
only_owner
modifier only_owner(bytes32 node);This modifier restricts operations to the owner of the specified ENS node, preventing unauthorized modification of other users' ENS records.
Parameter
- node: the ENS node identifier subject to access control.
Test Cases
The multihashes library is used to convert between IPFS Base58 representations and Ethereum hexadecimal representations. It supports encoding and decoding multihashes.
Converting Base58 to Hexadecimal
Convert the Base58 IPFS hash to a hexadecimal representation suitable for storing through the ENS contract.
import multihash from 'multihashes'
export const toHex = function(ipfsHash) {
let buf = multihash.fromB58String(ipfsHash);
return '0x' + multihash.toHexString(buf);
}- Use fromB58String to decode the string into a binary buffer.
- Convert the buffer to a hexadecimal string using toHexString.
- Add the 0x prefix and return the result.
Converting Hexadecimal to Base58
Convert the hexadecimal representation retrieved from ENS back to Base58.
import multihash from 'multihashes'
export const toBase58 = function(contentHash) {
let hex = contentHash.substring(2)
let buf = multihash.fromHexString(hex);
return multihash.toB58String(buf);
}- Remove the leading 0x prefix.
- Use fromHexString to decode the hexadecimal string into a buffer.
- Use toB58String to encode it as Base58.
These conversions enable interoperability between IPFS and ENS.
Reference Implementation
The mechanism was implemented as a browser extension. With the extension installed, users could enter an ENS name in the browser address bar much like a DNS name and access decentralized IPFS content.
The intended user experience is:
- Enter an ENS name as a URL, for example vitalik.eth.
- The extension automatically resolves the corresponding IPFS hash.
- Decentralized content is displayed in the browser.
Reference implementation repository:
Portal Network browser extension
The repository contains the extension implementation described by the proposal and can serve as a reference for other use cases. This is a historical proposal and example, not a claim of current browser support.
Citation
Phyrex Tsai phyrex@portal.network, Portal Network Team, "ERC-1062: Formalize IPFS hash into ENS(Ethereum Name Service) resolver [DRAFT]," Ethereum Improvement Proposals, no. 1062, May 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1062.
Conclusion
ERC-1062 proposes resolver functionality for registering and retrieving IPFS hashes through ENS.
Further reading and author links:




