ERC-7208 · Final · ERC · 2023-06-09
ERC-7208: On-Chain Data Containers
Separates where token data is stored (Data Objects) from the logic that manages it (Data Managers), so the same on-chain asset can be exposed through several token standards at once and its logic can be upgraded without moving the data.
What problem does it solve?
A token's balances usually live inside the same contract that implements its interface. If you later want that asset to behave like an ERC-20 and an ERC-1155, or move it to a newer standard, you need bespoke wrappers and bridges, and already-deployed contracts cannot adapt.
ERC-7208 proposes "On-chain Data Containers": keep the data in one place and let any number of independent logic contracts read and write it through a common interface. The authors pitch this as a building block for "standard adapters" between token standards.
How it works
The standard defines five roles:
| Role | Job |
|---|---|
| Data Point (DP) | A bytes32 identifier that indexes a piece of stored data. It is a pointer, not the data itself. |
| Data Object (DO) | Contract that actually stores the data, indexed by Data Points. Exposes read, write and setDIImplementation. |
| Data Manager (DM) | Contract with the business logic and user-facing interface (for example an ERC-20 or ERC-1155 front end). |
| Data Point Registry (DPR) | Allocates Data Points and manages their admins (allocate, isAdmin, grantAdminRole...). |
| Data Index (DI) | Access-control gate: decides which Data Managers may write to which Data Points (allowDataManager, isApprovedDataManager). |
Reads may go straight to a Data Object or through the Data Index; writes must go through the Data Index, which checks that the calling Data Manager is approved for that Data Point. Operations are selected by a bytes4 operation id plus ABI-encoded data, so a Data Object can define its own storage verbs.
A Data Point must carry a 4-byte chain id, and the spec recommends a layout of a 4-byte prefix (type and version), a 4-byte registry-local id, the chain id, and the 20-byte address of the registry that allocated it. That lets a Data Object quickly reject a Data Point from an unexpected registry.
Because the Data Object trusts a single Data Index per Data Point, storage management can be moved to a new Data Index with setDIImplementation. The spec calls this "horizontal data mobility": logic and access control can be upgraded while the stored value stays put.
Sample code
Core interfaces from the spec (comments trimmed):
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
interface IDataObject {
function read(bytes32 dp, bytes4 operation, bytes calldata data) external view returns (bytes memory);
function write(bytes32 dp, bytes4 operation, bytes calldata data) external returns (bytes memory);
function setDIImplementation(bytes32 dp, address newImpl) external;
}
interface IDataIndex {
function isApprovedDataManager(bytes32 dp, address dm) external view returns (bool);
function allowDataManager(bytes32 dp, address dm, bool approved) external;
function read(address dobj, bytes32 dp, bytes4 operation, bytes calldata data) external view returns (bytes memory);
function write(address dobj, bytes32 dp, bytes4 operation, bytes calldata data) external returns (bytes memory);
}
A Data Manager writing a balance change (the operation selector is implementation-defined):
bytes4 constant OP_TRANSFER = bytes4(keccak256("transfer(address,address,uint256)"));
function transfer(address to, uint256 amount) external returns (bool) {
dataIndex.write(address(dataObject), dataPoint, OP_TRANSFER, abi.encode(msg.sender, to, amount));
emit Transfer(msg.sender, to, amount);
return true;
}
Things to know
- Status is Final. The standard fixes the interfaces only; what operations a Data Object supports and how user ids are assigned are left to implementations.
- Access control is layered: the Registry decides who administers a Data Point, the Data Index approves Data Managers, and the Data Object trusts one Data Index. A mistake at any layer can expose shared storage to every interface built on it.
- The spec warns that user-id choices in a Data Index can make later migration to another Data Index hard.
- The reference implementation (a fungible plus semi-fungible adapter sharing one Data Object) is explicitly educational and unaudited.