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-2942, which proposes a custom URI scheme for the Ethereum Package Manager (EthPM).

This explanation is based on the following specification.

For other Ethereum improvement proposals, see the following page.

Overview

ERC-2942 proposes a custom URI scheme for identifying EthPM registries, packages, releases, and specific contract assets.

The scheme allows users and tools to reference EthPM resources with a single compact string, simplifying interaction with the package management ecosystem.

Motivation

Unique identification through Uniform Resource Identifiers (URIs) simplifies installation, publication, and distribution within EthPM.

A consistent format for identifying registries, packages, and releases offers several benefits.

  • Command-line tools and decentralized applications can handle package references more easily.
  • Developers and users can locate the relevant EthPM resources quickly.
  • Package references can be reused consistently across environments.

The proposed scheme improves convenience and interoperability throughout the package management process.

Specification

URI Format

The EthPM URI scheme has the following structure.

text
scheme://registry_address[:chain_id][/package_name[@package_version[/json_pointer]]]

A URI identifies an EthPM registry, package, release, or a specific asset within a release.

scheme

This field is required.

It must be either ethpm or erc1319. If a new EthPM registry specification is introduced through the ERC process, its ERC number may also be used as a scheme.

registry_address

This field is required.

It specifies either an ENS name or an Ethereum address with a 0x prefix and a checksum.

An ENS name is useful when flexibility is desirable, such as when the referenced registry may change. When security is important, a checksummed address is preferable because resolution does not depend on trusting the ENS name owner.

chain_id

This field is optional.

It specifies the integer chain ID of the blockchain on which the registry exists. When omitted, the default is Ethereum mainnet, with chain ID 1.

package_name

This optional field specifies the package name as a string.

package_version

This optional field specifies the package version as a string.

Characters that are not URL-safe, such as spaces or slashes, must be escaped appropriately.

Semantic versioning (SemVer) is not mandatory. If a version is omitted, tools should avoid guessing which version the user intended and instead present the available versions.

json_pointer

This optional field identifies a particular asset within the package.

It must conform to the JSON Pointer specification and identify an asset that actually exists in the specified package version.

Together, these fields provide a compact and consistent representation of EthPM resource references across tools and interfaces.

Additional Considerations

Many operations within EthPM, including package installation, registry selection, and package distribution, become simpler when resources can be represented by a single string.

The URI scheme provides a consistent way to identify resources on mainnet and test networks.

Potential benefits include the following.

  • A format that is easier for beginners to understand.
  • Less configuration for frameworks and other tools.
  • Clearer references that package authors can share with recipients.

These properties can make adopting and using EthPM easier.

Reference Implementations

Security

EthPM URIs are generally intended to reference immutable assets. However, care is needed when an ENS name is used as the registry address.

The owner of an ENS name can update its resolution to point to a different address. Consequently, an unchanged URI may resolve to a different registry from the one originally intended.

Where reliability and security are important, the specification recommends a direct 0x-prefixed address instead of an ENS name. This avoids changes caused by ENS resolution, although the immutability of the referenced asset also depends on the registry and resource implementation.

Citation

Nick Gheorghita (@njgheorghita), Piper Merriam (@pipermerriam), g. nicholas d'andrea (@gnidan), Benjamin Hauser (@iamdefinitelyahuman), "ERC-2942: EthPM URI Specification [DRAFT]," Ethereum Improvement Proposals, no. 2942, September 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2942.

Conclusion

ERC-2942 proposes a consistent URI scheme for identifying EthPM registries, packages, releases, and individual assets.