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 explores ERC2678, a proposal to update the Ethereum smart contract packaging standard.
The explanation below translates, summarizes, and expands on the material in the following specification.
You can also find explanations of other ERCs here.
Overview
This EIP proposes a new file format for smart contracts. Called a package manifest, this format can contain a collection of smart contracts and, optionally, their source code and information about contracts deployed on different networks. This information is shared through networks such as IPFS and stored as minified JSON.
IPFS
IPFS (InterPlanetary File System) is a distributed file system designed to make the Internet more peer-to-peer (P2P). On the traditional HTTP-based Internet, users download files from specific servers. With IPFS, files are stored across many peers in the network.
Its main characteristics are as follows.
Distribution Files are distributed across multiple nodes in the network. This allows files to remain available even if a central server goes down.
Content addressing IPFS generates addresses based on file contents. Each file has a unique hash, so its address changes when the contents change. This allows users to verify the integrity of the content they receive.
Efficient delivery When a user requests a file, IPFS retrieves it from nearby or readily available nodes. This can speed up data delivery and save bandwidth.
Persistence Peers store files and redistribute them on request, allowing files to potentially persist on the network.
IPFS is suitable for many applications, including decentralized applications (dApps), decentralized websites, and offline storage systems. In combination with blockchain technology such as Ethereum, it is expected to play an important role in decentralized application development.
These contract packages are also published to an on-chain location known as an EthPM registry, defined in EIP1319. This makes the packages readily accessible and usable by anyone.
EthPM
EthPM is a package manager primarily for projects running on the Ethereum blockchain. Ethereum is a decentralized platform on which programs called smart contracts can run. EthPM provides tools that simplify the development, distribution, and management of these contracts.
Sharing and using reusable components Reusable code such as smart contracts and libraries can be published as packages so that other developers can use them easily.
Version management Developers can manage different contract versions and configure a project to depend on specific versions. This simplifies compatibility management and updates.
Dependency management When a smart contract depends on other contracts or libraries, EthPM resolves those dependencies and links the required code appropriately.
EthPM plays a similar role to package managers such as npm and pip, but specializes in the blockchain environment. Ethereum developers can use EthPM to develop smart contracts more quickly, securely, and efficiently.
The proposal offers a way to manage and reuse smart contracts more efficiently and deploy them easily across networks. Its purpose is to make it easier for developers to share contracts and reuse one another's work.
Motivation
This standard aims to promote code reuse as a best practice in the Ethereum development ecosystem. It defines an open, community-driven package data format, provides a general-purpose solution based on existing practices, and supports the development of package management tools.
The standard updates the package manifest (a document describing a collection of code) to be compatible with the metadata emitted by compilers, which transform source code into executable forms.
It also updates the sources object to support different types of source files and serve as JSON input to compilers.
Moving compiler information into a top-level compilers array simplifies the relationship between compiler versions, source code, and compiled artifacts, making packages that use multiple compiler versions easier to handle.
To follow more common JSON conventions, it also changes key names from snake_case to camelCase. These updates are intended to help Ethereum developers manage and reuse code more efficiently.
Guiding principles
The specification sets out basic principles for how the package manifest should be handled.
Automatic generation
When a new software version is released, the package manifest is generated automatically. This is part of the package manager's work, performed programmatically rather than manually.
Consumption by package managers
When developers install software dependencies or build and distribute a new version, package managers read the manifest to retrieve the required information. The manifest is therefore an important source of information that helps streamline development.
Distributed storage
The manifest is not stored alongside the source code. Instead, it is maintained by a package registry or referenced for storage in a distributed system such as IPFS. This makes it accessible when needed.
Verifying public deployments
A package manifest can be used to verify whether a publicly deployed blockchain contract was generated from the correct source code. This is an important step in checking whether a public contract behaves as expected.
The specification provides rules for automating and streamlining development. The package manifest plays a central role, helping developers manage, share, and inspect code more easily.
Use cases
The use cases considered by the specification focus on different types of packages and the functionality they provide.
owned
A package containing base contracts that provide functionality to other contracts. They are not used alone; other contracts inherit and use them.
transferable
A package with a single dependency. It is used to share specific functionality or modules with other contracts.
standard-token
A package containing a reusable ERC20 contract. It provides common token functionality and is used in many projects.
safe-math-lib
A package containing a library for safer mathematical operations. It includes a deployed instance of a particular contract.
piper-coin
A package containing a deployed instance of a reusable contract from a dependency. It can be used to create new contracts based on existing ones.
escrow
A package containing a deployed instance of a local contract linked to a local library. It provides functionality for temporarily holding funds for transactions or agreements.
wallet
A package containing a deployed instance of a local contract linked to a library from a dependency. It provides functionality that allows users to manage funds securely.
wallet-with-send
A package containing a deployed instance linked to a deeper dependency. It is used to create more complex wallet functionality and interactions.
simple-auction
This example relates to the compiler's metadata output, which is useful when creating applications with specific functionality, such as auction contracts.
These examples demonstrate how package manifests address different needs for efficient code reuse and simpler deployments.
Specification
Conventions
Prefixed vs. unprefixed
Hexadecimal values may appear with or without the 0x prefix.
Examples are 0xdeadbeef and deadbeef.
Unless otherwise specified, this document recommends using 0x.
This makes it clear that the value is hexadecimal.
These conventions are intended to ensure that the proposal is understood accurately and consistently. Standardizing keywords and notation reduces ambiguity and allows readers to interpret information using the same conventions.
Document format
The document is formatted as a single, organized JSON object. To maintain this format, follow these simple rules.
Dense formatting
The document should be kept compact. Do not include unnecessary whitespace or line breaks; use as little space as possible.
Key ordering
All keys within an object should be sorted alphabetically. This makes individual keys easier to find and maintains consistency.
No duplicate keys
Two keys with the same name within one object are invalid. All keys must be unique.
UTF-8 encoding
The document should be encoded in UTF-8. This international standard can accurately represent characters from various languages.
No trailing newline
Do not include a newline at the end of the document. The file should end with a character such as a period or closing bracket.
Do not use manifest_version
This key is reserved for future compatibility. Avoid using it at the top level.
These rules ensure that package manifests remain consistently readable, simple, and less prone to errors.
Document specification
The document specification defines several fields that a package should contain.
Custom fields are also permitted, but their names should begin with x- to avoid collisions with future specification versions.
You can also consult the formalized JSON Schema version of the specification (package.spec.json).
The document provides guidance for handling both standard and custom package fields. When using custom fields, follow the naming convention to avoid future problems.
EthPM Manifest Version
The EthPM Manifest Version field identifies the version of the EthPM manifest specification that the package follows. Every package requires this information, configured as follows.
-
Required
- Yes. This field must be included in the package.
-
Key
- The field name is
manifest.
- The field name is
-
Type
- The value must be a string (
String).
- The value must be a string (
-
Allowed values
- The only permitted value is
ethpm/3. - This indicates that the package follows version 3 of the EthPM specification.
- The only permitted value is
This field is critical to compatibility and correct interpretation of the package. With accurate version information, tools and systems can handle the package correctly and perform the required operations.
Package name
The name field gives the package a human-readable name.
Including a name is recommended when publishing to an EthPM registry.
Package names must follow these simple rules.
-
First character
- The package name must begin with a lowercase letter.
-
Allowed characters
- Only lowercase letters (a-z), digits (0-9), and hyphens (-) are allowed.
-
Length
- The package name must be no longer than 255 characters.
Include the name together with version information.
In other words, if a version is specified, the name field is also required.
-
Required
- This field is required if a version is specified.
-
Key
- The field identifier is
name.
- The field identifier is
-
Type
- The value should be a string (
String).
- The value should be a string (
-
Format
- The name must match the regular expression
^[a-z][-a-z0-9]{0,255}$. - This checks compliance with the rules above.
- The name must match the regular expression
These guidelines are designed to ensure consistent and unique package naming in the EthPM registry.
Package version
A label identifying the package version.
Include version information when publishing a package to an EthPM registry.
The version number should follow semantic versioning (semver).
It uses the three-part form X.Y.Z, representing major changes, minor changes, and patches respectively.
Semantic versioning
Semantic Versioning (SemVer) is a set of rules for assigning version numbers to software. Version numbers follow the major.minor.patch format, with each component representing the following types of changes:
- Major
- Increment for incompatible API changes.
- For example, changing
1.0.0to2.0.0indicates breaking changes, such as significant changes or removal of existing functionality.
- Minor
- Increment when adding backward-compatible functionality.
- For example, changing
1.2.0to1.3.0indicates new functionality while maintaining compatibility with existing features.
- Patch
- Increment for backward-compatible bug fixes.
- For example, changing
1.3.1to1.3.2indicates small changes such as minor bug fixes or performance improvements.
Examples
- Version
1.0.0represents the first stable release of the software. - After a minor bug fix, the version becomes
1.0.1(increment the patch number). - If a new feature is added while maintaining API compatibility, the version becomes
1.1.0(increment the minor number). - After a major change such as changing or removing an existing API, the version becomes
2.0.0(increment the major number).
Semantic versioning helps developers understand the nature and scope of changes in a release from its version number. It simplifies dependency management and reduces the risks associated with software updates.
If the name field (package name) is set, version information is required.
A named package must therefore have an explicit version.
- Required
- If the package has a name, its version must also be specified.
- Key
- The field name is
version.
- The field name is
- Type
- The version value is a string.
The package version identifies a specific package release and helps developers use the correct version of their dependencies. Appropriate version numbers make package updates and compatibility management much easier.
Package metadata
A field for storing additional information about the package. This information is not directly necessary for installation, but provides useful details about the package and for other purposes.
Metadata is optional, but including it is recommended when providing more information about a package.
- Required
- No.
- This field is optional but recommended to provide useful package information.
- Key
- The field name is
meta.
- The field name is
- Type
- The field type is a Package Meta Object, an object containing various additional details about the package.
Package metadata is an optional field that provides useful information to package users. It helps users understand the package contents, usage, and background in greater depth.
Sources
This field describes the entire source code layout needed to reconstruct the contracts in the package. It identifies the location and contents of the original contract code and is important for package reuse and verification.
The field is optional but particularly useful for understanding and recompiling contracts. Access to source code is especially important when assessing contract reliability and security.
- Required
- No.
- This field is not always necessary, but is recommended to provide comprehensive package information.
- Key
- The field identifier is
sources.
- The field identifier is
- Type
- This field is an object mapping strings (source file paths or names) to associated source objects (file contents or information).
It is a map organizing the source code of the contracts in the package so developers can inspect it when necessary. This information helps developers understand contract behavior and inspect or improve the code themselves if needed.
Contract types
This field describes the structure and definitions of the contracts contained in the package. It organizes the details of the specific contracts included in a release and clarifies how they are constructed.
The field has the following characteristics.
- Required
- This field is not mandatory.
- However, it is useful for understanding the package contents in more detail or clarifying contract structure.
- Contents
- Include only contract types found directly in the package.
- Do not include contracts from dependencies or abstract contracts.
- This explicitly identifies only the concrete contracts in the package and avoids confusion.
- Key
- The field name is
contractTypes.
- The field name is
- Type
- The field type is an object.
- It maps contract aliases to objects containing the contract definitions and information.
- Format
- Each key must be a valid contract alias.
- Each value must conform to the definition of a contract type object.
This organizes detailed information about contracts in the package and makes each contract easier to understand. Developers can gain a deeper understanding of the package and use individual contracts as needed.
Compilers
This field provides information about how the contracts in the package were created. Specifically, it includes details of the tools and settings used to compile them. It is optional, but improves compilation transparency and helps developers compile the code under the same conditions.
The field has the following characteristics.
-
Required
- No.
- This field is optional, but providing compilation details helps improve reproducibility and reliability.
-
Key
- The field name is
compilers.
- The field name is
-
Type
- The field type is an array.
- Each element is an object containing compiler information, such as version, settings, and language.
It identifies which compilers and settings were used to compile the package's contracts, helping developers reproduce the environment. This improves transparency when verifying contract behavior and security.
Deployments
This field defines which blockchains contain the released contracts and how their individual details are provided. It helps developers identify where contracts have been deployed and retrieve information about specific contract instances.
- Required
- This field is optional.
- It is not mandatory, but helps clarify contract deployment information.
- Key
- The field identifier is
deployments.
- The field identifier is
- Type
- The field type is an object.
- Each key represents a unique blockchain identified by a BIP122 URI. Each value is an object containing information about contract instances deployed on that blockchain.
Each contract-instance information object maps contract names to their corresponding details. This makes information about specific contract instances easy to find.
The field identifies the blockchains containing the released contracts and where specific information about each contract can be found. Developers can readily identify and access the contract instances they need.
Build dependencies
This field identifies dependencies on other EthPM packages required to build a project correctly. It makes clear which external packages a project depends on and provides a link to each dependency.
-
Required
- This field is optional.
- Not every project needs it, but it helps clarify relationships when a project depends on other packages.
-
Key
- The field name is
buildDependencies. - Use this field to specify dependencies on other packages that affect the project's build process.
- The field name is
-
Type
- The field type is an object.
- Each key is the name of a dependency package, and each value is a content-addressable URI pointing to that package.
-
Format
- Each key (package name) must be valid.
- Each value (
URI) must point to a valid package that follows the same EthPM manifest version as the parent project.
This field provides links to other EthPM packages needed for the project to build and run smoothly. It helps developers identify the external resources their project depends on and manage the required packages.
Object definitions
This section describes the rules and structures of the various object types used in EthPM packages. These include package structure, contract details, build dependencies, and other package information. Developers can also define custom fields to add their own information to a package.
Prefix custom fields with x- to prevent name collisions in future specification updates.
For example, specify custom color information as x-color rather than color.
This helps custom fields continue to work after specification updates, maintaining package compatibility and stability.
These definitions guide the accurate description of package contents and structure and provide rules for safely adding custom fields.
Link reference object
A link reference object contains the following key-value pairs. All link references are assumed to be associated with corresponding bytecode.
Offsets
An array of integers identifying each starting position of the link reference within the bytecode.
Positions are indexed from 0 at the start of the corresponding byte representation of the bytecode.
The field is invalid if it refers to a position beyond the end of the bytecode.
-
Required
- This field is required.
-
Type
- Array.
Length
An integer defining the length of the link reference in bytes. The field is invalid if the end of the defined link reference extends beyond the end of the bytecode.
-
Required
- This field is required.
-
Type
- Integer.
Name
A string that must be a valid identifier. Link references that should be linked with the same link value should have the same name.
- Required
- No.
- The field is optional but useful for identifying link references.
- Type
- String.
- Format
- It must conform to the identifier format.
These fields describe the position, length, and name of specific link references within bytecode, helping explain exactly how a contract is linked. Developers can manage the contract bytecode appropriately and link it when needed.
Link value object
This object describes a single link value. The link value object defines the following key-value pairs.
Offsets
Defines the positions within the corresponding bytecode where this link value was written. These positions are zero-indexed from the start of the byte representation of the corresponding bytecode.
- Required
- Yes.
- Type
- Integer.
- Format
- An array of integers, each satisfying the following conditions.
- It must be greater than or equal to zero.
- It must be strictly less than the length of the unprefixed hexadecimal representation of the corresponding bytecode.
Type
Defines the type of value encoded when linking the corresponding bytecode.
- Required
- Yes.
- Type
- String.
- Allowed values
- "literal" (for a bytecode literal)
- "reference" (for a named reference to a specific contract instance)
Value
Defines the value to be written when linking the corresponding bytecode.
- Required
- Yes.
- Type
- String.
- Format
- Determined by the type.
- For a static literal value (such as an address), the value must be a
0x-prefixed hexadecimal string representing bytes. - When referencing the address of a contract instance from the current package, the value should be the name of that contract instance.
- When referencing a package's contract instance from somewhere in the dependency tree, the value is constructed using a specific format.
A link value object defines where a particular link value belongs in the contract bytecode, what to link, and which value to use. This allows the bytecode to be linked correctly and the required information to be embedded accurately.
Bytecode object
A Bytecode Object contains contract bytecode and the information required to link it.
Bytecode
The contract bytecode represented as a 0x-prefixed hexadecimal string.
This required field represents the executable code of the contract.
- Required
- Yes.
- Type
- String.
- Format
- A
0x-prefixed hexadecimal value.
- A
Link references
This field defines the locations in the bytecode that require linking. Each location is represented by a link reference object containing the information needed to link the bytecode correctly.
- Required
- No.
- Type
- Array.
- Format
- All values must be valid link reference objects.
- The field is invalid if a link reference is invalid when applied to the bytecode or if link references overlap.
Link dependencies
This field defines the link values used to link the corresponding bytecode. Each link value is represented by a link value object describing what to write and where when linking the bytecode.
- Required
- No.
- Type
- Array.
- Format
- All values must be valid link value objects.
- Two link value objects must not contain the same offset value, and each link value object must have a corresponding link reference object in the link references field.
- The resolved value length must equal the corresponding link reference length.
This object organizes contract bytecode together with the references and dependencies needed to link it. It allows the bytecode to be understood accurately and linked appropriately.
Package meta object
The Package Meta Object defines key-value pairs providing additional information about the package.
Authors
This field defines a list of human-readable names of the package authors. Packages may include this field.
- Required
- No.
- Key
authors
- Type
- Array of strings.
License
This field declares the license associated with the package. The value should conform to SPDX format. Packages should include this field. If a particular file's source object defines its own license, that license overrides the package-level meta license for that file.
- Required
- No.
- Key
license
- Type
- String.
SPDX
SPDX (Software Package Data Exchange) is a specification for documenting and sharing software package components, licenses, and copyright information in a standardized format. Supported by the Linux Foundation, it is widely used to identify and organize licenses for open-source and other types of software.
The main goal of SPDX is to make software licensing information transparent and interoperable across tools and formats. This enables developers, legal teams, and supply-chain managers to understand, analyze, and share software package license information easily.
The SPDX specification has the following features.
License list SPDX provides standard short identifiers for common open-source licenses and their variants, such as GPL-2.0 and MIT. This helps maintain consistency and accuracy in documents and metadata.
Document formats SPDX provides formats for documenting software components, their dependencies, licenses, and copyright information. These include tag-value, RDF, and JSON.
Tool support Various SPDX tools can generate, validate, compare, and analyze SPDX documents.
SPDX is particularly useful in large projects integrating multiple open-source components and in organizations that need to manage license compliance. It also helps with software supply-chain management as an important step in maintaining open-source license compliance.
Description
This field provides additional details about the package. Packages may include this field.
- Required
- No.
- Key
description
- Type
- String.
Keywords
This field provides keywords associated with the package.
- Required
- No.
- Key
keywords
- Type
- Array of strings.
Links
This field provides URIs for resources associated with the package. Where possible, authors should use the following keys for these common resources.
website- The package's main website.
documentation- The package documentation.
repository- The location of the project's source code.
- Required
- No.
- Key
links
- Type
- Object (string: string).
The package meta object provides additional information such as authors, licenses, descriptions, keywords, and related links, offering a more comprehensive overview of the package. Users can learn more about the package's background and use this information when deciding whether to use it.
Source objects
The Sources Object contains information about individual source files in the package. Each source file is represented by a unique identifier (key) and a source object (value).
A source object contains the following fields.
Checksum
The hash of the source file. It is required only when the content field is absent and none of the provided URLs contains a content hash.
- Key
checksum
- Value
- Checksum object
URLs
An array of URLs resolving to the same source file. URLs should point to a content-addressable file system. Otherwise, either the content or a checksum must be included. Required if content is not included.
- Key
urls
- Value
- Array of strings
Content
The inline contract source. If both URLs and content are supplied, the content value must match the file identified by the URLs. Required if URLs are absent.
- Key
content
- Value
- String
Install path
The source file's filesystem path. Packages that can be written to disk require this field.
- Key
installPath
- Value
- String
Type
Declares the source file type. The value is one of solidity, vyper, abi-json, or solidity-ast-json. Optional.
- Key
type
- Value
- String
License
Declares the license associated with this source file. If defined, this license takes precedence over the package-level meta license. Optional.
- Key
license
- Value
- String
These fields provide details about each source file, including its contents, location, type, and license, allowing the files in the package to be managed and understood properly.
Checksum object
A Checksum Object contains information for generating a hash of a source file's contents and verifying its integrity. The following key-value pairs are defined.
Algorithm
This field identifies the algorithm used to generate the corresponding hash.
Possible algorithms include, but are not limited to, sha3, sha256, md5, and keccak256.
- Required
- Yes.
- Type
- String.
Hash
This field contains the hash of the source file's contents generated using the corresponding algorithm.
- Required
- Yes.
- Type
- String.
To verify that a source file has not been modified, record the hash computed from its contents and the algorithm used to compute that hash. This supports file integrity and a reliable software development process.
Contract type object
A Contract Type Object contains key-value pairs defining detailed information about a particular contract type.
Contract name
This field defines the name of the contract type. Required if the contract name and contract alias differ.
- Type
- String.
- Format
- Must be a valid contract name.
Source ID
The global identifier of the source file from which this contract type was generated. It must match a unique source ID in the package's source objects, but is optional.
- Type
- String.
Deployment bytecode
Defines the deployment bytecode of this contract type. It must conform to the bytecode object format, but is optional.
- Type
- Object.
Runtime bytecode
Defines the unlinked, 0x-prefixed runtime bytecode portion of this contract type.
It must conform to the bytecode object format, but is optional.
- Type
- Object.
ABI
This field defines the contract's application binary interface (ABI). It must conform to the Ethereum contract ABI JSON format, but is optional.
- Type
- Array.
UserDoc
This field defines the contract's user documentation.
It must conform to the UserDoc format, but is optional.
- Type
- Object.
DevDoc
This field defines the contract's developer documentation.
It must conform to the DevDoc format, but is optional.
- Type
- Object.
This object provides essential information defining contract characteristics and behavior, including its name, source, bytecode, ABI, and documentation. These details help developers understand and interact with the contract correctly.
Contract instance object
A Contract Instance Object represents a single deployed contract instance and contains the following key-value pairs.
Contract type
Defines the contract type of this contract instance.
It can reference any contract type in this package or any contract type in a package dependency found through the package manifest's buildDependencies section.
- Required
- Yes.
- Type
- String.
- Format
- Use
<contract-alias>to reference a contract type in this package and<package-name>:<contract-alias>to reference a contract type from a dependency.
- Use
Address
Defines the address of the contract instance.
- Required
- Yes.
- Type
- String.
- Format
- An Ethereum address encoded as a
0x-prefixed hexadecimal value.
- An Ethereum address encoded as a
Transaction
Defines the hash of the transaction that created this contract instance.
- Required
- No.
- Type
- String.
- Format
- A transaction hash encoded as a
0x-prefixed hexadecimal value.
- A transaction hash encoded as a
Block
Defines the hash of the block in which the transaction creating this contract instance was mined.
- Required
- No.
- Type
- String.
- Format
- A block hash encoded as a
0x-prefixed hexadecimal value.
- A block hash encoded as a
Runtime bytecode
Defines the runtime bytecode portion of this contract instance. If present, this field overrides the runtime bytecode inherited from the contract instance's contract type.
- Required
- No.
- Type
- Object.
- Format
- Must conform to the bytecode object format.
- Every link reference in this bytecode must have a corresponding entry in the
linkDependenciessection.
This object provides important information about a deployed contract instance, such as its type, address, transaction, block, and runtime bytecode, guiding developers in executing and interacting with contracts.
Compiler information object
A Compiler Information Object defines the compilers and their settings used to compile contract types and instances in the package.
Name
Defines which compiler was used.
- Required
- Yes.
- Key
name
- Type
- String.
Version
Defines the compiler version.
This field should be operating-system independent (the OS is not included in the string).
Stable versions use semver, while nightly builds use <semver>-<commit-hash>.
Example: 0.4.8-commit.60cc1668.
- Required
- Yes.
- Key
version
- Type
- String.
Settings
Defines the settings and configuration used during compilation. For the "solc" compiler, this should conform to the Compiler Input and Output Description.
- Required
- No.
- Key
settings
- Type
- Object.
Compiler Input and Output Description
The Compiler Input and Output Description is a specification for compilers, particularly those for smart contract languages such as Solidity. It defines the formats of inputs supplied to the compiler and outputs produced by it. This clarifies compiler behavior and makes its operation easier for developers to predict.
Input description
Compiler input is typically provided as JSON containing the following information.
- Language version
- The version of the compiler used.
- Source code
- The source files to compile.
- These may include multiple files and dependencies.
- Settings
- Settings affecting compilation, such as whether optimization is enabled, the level of output detail, and library linking.
Output description
Compiler output typically contains the following information.
- Bytecode
- The compiled contract bytecode.
- This is the executable code used when deploying to the blockchain.
- ABI(Application Binary Interface)
- The interface needed to interact with the contract, including calling its functions externally.
- Metadata
- Additional information such as the contract version, authors, and license.
- Runtime bytecode
- Bytecode used when the contract executes on the blockchain.
- Other debugging information
- Source mappings, gas estimates, and other information useful for debugging.
This specification allows developers to use compilers efficiently, interpret outputs such as bytecode and ABI, and obtain the information needed to deploy smart contracts to a blockchain accurately. It is also important for maintaining compatibility across environments and compilers.
Contract types
A list of contract aliases or contract types in this package whose output was generated by this compiler.
All contractTypes declaring local runtimeBytecode should be attributed to a compiler object.
A single contractTypes entry must not be attributed to multiple compilers.
- Required
- No.
- Key
contractTypes
- Type
- Array of contract aliases.
This object provides detailed information about the compilers used for contracts, including names, versions, settings, and associated contract types, helping developers understand the compilation process accurately.
BIP122 URI
A BIP122 URI defines a blockchain using part of the BIP122 specification. The specific format is as follows.
blockchain://<genesis_hash>/block/<latest confirmed block hash>Here, <genesis_hash> represents the hash of the first block in the chain, while <latest confirmed block hash> represents the latest block hash whose reliability has been confirmed.
Package managers are free to choose their desired confirmation level.
This URI format uniquely identifies a specific blockchain and its particular state (the latest confirmed block). It helps identify packages and information associated with contracts or transactions on a particular blockchain. It also helps avoid confusion between different blockchains.
Glossary
ABI
The JSON representation of an application binary interface.
Address
An identifier for an account on a specific chain.
Bytecode
A set of EVM instructions generated by a compiler.
Unless otherwise specified, it is assumed to be hexadecimal-encoded, to represent an integer number of bytes, and to have a 0x prefix.
Bytecode can be linked or unlinked.
Chain Definition
A definition derived from a BIP122 URI. Used to uniquely identify a specific blockchain and its particular state.
Content Addressable URI
A URI containing a cryptographic hash that can be used to verify content integrity. The URI format is defined in RFC3986.
Contract Alias
A name used to reference a particular contract type. It must be unique within the package.
Contract Instance
A particular deployed version of a contract type.
Contract Instance Name
A name used to reference a specific contract instance on a specific chain from the deployments of a single package.
Contract Name
The name defining a particular contract type in source code.
Contract Type
A specific contract in the package source. This can include abstract contracts, ordinary contracts, or libraries.
Identifier
A general term for a named entity within a package.
Link Reference
A location in contract bytecode that needs to be linked.
Link Value
A value that can be inserted in place of a link reference.
Linking
The act of replacing link references in bytecode with link values.
Package
A distribution of application source or compiled bytecode together with metadata such as copyright, license, and version information.
Package Manifest
A machine-readable description of a package.
Prefixed
A bytecode string beginning with 0x.
Example: 0xdeadbeef.
Unprefixed
A value without the prefix.
Example: deadbeef.
Additional considerations
Minification
EthPM packages are distributed as minified JSON with alphabetically ordered keys. This ensures that a given set of contract assets resolves to the same content-addressed URI when publishing a package to a content-addressable file system such as IPFS. This maintains package consistency.
Package names
Package names are restricted to lowercase letters, digits, and hyphens (-).
This improves package-name readability and, in turn, its security properties.
The restricted character set makes it easier to identify the intended package and avoid confusion with malicious lookalikes of trusted packages.
BIP122 (Bitcoin Improvement Proposal 122)
The BIP-122 standard has been used since EthPM version 1. It is an industry-standard URI scheme for identifying blockchains and distinguishing between forks.
Compilers
Compilers are now defined as a top-level array describing the compilers and settings used to compile contract types and contract instances. This simplifies how tools identify the compiler type required to interact with or verify contract assets. It also removes unnecessary duplication when multiple contract types share the same compiler type.
Compatibility
To make the EthPM specification clearer and more readable, version 3 changes the manifest_version field to manifest.
For backward compatibility, version 3 packages must have a top-level manifest key with the value ethpm/3.
In addition, manifest_version is prohibited as a top-level key in version 3 packages.
These changes simplify migration to newer EthPM versions while maintaining compatibility with older versions.
Security
Using an EthPM package means incorporating or executing code written by someone else. The EthPM specification ensures that users of a correctly constructed package use exactly the same code included by the package author. However, it does not guarantee that the code is safe to use. It is therefore important to use EthPM packages created and released by people or organizations that you trust to include only nonmalicious code. Choosing packages from trusted sources helps reduce security risks.
Citation
g. nicholas d’andrea (@gnidan), Piper Merriam (@pipermerriam), Nick Gheorghita (@njgheorghita), Christian Reitwiessner (@chriseth), Ben Hauser (@iamdefinitelyahuman), Bryant Eisenbach (@fubuloubu), "ERC-2678: Revised Ethereum Smart Contract Packaging Standard (EthPM v3)," Ethereum Improvement Proposals, no. 2678, May 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2678.
Conclusion
This article covered ERC2678, the proposal to update the Ethereum smart contract packaging standard. I hope this explanation was helpful.
If you have any questions, feel free to send me a direct message on Twitter.
You can also find my writing on the following platforms.


