Skip to main content

Kinds

A kind is a type of a group of objects in the Previous Network.

A kind itself is an object and consists of five elements: state_spec, code, data, rel_spec0, and rel_spec1.

A kind is minted from the Kind Registry, which is the set of all kind objects.

As an object, a kind also has a kind, which is the kind of all kind objects, called KindOfKinds.

Creation

The KindOfKinds is a genesis object, created when the protocol is deployed.

User-defined kinds are created when they are registered at the Kind Registry.

The following elements must be specified when registering.

State Spec

The state_spec element defines the elements of the objects created from this kind.

  • It is an array of uint8 integers, each item indicating an element type for objects of this kind.
  • Element types are non-zero uint8 integers.
  • They are concatenated and right-padded with zeros to 32 bytes.

Kind Contract

The code element is a hash of a code material.

  • The content of the code material is WASM code built from a kind contract, which can be written in AssemblyScript using kind-as, or in Rust using kind-rs.
  • The content-type of the code material is application/wasm.
  • 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 material.

  • The JSON data must have "name" and "description" fields, and optionally an "image" field. These fields are used in the kind contract of the KindOfKinds object to generate meta assets of the kind.
  • The JSON data can have other fields, which can be used in the kind contract to compute assets for objects from it.
  • The content-type of the data material is application/json.
  • The data material must be added to the Previous chain before its hash can be used.

Relation Spec

The rel_spec0 and rel_spec1 elements define the relationships that this kind of object can have with other objects.

  • They are arrays of non-zero uint64 integers, each item being an ID of a relation registered at the Relation Registry.
  • They are big-endian encoded, concatenated, and then right-padded with zeros to 32 bytes.
  • A kind can have zero to eight relations.

Update

Kinds can be updated to adopt a new version of the kind contract, change relationships to other kinds, or update the data of the kind. However, the state_spec element of a kind cannot be modified.

When a kind is updated, the revision of the kind object itself is increased. All objects already minted from this kind will not be affected. If an object's owner chooses to upgrade the object's kind to the newer revision, the object's revision is increased, and only then can the new code/data/relations introduced by the specific revision be applied.