Skip to main content

Module chain

Module chain 

Source
Expand description

Remote chain protocol methods (tags 76-103).

Translates between SCALE-encoded binary messages from the product-SDK and JSON-RPC for smoldot. Each function either:

  • Parses a smoldot JSON-RPC notification and encodes the result as SCALE, or
  • Encodes a SCALE response for a given chain request tag.

All response messages follow the envelope: request_id (SCALE str) + response_tag (u8) + v1 (0x00) + payload

Structs§

RuntimeSpec
Parsed runtime specification fields.
StorageResultItem
A single storage result item returned in OperationStorageItems.

Enums§

ChainHeadEvent
Strongly-typed representation of every chainHead_v1_followEvent variant.
RuntimeInfo
Runtime information attached to Initialized / NewBlock events.

Constants§

TAG_CHAIN_HEAD_BODY_REQ
TAG_CHAIN_HEAD_BODY_RESP
TAG_CHAIN_HEAD_CALL_REQ
TAG_CHAIN_HEAD_CALL_RESP
TAG_CHAIN_HEAD_CONTINUE_REQ
TAG_CHAIN_HEAD_CONTINUE_RESP
TAG_CHAIN_HEAD_FOLLOW_INTERRUPT
TAG_CHAIN_HEAD_FOLLOW_RECEIVE
TAG_CHAIN_HEAD_FOLLOW_START
TAG_CHAIN_HEAD_FOLLOW_STOP
TAG_CHAIN_HEAD_HEADER_REQ
TAG_CHAIN_HEAD_HEADER_RESP
TAG_CHAIN_HEAD_STOP_OP_REQ
TAG_CHAIN_HEAD_STOP_OP_RESP
TAG_CHAIN_HEAD_STORAGE_REQ
TAG_CHAIN_HEAD_STORAGE_RESP
TAG_CHAIN_HEAD_UNPIN_REQ
TAG_CHAIN_HEAD_UNPIN_RESP
TAG_CHAIN_SPEC_CHAIN_NAME_REQ
TAG_CHAIN_SPEC_CHAIN_NAME_RESP
TAG_CHAIN_SPEC_GENESIS_HASH_REQ
TAG_CHAIN_SPEC_GENESIS_HASH_RESP
TAG_CHAIN_SPEC_PROPERTIES_REQ
TAG_CHAIN_SPEC_PROPERTIES_RESP
TAG_CHAIN_TX_BROADCAST_REQ
TAG_CHAIN_TX_BROADCAST_RESP
TAG_CHAIN_TX_STOP_REQ
TAG_CHAIN_TX_STOP_RESP

Functions§

bytes_to_hex
Convert raw bytes [0xab, 0xcd] to "0xabcd".
encode_chain_follow_json_event
Encode a chain-head follow event notification from raw JSON-RPC text.
encode_chain_follow_stop
Encode a synthetic follow stop event for unsupported/disconnected chains.
encode_chain_head_event
Encode a chainHead_v1_followEvent receive message (tag 79).
encode_chain_response_hex
Encode a Result(Hex(), GenericError) response.
encode_chain_response_nullable_hex
Encode a Result(Nullable(Hex()), GenericError) response.
encode_chain_response_nullable_string
Encode a Result(Nullable(str), GenericError) response.
encode_chain_response_operation_started
Encode a Result(OperationStartedResult, GenericError) response.
encode_chain_response_string
Encode a Result(str, GenericError) response.
encode_chain_response_void
Encode a Result(void, GenericError) response.
encode_chain_rpc_error
Encode a chain RPC error using the correct response tag for request_tag.
encode_chain_rpc_json_response
Encode a chain RPC response from raw JSON-RPC text using the correct chain protocol envelope for request_tag.
hex_to_bytes
Convert a "0xabcd" hex string to raw bytes [0xab, 0xcd].
parse_chain_head_json_rpc
Parse a smoldot chainHead_v1_followEvent notification into a ChainHeadEvent.