chain_context
The chain_context namespace provides access to blockchain configuration and module arguments. For complete API
documentation, see the
chain_context reference in the
Standard Library.
The chain_context.args field contains the module arguments specified in the chromia.yml configuration file.
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: 46Code that reads module_args:
function f() {
print(chain_context.args.name);
print(chain_context.args.age);
}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"}}}.