Docs
chromia.com

Object

On this page

An object is similar to an entity, but there can be only one instance of an object:

Objects have the following characteristics:

  • Rell objects exist as unique instances, acting as global singletons.
  • Like entities, objects are stored in the database.
  • Objects get initialized automatically during blockchain initialization.
  • Objects cannot be directly created or deleted from code.
  • Object attributes require default values.

Example

Rell
object event_stats {
    mutable event_count: integer = 0;
    mutable last_event: text = "n/a";
}

Accessing and modifying objects

Reading attributes

Employ query statements to retrieve object attribute values.

Example

Rell
query get_event_count() = event_stats.event_count;

Updating attributes

Utilize update operations to modify object attributes.

Example

Rell
operation process_event(event: text) {
    update event_stats ( event_count += 1, last_event = event );
}