---
eip: 2942
label: ERC-2942
title: EthPM URI Specification
status: Stagnant
type: Standards Track
category: ERC
created: 2020-09-04
requires: 2678
official: https://eips.ethereum.org/EIPS/eip-2942
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2942.md
canonical: https://eips.huatuo.xyz/eip-2942/
lang: en
tldr: "Defines `ethpm://` URIs that name an EthPM package registry, a package, a specific release, or a single asset inside it in one string, so tools can install and share smart-contract packages easily."
tags: [ethpm, packages, uri, tooling, registry]
---

# ERC-2942: EthPM URI Specification

> A custom URI scheme to identify an EthPM registry, package, release, or specific contract asset within a release.

**TL;DR:** Defines `ethpm://` URIs that name an EthPM package registry, a package, a specific release, or a single asset inside it in one string, so tools can install and share smart-contract packages easily.

## What problem does it solve?

EthPM is a package-management system for smart contracts: packages (ABIs, bytecode, deployment addresses, sources) are described by a manifest ([EIP-2678](/eip-2678/)) and published to on-chain registries ([ERC-1319](/eip-1319/)). To install or point someone at a package, a user had to supply several separate facts: which chain, which registry contract, which package name, which version.

ERC-2942 packs all of that into a single URI, the same way `https://` or `git+ssh://` URLs identify resources elsewhere.

## How it works

The general shape is:

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

| Part | Required | Meaning |
| --- | --- | --- |
| `scheme` | yes | `ethpm` or `erc1319` (future registry ERCs may add schemes) |
| `registry_address` | yes | an ENS name or a checksummed `0x` address of the registry |
| `chain_id` | no | chain the registry lives on; defaults to `1` (mainnet) |
| `package_name` | no | name of the package |
| `package_version` | no | release version; URL-unsafe characters must be percent-escaped |
| `json_pointer` | no | an RFC 6901 JSON pointer to one asset inside the release manifest |

Each optional part narrows the target: registry → package → release → asset. If the version is omitted and several releases exist, tools should not guess (semver is not enforced) and should ask the user to choose.

## Sample code

Example URIs (addresses and names are placeholders):

```text
ethpm://0x1234...AbCd                                   registry on mainnet
ethpm://0x1234...AbCd:5/owned                           package "owned" on chain 5
ethpm://packages.eth/dai@1.0.0                          release via an ENS-named registry
ethpm://packages.eth:1/dai@1.0.0/contractTypes/DSToken/abi   one asset in the release
```

A minimal parser in TypeScript:

```ts
const RE = /^(ethpm|erc1319):\/\/([^/:]+)(?::(\d+))?(?:\/([^@/]+)(?:@([^/]+)(\/.*)?)?)?$/;

function parseEthpmUri(uri: string) {
  const m = RE.exec(uri);
  if (!m) throw new Error("not an EthPM URI");
  const [, scheme, registry, chainId, pkg, version, pointer] = m;
  return {
    scheme,
    registry,
    chainId: chainId ? Number(chainId) : 1,   // default: mainnet
    pkg,
    version: version && decodeURIComponent(version),
    pointer,                                   // JSON pointer, e.g. "/contractTypes/X/abi"
  };
}
```

## Things to know

- Status is **Stagnant**. EthPM itself saw limited adoption, and support in the tools the spec lists (Brownie, Truffle, EthPM CLI) should be checked before relying on it.
- Using an ENS name as the registry ([EIP-137](/eip-137/)) is convenient but means trusting whoever controls the name: it can be repointed to a different registry. Use a checksummed address when integrity matters.
- A URI that pins registry, package and version generally identifies an immutable release; leaving parts out makes it a moving target.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2942
