Sets
A Set is a meta-object from which other objects are created.
Descriptor
Sets are themselves objects: they have their own kind and are minted from a set. The Kind of Set and the Set of Set are genesis objects created during protocol initialization.
A set’s descriptor is initialized with the following values:
| Field | Value | Description |
|---|---|---|
flags | 0 | Reserved flags |
rev | 1 | Initially 1, increments as the kind itself evolves |
krev | latest | Revision of the Kind of Set at creation (increments over time) |
srev | latest | Revision of the Set of Set at creation (increments over time) |
kind | 1 | ID of the Kind of Set |
set | 1 | ID of the Set of Set |
Elements
Each set has 2 elements, as defined in the Kind of Set object's eltys field.
| Index | Element | Type | Mutable | Description |
|---|---|---|---|---|
0 | code | Matter | Yes | Address of the set contract |
1 | data | Matter | Yes | Matter hash of the set data |
Set Contract
The code field stores the address of the set contract that governs all objects minted from this set.
The address is stored as a bytes32, derived from an Ethereum address as follows:
bytes32(uint256(uint160(addr)))A periphery library is available to help users write set contracts. You can learn more in the guide: Register a Set.
Set Data
The data field stores a matter hash referencing a piece of data associated with the set.
This data is available to the set’s own kind contract and may also be used by the kind contracts of objects minted from it. We will explore more in later chapters.
Set Registry
When a set is registered in the Set Registry, it is assigned a set ID.
The set ID and set revision must be specified in an object's descriptor whenever the object is created or modified.