EIPs Explained

ERC-8110 · Draft · ERC · 2025-12-20

ERC-8110: Domain Architecture for Diamonds

A draft convention for Diamond contracts that groups storage by business domain, with a fixed naming scheme for ERC-8042 storage identifiers, versioning and sub-domains, to cut storage-collision and upgrade mistakes.

What problem does it solve?

A Diamond (ERC-2535) is one proxy that routes function selectors to many logic contracts ("facets"). All facets share the Diamond's storage, so each piece of state lives at a hashed position such as keccak256("my.project.storage"). ERC-8042 standardised human-readable identifiers for those positions, but not how to choose or organise them.

In big projects this leads to drift: teams tie storage to facets, reuse or mistype identifiers, and break layouts during upgrades, so one facet silently corrupts another's state. ERC-8110 is a pure convention, with no new interfaces, that says: storage belongs to domains, not facets.

How it works

  • Domain = one area of responsibility (for example character, equipment, gamesettings). Each domain has exactly one storage struct and one identifier. Many facets may read or write the same domain.
  • Identifier format: at minimum {project}.{domain-name}.{version}; extended form {org}.{project}.{domain-type}.{domain-name}.{version}, where domain-type is diamond, system or business. Omitting the version means v1.
  • Append-only: new fields go at the end of the struct. A layout-breaking change (for example reshaping nested structs) requires a new version identifier (v2, …) and explicit, project-handled migration.
  • Sub-domains: to add state to a domain without touching its struct, define {…}.{version}.{sub-domain} with its own struct and identifier.
  • Annotation: each domain struct must carry @custom:storage-location erc8042:<id> so tools can find it.
  • Directories should mirror domains (contracts/character/storage/…, contracts/character/facets/…).

Upgrades are classified by their effect on storage: no new state (just add selectors), a new domain (horizontal), new fields in an existing domain (append or sub-domain), or a layout break (new version).

Sample code

A business domain plus a sub-domain, following the spec's naming:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @custom:storage-location erc8042:acme.game.business.character.v1
bytes32 constant CHARACTER_STORAGE_POSITION = keccak256("acme.game.business.character.v1");

struct Character { uint32 level; uint256 hp; }
struct CharacterStorage { mapping(uint256 => Character) characters; }

function characterStorage() pure returns (CharacterStorage storage s) {
    bytes32 position = CHARACTER_STORAGE_POSITION;
    assembly { s.slot := position }
}

/// Sub-domain: new state isolated from the original struct
/// @custom:storage-location erc8042:acme.game.business.character.v1.mounted
bytes32 constant CHARACTER_MOUNTED_POSITION = keccak256("acme.game.business.character.v1.mounted");

struct CharacterMountedStorage { bool isMounted; }

function characterMountedStorage() pure returns (CharacterMountedStorage storage s) {
    bytes32 position = CHARACTER_MOUNTED_POSITION;
    assembly { s.slot := position }
}

// Any facet can use the domain helpers
contract CharacterFacet {
    function levelUp(uint256 id) external {
        characterStorage().characters[id].level += 1;
    }
}

Things to know

  • Status: Draft. Naming rules may still change.
  • It changes nothing in the Diamond execution model and adds no on-chain interface; it is compatible with existing ERC-2535 and ERC-8042 systems and can be adopted incrementally. Existing identifiers in shared libraries should be left alone.
  • Choosing between appending to a domain and adding a sub-domain is a team trade-off: appending keeps things together but demands layout discipline; sub-domains isolate risk.
  • Identifier uniqueness is the main hazard when adopting it in a live system: new identifiers must not clash with existing ones.
  • For non-Diamond upgradeable contracts, the comparable namespaced-storage convention is ERC-7201.

#diamond #storage #upgradeability #architecture #solidity

Details

Authors
Hoang (@0x76agabond)
Status
Draft
Type
Standards Track / ERC
Created
2025-12-20
Requires

Machine-readable: Markdown · JSON