Crate pallet_messages
source ·Expand description
Stores messages for IPFS
and OnChain
Schema payload locations
Quick Links
- Configuration:
Config
- Extrinsics:
Call
- Runtime API:
MessagesRuntimeApi
- Custom RPC API:
MessagesApiServer
- Event Enum:
Event
- Error Enum:
Error
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 IPFSOnChain
: 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/Description | Caller | Payment | Key Events | Runtime Added |
---|---|---|---|---|
add_ipfs_message Add a message to a Schema with an IPFS payload location | Provider | Capacity or Tokens | MessagesInBlock * | 1 |
add_onchain_message Add a message to a Schema with an ON_CHAIN payload location | Provider | Capacity or Tokens | MessagesInBlock * | 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
Name | Description | Query | Runtime Added |
---|---|---|---|
Get Messages v2 | Suggested: Use RPC instead of this storage directly. Storage for the messages by Block number, Schema Id, and Message Index | messagesV2 | 61 |
Get Messages v1 | Removed in Runtime 60 | messages | 1-60 |
See the Rust Docs for additional state queries and details.
RPCs
Note: May be restricted based on node settings and configuration.
Name | Description | Call | Node Version |
---|---|---|---|
Get Messages by Schema Id | Fetch paginated messages for a specific Schema Id in the given block range for a given Schema Id | getBySchemaId | v1.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
- Index of message in the block
- Payloads stored offchain contain a tuple of (bytes(the payload reference), payload length).