Messages
Send messages on the private layer
Last updated
Send messages on the private layer
Last updated
To share information on the private layer, it should be wrapped as a message.
To send a message through a public , it needs to be anchored.
The requirement to anchor prevents spam by associating a small cost for each message.
Messages can be encrypted so the data can only be read or processed by a specific LTO account. Encrypting a message is done using the public key of the recipient.
To get the public key from an address, we'll need to resolve the address. This uses the LTO DID resolver internally.
Only accounts that have submitted at least one transaction on the public chain can be resolved.
The recipient can decrypt the message using its private key.
To enhance client-side rendering and improve UX, you can attach metadata to a message before sending it. This metadata allows the receiving wallet to preview the content with a title, description, and thumbnail.
Supported Metadata Fields
type
: A string identifier (e.g., "ownable"
) if type is left undefined the library defaults to "basic", generally advised to explictly use "ownable" if its an ownable.
title
: A short, human-readable title
description
: A brief explanation of the message contents
thumbnail
: A binary image preview (max size: 256KB)
By default, messages are assigned the basic
type, which provides minimal descriptive context. While this is sufficient for most simple message exchanges, it lacks the flexibility needed for richer, more descriptive content.
Starting from versions v0.15.17 and v0.16.9+, support for message metadata and message versioning was introduced. This enhancement allows developers to embed additional context such as a title, description, and a thumbnail directly into the message metadata.
This is particularly valuable for Ownables, where visual and descriptive cues are essential for user comprehension. With metadata support, client-side applications can render messages with meaningful context, without decrypting and parsing message bodies just to extract basic display information. This not only improves performance but also significantly enhances the developer and user experience.
By default, messages are posted through . Instead of depending on the public relay service, you can .