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 explains ERC-6821, a proposal for mapping ENS names to contract addresses in Web3 URLs.

The following specification is the basis for this explanation.

For other Ethereum improvement proposals, see the following page.

Overview

The standard defines a mapping from the Ethereum Name Service (ENS) to addresses defined by ERC-4804.

ERC-4804 defines a mechanism for accessing smart contracts using URLs such as web3://cardene.eth/. A path such as web3://cardene.eth/article/qiita can also be used to pass parameters. For details, see the following article.

ERC-4804: Calling Smart Contracts Using HTTP-Style Web3 URLs

Motivation

ERC-4804 defines URIs beginning with web3:// that identify smart contracts. ERC-6821 proposes a mechanism for associating these URIs with ENS names.

Specification

Given the contractName and chainid from a web3:// URI, the contract address is resolved as follows.

  1. Look up the contentcontract text record using the ENS resolver on the specified chainid.
    • Return an error if the chain has no ENS deployment or an invalid Ethereum address is encountered.
  2. If the contentcontract text record does not exist, use the address associated with the name according to ERC-137.
  3. If the resulting address is the zero address (0x0000000000000000000000000000000000000000), return an address not found error.
  4. The contentcontract text record can contain either a hexadecimal Ethereum address prefixed with 0x or an ERC-3770 chain-specific address.
    • If it contains an ERC-3770 address, the chain used for the message call is overridden by the chain identified by that address's short name, such as eth or arb.

For more information about ERC-137, see the following article.

ERC-137: How ENS Associates Human-Readable Names with Addresses

For more information about ERC-3770, see the following article.

ERC-3770: Adding Chain Short Names to Addresses

Additional Considerations

Following ERC-4804's design principles, the standard uses a human-readable contentcontract text record containing an ERC-3770 chain-specific address instead of contenthash.

Using a text record also leaves room for additional fields such as TTL (Time to Live).

Citation

Qi Zhou (@qizhou), Qiang Zhu (@qzhodl), "ERC-6821: Support ENS Name for Web3 URL [DRAFT]," Ethereum Improvement Proposals, no. 6821, April 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6821.

Conclusion

ERC-6821 defines how ENS names resolve to the smart contract addresses used by Web3 URLs.