Inspiration

The demonstration in the AO Cookbook on creating chatrooms and sending messages between friends inspired me. It made me realize that AO's principles and technical architecture are naturally suited for developing an instant messaging app.

What it does

AO-Chat fully leverages Arweave's distributed storage and AOS's real-time communication protocol to provide users with a secure, reliable, and feature-rich instant messaging service. The application primarily includes two major functional modules:

  1. Text Chat
  2. Video Chat

These two modules differ in technical implementation but share the underlying Arweave and AOS infrastructure.

In our initial design, AO-Chat is intended to support the following features:

1. Text Chat Features

  1. User Login and Contact Management
    • Development completed and implemented in the demo.
  2. Chat Session Management
    • Development completed and implemented in the demo.
  3. Message Encryption
    • Component development completed but not implemented in the demo.
  4. Chat History Storage
    • Partially developed and implemented in the demo.
  5. Multimedia Transmission
    • Component pending development.

2. Video Chat Features

  1. Video Streaming
    • Component development completed but not implemented in the demo.
  2. Video Recording and Storage
    • Component development completed but not implemented in the demo.
  3. Video Call Controls
    • Component development completed but not implemented in the demo.

How we built it

1. Text Chat Features

  1. User Login and Contact Management

    • Users log in to the chat app using their AOS address.
    • Contact information stores AOS addresses to facilitate establishing chat processes.
  2. Chat Session Management

    • The chat initiator creates a chat process in AOS.
    • Prebuilt chat modules (e.g., chatroom.lua) are loaded into the process.
    • Invitations are sent to other users, who can join the chat by accepting the invite.
  3. Message Encryption

    • ECDH is used for key exchange via the process, and AES-GCM ensures message confidentiality and integrity during transmission.
  4. Chat History Storage

    • By default, chat history is stored in the process table.
    • Users can choose to store important chat history in Arweave for permanent storage.
  5. Multimedia Transmission

    • Upload images/videos to Arweave.
    • Reference and preview these files in chats using their TXID.

2. Video Chat Features

  1. Video Streaming

    • Utilizes the WebRTC real-time video communication protocol for peer-to-peer audio and video stream transmission.
  2. Video Recording and Storage

    • Captures the entire video call using WebRTC's screen sharing and recording features.
    • Employs efficient video encoding and container formats (e.g., VP9 + WebM) to compress the size of recorded files.
    • Offers two storage options: "Permanent Storage" on Arweave and "Temporary Storage" on Arfleet.
  3. Video Call Controls

    • Implements call, answer, and hang-up control logic.
    • Uses the process to transmit signaling.

Challenges we ran into

  1. The descriptions of API data structures in the Cookbook and various SDKs were incomplete. We had to debug extensively by adding significant amounts of code to Lua scripts loaded into processes and repeatedly testing interactions between the front and back ends to infer the structure of API request data in AO.
  2. While Permaweb is excellent for deploying static websites or apps, its compatibility with dynamic websites and apps is limited. We had to deploy the app on Vercel as a compromise.

Accomplishments that we're proud of

  1. Achieved the ability to handle data storage, management, and interactions entirely through processes, which were traditionally handled by centralized servers in Web2, creating a fully decentralized instant messaging app.
  2. In video chat component testing, we used libp2p and WebRTC to implement fully decentralized video chat functionality. We are currently conducting stability tests.

Once completed, this app will be the first to implement a fully decentralized instant messaging software.

What we learned

  1. How to use processes to replicate the functionalities of centralized servers in Web2.
  2. How to build custom modules to meet specific functional requirements.

What's next for AO-Chat

  1. Use custom modules to spawn chatroom processes, allowing chatroom processes to handle text chat management. This will enable flexible options for one-to-one and group chats while keeping contact management in the current process.
  2. Implement encrypted chat messages.
  3. Enable multimedia file and sticker transmission.
  4. Support permanent storage of important chat information.
  5. Achieve fully decentralized video chat functionality, with optional video recording and Arweave uploads for permanent storage.

Built With

  • arweave
  • json
  • libp2p
  • lua
  • module
  • permaweb
  • react
  • tailwincss
  • typescript/javascript
  • wasm
Share this project:

Updates