This app showcases the new Sui Stack Messaging SDK. The SDK provides a complete, end-to-end encrypted messaging solutions powered by Sui, Walrus, and Seal. The SDK enables developers to integrate secure, wallet-linked messaging directly into apps without building custom backends. These conversations are private by default, recoverable across devices, and composable with other applications.
Visit the SDK's repo for more details on the features, use cases, and non-goals.
You can try out a live deployment of this site at https://chatty.wal.app
Follow the steps below to run the website locally.
- Clone the repo
- In the root directory, install the dependencies by running
pnpm install
- Start up the local server by running
pnpm dev
and visit the site outputted in your terminal
Follow the steps below to learn how to build this site from scratch.
The starting point for this app is the Mysten Lab's counter example app. Navigate to the directory you want to build this app in and run pnpm create @mysten/dapp
- Choose the
react-e2e-counter
option - Input whatever you want to call this app
- Once built, navigate to the root directory of the app (it should be called whatever your input was in the previous step)
The SDK's npm package is still in the process of being publish so the SDK needs to be manually installed. Visit the SDK's Installation Guide for instructions on how to install the SDK.
The SDK uses Seal for encrypting messages and attachments. The Seal SDK requires a SessionKey
, which contains a signature from the connected account and allows the app to retrieve the Seal decryption keys for a limited time without requiring repeated user confirmations. Visit the Seal docs for more details on Seal sessions.
Once an account is connected, the app requests a signature from the user that will be used to generate the SessionKey
for the session. The session in this app lasts 30 minutes. The SessionKey
is stored in the browser's local storage to persist the SessionKey
through refreshes (as long as the 30 minute window hasn't expired).
This is all handled in the SessionKeyProvider.tsx
component. The status is displayed on the app with the MessagingStatus
component.
Create a provider that creates a Seal + Messaging client using the connected account and the previously generated SessionKey
. Visit the Messaging SDK docs to get more details on creating the complete client.
This is managed in MessagingClientProvider.tsx
.
This app uses a single useMessaging.ts
hook that holds all of the functionality and state for listing Channels
, creating Channels
, receiving and sending messages, and other details.
The primary structure in the Messaging SDK are Channels
. Channels
are the core messaging containers in this SDK - encrypted communication spaces between users on the Sui blockchain. Think of them as secure, decentralized chat rooms with strong access control and end-to-end encryption. Channels
hold membership details, messages, along with other details. Visit the Channel
source code for the full structure.
The Messaging SDK provides createChannelFlow
to facilitate the process of creating a new Channel
. Creating a Channel
is a multi-step process that involves creating the on-chain Channel
object, generating and distributing the CreatorCap
and MemberCap
s, and generating and attaching the encryption key. Visit the createChannelFlow
API reference for more details. Note that executeCreateChannelTransaction
is useful if you are creating channels in a server, i.e. when you have direct access to the Signer
.
The UI for creating a Channel
is in the CreateChannel
component.
This app uses getChannelObjectsByAddress
to fetch and list all of the Channels
or chat rooms that the connected user is in. This getChannelObjectsByAddress
function works by fetching all of the MemberCaps
that the user has and retrieves the Channel
data for each membership. Visit the getChannelObjectsByAddress
API reference for more details.
The UI for listing Channel
s is in the ChannelList
component.
This app uses getChannelObjectsByChannelIds
to fetch the details for specific Channel
s, getChannelMessages
to retrieve all of the messages in the Channel
, and sendMessage
to send new messages.
The UI for displaying a Channel
and send messages is in the Channel
component.
Join the discord to ask questions about the example app and the SDK!