L2PS Messaging System
Within theL2PS 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:
sendMessage
This method compiles and send aMessage within an EncryptedTransactionto the on-chain Subnet.
Arguments
address: string // The Demos Address of the receivermessage: 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 retrievemessageId: string // The messageId of the specific message to fetch
Returns
Promise<Message>