Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • sendMessage
  • retrieveMessages
  • retrieveSingleMessage
  1. SDK
  2. WebSDK
  3. L2PS SDK

L2PS Messaging System

Within the L2PS class, a handful of high level methods are exposed to execute routine operations easily, without code redundancy.

In this chapter, we will see the messaging system enabled by the Subnets logic.

Before diving into the methods, it is useful to take a look at the Messagetype:

type Message = { 
    messageId: string 
    sender: string 
    receiver: string 
    message: string 
    timestamp: number 
}

The type is mostly handled automatically by the methods below.

sendMessage

This method compiles and send a Message within an EncryptedTransactionto the on-chain Subnet.

Arguments

  • address: string // The Demos Address of the receiver

  • message: string // The message to be included in the transaction

Returns

  • Promise<string> // The messageId of the specific Subnet message after being accepted by the network

retrieveMessages

This method returns all the messages received by an address in the Subnet.

NOTE: If the retriever is not authorized to read those messages, they will be denied by the Subnet.

Arguments

  • address: string // The address whose messages we want to retrieve

Returns

  • Promise<MessageMap> // A Map<string Message> object (messageId -> Message)

retrieveSingleMessage

This method is used to retrieve a single message pertaining to an address.

Arguments

  • address: string // The address whom message we want to retrieve

  • messageId: string // The messageId of the specific message to fetch

Returns

  • Promise<Message>

PreviousInteracting with the L2PSNextInstant Messaging

Last updated 5 months ago