Legend:
Library
Module
Module type
Parameter
Class
Class type
This module represents access to a global table of constant Micheline values. Users may register a Micheline value in the table, paying the cost of storage. Once stored, contracts source code may reference this value by its hash.
Note: the table does not typecheck the values stored in it. Instead, any place that uses constants must first call expand before typechecking the code. This decision was made to make it as easy as possible for users to register values to the table, and also to allow maximum flexibility in the use of constants for different parts of a Michelson script (code, types, data, etc.).
A constant is the prim of the literal characters "constant". A constant must have a single argument, being a string with a well formed hash of a Micheline expression (i.e generated by Script_expr_hash.to_b58check).
register context value registers a constant in the global table of constants, returning the hash and storage bytes consumed.
Does not type-check the Micheline code being registered, allow potentially ill-typed Michelson values to be stored in the table (see note at top of module).
The constant is stored unexpanded, but it is temporarily expanded at registration time only to check the expanded version respects the following limits. This also ensures there are no cyclic dependencies between constants.
Fails with Expression_too_deep if, after fully expanding all constants, the expression would have a depth greater than Constant_repr.max_allowed_global_constant_depth.
Fails with Badly_formed_constant_expression if constants are not well-formed (see declaration of Badly_formed_constant_expression) or with Nonexistent_global if a referenced constant does not exist in the table.
Consumes serialization cost. Consumes Gas_repr.write_bytes_cost <size> where size is the number of bytes in the binary serialization provided by Script_repr.expr_encoding.
expand context expr replaces every constant in the given Michelson expression with its value stored in the global table.
The expansion is applied recursively so that the returned expression contains no constant.
Fails with Badly_formed_constant_expression if constants are not well-formed (see declaration of Badly_formed_constant_expression) or with Nonexistent_global if a referenced constant does not exist in the table.