Crate pallet_messages

source ·
Expand description

Stores messages for IPFS and OnChain Schema payload locations

Messages Pallet

Stores block-indexed data for a Schema using OnChain or IPFS payload location.

Summary

Messages stores metadata and message payload data for a set Schema. Message payloads are meant for streaming data, where when the message was sent is the focus. Discovery is via the MessagesInBlock on new blocks or requesting messages from a block. Retrieval is via RPC.

Metadata vs Payload

Messages have both metadata and payloads. The payload should always match the data structure or the message is considered invalid. The metadata is the Block Number, Schema Id, and other data useful for discovering and organizing the payload information.

Payload Options

  • IPFS: Storage of the CID and length of the file on IPFS
  • OnChain: Storage of the entire payload data, usually for sub-256 byte payloads

Message Ordering

Messages are ordered by block number, and within each block, they follow a specific order based on their transaction sequence within that block. This order is immutable.

Actions

The Messages pallet provides for:

  • Adding messages for a given schema
  • Enabling the retrieval of messages for a given schema

Interactions

Extrinsics

Name/DescriptionCallerPaymentKey EventsRuntime Added
add_ipfs_message
Add a message to a Schema with an IPFS payload location
ProviderCapacity or TokensMessagesInBlock*1
add_onchain_message
Add a message to a Schema with an ON_CHAIN payload location
ProviderCapacity or TokensMessagesInBlock*1

* The MessagesInBlock may not occur more than once per block and does not indicate which schema received messages.

See Rust Docs for more details.

State Queries

NameDescriptionQueryRuntime Added
Get Messages v2Suggested: Use RPC instead of this storage directly. Storage for the messages by Block number, Schema Id, and Message IndexmessagesV261
Get Messages v1Removed in Runtime 60messages1-60

See the Rust Docs for additional state queries and details.

RPCs

Note: May be restricted based on node settings and configuration.

NameDescriptionCallNode Version
Get Messages by Schema IdFetch paginated messages for a specific Schema Id in the given block range for a given Schema IdgetBySchemaIdv1.0.0+

See Rust Docs for more details.

Re-exports

Modules

  • migration module
  • The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
  • Autogenerated weights for pallet_messages

Structs

  • A single message type definition.

Type Aliases