EIPs Explained

ERC-1319 · Stagnant · ERC · 2018-08-13

ERC-1319: Smart Contract Package Registry Interface

A common read/write interface for on-chain smart contract package registries, so tools like an Ethereum package manager could install versioned packages from any registry.

What problem does it solve?

Developers reuse libraries like Ownable or token templates the way web developers use npm. The EthPM project ran a single, centralised package registry. The authors wanted many independent registries (each possibly named via ENS, e.g. packages.zeppelin.eth) that tooling could query the same way.

ERC-1319 defines that minimal common interface. Each registry can have its own business logic (who may publish, fees, etc.) but exposes the same endpoints, so a CLI or library can resolve "package X version Y" against any of them.

How it works

The data model:

  • A registry contract holds many packages.
  • A package has a unique name and bytes32 package id, and a list of releases.
  • A release is identified by a bytes32 release id, unique per (name, version). It points to a manifest URI: a content-addressed location (IPFS, Swarm, or similar) of a package manifest as defined in EIP-1123.

Semver is suggested but not required; versions are just strings.

Write API (one method):

function release(string packageName, string version, string manifestURI) returns (bytes32 releaseId);
event VersionRelease(string packageName, string version, string manifestURI);

Read API: getAllPackageIds(offset, limit), getPackageName(id), getReleaseId(name, version), getAllReleaseIds(name, offset, limit), getReleaseData(releaseId), generateReleaseId(name, version), numPackageIds(), numReleaseIds(name).

The list methods are paginated: they return a pointer to continue from, because the lists can grow too large for one call. generateReleaseId must be public so tools can compute the id for a (name, version) pair without listing every release.

Sample code

The release-id scheme suggested in the spec:

function generateReleaseId(string memory packageName, string memory version)
    public pure returns (bytes32)
{
    return keccak256(abi.encodePacked(packageName, version));
}

Resolving a release with ethers v6:

import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const registry = new Contract(registryAddress, [
  "function getReleaseId(string packageName, string version) view returns (bytes32)",
  "function getReleaseData(bytes32 releaseId) view returns (string packageName, string version, string manifestURI)",
], provider);

const id = await registry.getReleaseId("simple-token", "1.0.1");
const { manifestURI } = await registry.getReleaseData(id);
console.log(manifestURI); // e.g. an ipfs:// URI to fetch the package manifest

Things to know

  • Status is Stagnant. The companion manifest spec EIP-1123 is Withdrawn, and EthPM tooling is no longer widely used.
  • The registry stores only pointers. Integrity comes from the manifest URI being content-addressed, so always verify the fetched content matches its hash.
  • The spec recommends registries also implement ERC-165 to advertise richer interfaces (semver ranges, latest, etc.), which this standard deliberately leaves out.

#ethpm #packages #registry #tooling

Details

Authors
Piper Merriam <[email protected]>, Christopher Gewecke <[email protected]>, g. nicholas d'andrea <[email protected]>, Nick Gheorghita (@njgheorghita)
Status
Stagnant
Type
Standards Track / ERC
Created
2018-08-13

Machine-readable: Markdown · JSON