Skip to main content

Module runtime

Module runtime 

Source
Expand description

Functions for interacting with the current runtime.

Constants§

ADDRESSABLE_ENTITY_FIELD_IDX
Index for the addressable entity field of block info.
ADDRESSABLE_ENTITY_LENGTH
The default size of the addressable entity flag.
BLOCK_HEIGHT_FIELD_IDX
Index for the block height field of block info.
BLOCK_TIME_FIELD_IDX
Index for the block time field of block info.
DEFAULT_HASH_LENGTH
The default length of hashes such as account hash, state hash, hash addresses, etc.
PARENT_BLOCK_HASH_FIELD_IDX
Index for the parent block hash field of block info.
PROTOCOL_VERSION_FIELD_IDX
Index for the protocol version field of block info.
PROTOCOL_VERSION_LENGTH
The default size of ProtocolVersion. It’s 3×u32 (major, minor, patch), so 12 bytes.
STATE_HASH_FIELD_IDX
Index for the state hash field of block info.

Functions§

blake2b
Returns a 32-byte BLAKE2b digest
call_contract
Calls the given stored contract, passing the given arguments to it.
call_package_version
Invokes the specified entry_point_name of stored logic at a specific contract_package_hash address, for a specific pair of major_version and contract_version and passing the provided runtime_args to it
call_versioned_contract
Invokes the specified entry_point_name of stored logic at a specific contract_package_hash address, for the most current version of a contract package by default or a specific contract_version if one is provided, and passing the provided runtime_args to it
emit_message
Emits a message on a topic.
get_addressable_entity
Returns whether or not the addressable entity is turned on.
get_block_height
Returns the block height.
get_blocktime
Returns the current BlockTime.
get_call_initiator
Returns the call stack initiator
get_call_stack
Returns the call stack.
get_caller
Returns the caller of the current context, i.e. the AccountHash of the account which made the deploy request.
get_immediate_caller
Returns the immidiate caller within the call stack.
get_key
Returns the requested named Key from the current context.
get_named_arg
Returns given named argument passed to the host for the current module invocation.
get_parent_block_hash
Returns the parent block hash.
get_phase
Returns the current Phase.
get_protocol_version
Returns the protocol version.
get_state_hash
Returns the state root hash.
has_key
Returns true if name exists in the current context’s named keys.
is_valid_uref
Validates uref against named keys.
list_authorization_keys
Returns the set of AccountHash from the calling account’s context authorization_keys.
list_named_keys
Returns the named keys of the current context.
manage_message_topic
Manages a message topic.
print
Prints a debug message
put_key
Stores the given Key under name in the current context’s named keys.
random_bytes
Returns 32 pseudo random bytes.
remove_key
Removes the Key stored under name in the current context’s named keys.
ret
Returns the given CLValue to the host, terminating the currently running module.
revert
Stops execution of a contract and reverts execution effects with a given ApiError.
try_get_named_arg
Returns given named argument passed to the host for the current module invocation. If the argument is not found, returns None.