How to use the ODC Storage
Main architecture
Storage Types in ODC
The Nexera Protocol provides two types of storage accessible through the IODC
interface:
Storage
- Storage is linked directly to ODC IDs and their associated Properties. It can be accessed using
IODC.getTYPEOFDATA(ouid, property)
andIODC.setTYPEOFDATA(ouid, property)
.
For example, in the case of an ERC-721 stored as a Property (implemented through a Property Manager), we can store approvals directly on specific ODC IDs.
GlobalStorage
- GlobalStorage is only linked to Properties themselves (not inherent to ODC tokens). It can be accessed using
IODC.getGlobalTYPEOFDATA(property)
andIODC.setGlobalTYPEOFDATA(property)
.
Continuing the example of an ERC-721, we can store a global royalty fee using GlobalStorage.
Data Types
The Nexera Protocol supports four data types for both Storage and GlobalStorage:
Bytes32
- Used for fixed-size data (32 bytes)
- Represented by the
keyValueData
mapping (maps bytes32 key to bytes32 value) - Suitable for storing IDs, short strings, numbers, and other small data
Bytes
- Used for variable-size byte arrays (any length)
- Represented by the
keyBytesData
mapping (maps bytes32 key to bytes value) - Suitable for storing larger data, such as long strings, serialized objects, or encrypted content
DataSet
- Used for storing sets of bytes32 values
- Represented by the
keySetData
mapping (maps bytes32 key to EnumerableSet.Bytes32Set value) - Consists of an inner Set struct with an array of bytes32 values and a mapping of these values to their 1-indexed positions in the array
- Suitable for storing collections of unique items, such as lists of identifiers, addresses, or tokens
DataMap
- Used for storing key-value pairs of bytes32 data
- Represented by the
keyMapData
mapping (maps bytes32 key to EnumerableMapMod.Bytes32ToBytes32Map value) - Consists of an inner Map struct with an array of MapEntry structs and a mapping of bytes32 keys to their 1-indexed positions in the array
- Suitable for storing mappings between different data, such as user IDs to their associated data or tokens to their balances
In summary, Bytes32 and Bytes data types are suitable for storing individual pieces of data, while DataSet and DataMap are more suitable for storing collections of data and their relationships. These storage types and data types offer flexibility to adapt to various requirements and constraints in the ODC ecosystem.