ERC-2942 EthPM package URI scheme (EthPM URI Specification)
Stagnant · Names & metadata · created 2020-09-04
A specification that identifies an EthPM registry, package, release, and asset with a single string (URI). It simplifies the process of installing, deploying, and sharing packages.
Why it is needed
Installing or deploying a package in the EthPM ecosystem requires combining multiple pieces of information, including the registry address, chain, package name, version, and even a specific asset within the package. Without a common URI format, each tool or framework ends up representing this information differently, forcing users to learn a different input method for each tool and forcing package authors to define their own description method every time they deploy. Additionally, if information such as which chain the registry is on, or whether it is an ENS name or an address, is missing or ambiguous, there is a risk of referencing the wrong package. A standard format that can express everything from the registry down to a specific asset in a single string can reduce this confusion and redundant configuration.
In depth
Overall URI structure
The URI has the format scheme://registry_address[:chain_id][/package_name[@package_version[/json_pointer]]]. This specification assumes EIP-2678 (the EthPM v3 manifest specification) and is designed so that a single string can point to everything from the registry, to the package and release, down to a specific asset within the package.
scheme
scheme is a required field and must be either ethpm or erc1319. If a new version of the EthPM registry standard is later published through the ERC process, that ERC may also become a valid scheme.
registry_address
registry_address is a required field and should be an ENS name or a checksummed address beginning with 0x. An ENS name is suitable when mutability of the target asset is acceptable and the name owner can be implicitly trusted, while a 0x checksummed address is suitable when security matters more and trusting a name administrator is not acceptable.
chain_id
chain_id is an optional integer representing the id of the chain on which the registry is located. If omitted, the default is 1, i.e. mainnet.
package_name and package_version
package_name and package_version are both optional strings. If package_version contains characters that are not URL-safe, they must be percent-encoded. Since the ethpm spec does not strictly enforce semver, if package_version is omitted from the URI, tools should not guess a version arbitrarily in ambiguous situations, but should let the user choose from the list of available versions.
json_pointer
json_pointer is an optional field, a path pointing to a specific asset within a versioned package release. This path MUST follow the RFC 6901 JSON Pointer specification and MUST resolve to an asset that actually exists within the package.
Proposal status
This proposal is in Stagnant status, meaning discussion has stopped and it has not yet been finalized.
Things to watch out for
- Mutability of the ENS registry: Most EthPM URIs point to immutable assets, which guarantees the target has not been modified. However, when an ENS name is used as the registry address, that ENS name can be repointed to a different registry, in which case the immutability guarantee no longer holds.