chain_context
The chain_context.args
field contains the module arguments specified in the chromia.yml
configuration file. The module_args
field must be defined as a user-defined struct within the entry point module named module_name
. Access to the args
field is only possible if the module_args
struct is defined.
Example of module_args
:
struct module_args {
name: text;
age: integer;
}
Corresponding module configuration:
blockchains:
module-args-example:
module: example
moduleArgs:
example:
name: Alice
age: 46
Code that reads module_args
:
function f() {
print(chain_context.args.name);
print(chain_context.args.age);
}
When configuring a module, you only need to explicitly specify values for attributes in module_args
that differ from their default values. If an attribute has a default value and you don't specify it, Rell will use the default value during runtime. If all attributes have default values, you can omit the args section altogether, and default values will be used for all attributes.
Every module can have its own module_args
. Reading chain_context.args
returns the args for the current module, and the type of chain_context.args
is different for different modules: it's the module_args
struct defined in that module.
-
chain_context.blockchain_rid
: This field contains a byte array representing the blockchain RID. -
chain_context.raw_config
: This field contains a GTV object representing the blockchain configuration, for example,{"gtx":{"rell":{"mainFile":"main.rell"}}}
.