Kind

Kinds are objects that act as the types or blueprints for other objects in the protocol.

Each kind is created from a special set known as the Set of Kinds, governed by the Kind Registry, a core contract of the protocol. All kinds adhere to the Kind of Kind, which defines the essential elements that a kind object must contain.

Several kinds are established during the protocol's deployment, while others emerge as users register new kinds.

ID

The IDs of original kinds are predefined by the protocol:

#![allow(unused)]
fn main() {
ID_KIND_OF_SPACE = 0;
ID_KIND_OF_SET = 1;
ID_KIND_OF_KIND = 2;
ID_KIND_OF_RELATION = 3;
ID_KIND_OF_TRANSFORM = 4;
}

The IDs of emergent kinds are allocated by the Kind Registry upon registration:

#![allow(unused)]
fn main() {
ID_EMERGENT_KINDS_BEGIN = 17;
}

State Meta

When a kind is registered in the Kind Registry, its initial metadata is defined as follows:

#![allow(unused)]
fn main() {
meta.flags = 0;
meta.rev = 1;
meta.kind_rev = latest_kind_rev();
meta.set_rev = latest_set_rev();
meta.kind_id = ID_KIND_OF_KIND;
meta.set_id = ID_SET_OF_KIND;
}

State Elements

According to the Kind of Kind, a kind object consists of the following elements:

ElementNameTypeDescription
elems[0]state_specBytes32Specifies the elements of objects of this kind.
elems[1]codeBytes32Hash of the WASM code material that defines the imaging of objects of this kind.
elems[2]dataBytes32Hash of the JSON data material that provides info for the kind.
elems[3]rel_specBytes32Specifies the realtions supported by the objects of this kind.

The state_spec element cannot be changed once it is set.

state_spec

The state_spec element defines the structure of objects created from this kind. It consists of an array of uint8 values, where each item represents an element type for objects of this kind. The array is concatenated and right-padded to 32 bytes.

code

The code element contains the hash of a WASM-based kind contract. This code, written in AssemblyScript using kind-as or in Rust using kind-rs, is responsible for the behavior of objects derived from this kind. The code material must be added to the Previous chain before its hash can be used.

data

The data element is a hash of a JSON object, which includes fields like:

  • name: The name of the kind.
  • description: A description of the kind.
  • image (optional): A URL or reference to an image representing the kind.

These fields are used by the kind contract to generate metadata for the kind object.

rel_spec

The rel_spec defines the relationships that this kind of object can have with other objects. It includes arrays of relation IDs registered in the Relation Registry, which are big-endian encoded and padded to 32 bytes.

Operations

Operations involving positioning or object-to-object relationships are not supported for kinds.

OperationModifiesSupported
transferownerYes
updatemeta.rev, elems[1], elems[2], elems[3]Yes
upgrademeta.rev, meta.kind_rev, meta.set_revYes
touchmeta.revYes
relate/unrelaten/aNo
moven/aNo
enter/leaven/aNo
jump/dropn/aNo