Skip to main content

Module definitions

Module definitions in Rell create reusable code components, including entities, objects, structs, enums, queries, operations, and functions. Abstract modules serve as templates, namespaces organize code, and external modules enable cross-blockchain access. Mount names provide flexible identification and mapping of components.

Identifiers syntax

Identifiers are unique names for variables, functions, and keywords, following specific syntax rules with letters, digits, and underscores (e.g., function, entity, struct).

Entity

Entities store data long-term, with unique IDs and support relationships through keys and indices. The @log annotation makes them immutable.

Object

Objects are singleton structures initialized at startup, with default attributes that cannot be created or deleted by code.

Struct

Structs are in-memory structures with default or mutable attributes, managed by the garbage collector, and can encapsulate function parameters.

Enum

Enums are sets of constants with unique integer values and built-in functions like T.values() to list values.

Query

Queries return GTV-compatible data and do not modify the database, with simple or explicit return statement options.

Operation

Operations modify data, have no return value, and are declared with the operation keyword. The require statement enforces execution conditions.

Function

Functions offer reusable logic, support various return types, and include features like default parameters, named arguments, and partial application.

Abstract module

Abstract modules and functions provide templates for customization. Client modules import and override these components to create functional versions.

Namespace

Namespaces group related modules, entities, and functions for better code organization.

External module

The @external annotation allows access to external blockchain entities within the same container. These modules must use @log and are filtered by block height.

Mount names

Mount names identify components and map entities/objects to SQL tables. The @mount annotation customizes names with support for relative naming using . (append) and ^ (remove).