This is a nostalgic 90s-style chat room implementation with multi-wallet web3 authentication. The application has been modularized for better organization, maintainability, and extensibility.
- 🌴 Retro 90s aesthetic with animated backgrounds, marquees, and Comic Sans
- 👛 Multi-wallet support (MetaMask, Phantom, Brave Wallet, Coinbase Wallet)
- 👤 Custom username creation with colorful chat messages
- 🤖 Simulated users and responses for testing
- 💬 Chat commands like /help, /clear, /shrug, /me, and /color
- 🎨 Fully responsive design that works on mobile and desktop
- 🧩 Modular architecture for easy extension and maintenance
- 🔄 Optional peer-to-peer (P2P) implementation with WebRTC
- 🔐 Web3 wallet-based authentication and message signing
- 👥 Multi-user real-time chat capabilities
tropichat/
├── index.html # Main HTML structure
├── css/
│ └── style.css # All styling for the application
├── js/
│ ├── config.js # Configuration settings and constants
│ ├── wallet.js # Multi-wallet Web3 connection functionality
│ ├── chat.js # Chat room functionality
│ ├── app.js # Main application initialization
│ ├── debug.js # Debug console for troubleshooting
│ ├── p2p-client.js # WebRTC peer-to-peer client (P2P mode)
│ ├── p2p-webrtc-architecture.js # P2P architecture diagram
│ ├── server.js # Backend server (Multi-user mode)
│ ├── socket-client.js # Socket.io client (Multi-user mode)
│ └── web3-p2p-wallet-auth.js # Web3 wallet authentication for P2P
├── docs/
│ ├── MULTI-USER INTEGRATION GUIDE.md # Guide for implementing multi-user mode
│ └── P2P-CHAT-IMPLEMENTATION.md # Guide for implementing P2P mode
└── README.md # This documentation file
Create the folders and files as shown in the structure above. Place each file in its corresponding directory.
Copy the entire
tropichatdirectory to your website's root folderInclude it in your main page with:
<iframesrc="/tropichat/index.html" style="width: 100%; height: 600px; border: none;"></iframe>
Or link to it from your navigation:
<ahref="/tropichat/index.html">Join Our Chat Room</a>
The chat room supports multiple wallet providers:
- Ethereum-based wallets: MetaMask, Brave Wallet, Coinbase Wallet, Trust Wallet
- Solana-based wallets: Phantom
- More can be added by extending the wallet.js module
Users only need to have one of these wallets installed in their browser to connect.
TropiChat now offers multiple implementation options:
The default mode is a client-side only demo that simulates chat with mock responses. This is perfect for testing and development.
For a full implementation with server-side functionality, you'll need:
- Node.js with Express for the backend
- Socket.io for real-time communication
- MongoDB or another database to store chat history and user information
Backend Implementation Example:
// server.jsconstexpress=require('express');consthttp=require('http');constsocketIo=require('socket.io');constmongoose=require('mongoose');const{ ethers }=require('ethers');// Initialize serverconstapp=express();constserver=http.createServer(app);constio=socketIo(server);// Serve static filesapp.use(express.static('public'));// Connect to databasemongoose.connect('mongodb://localhost/tropichat',{useNewUrlParser: true,useUnifiedTopology: true});// Define schemasconstUser=mongoose.model('User',{username: String,wallet: String,provider: String,color: String,lastSeen: Date});constMessage=mongoose.model('Message',{username: String,wallet: String,color: String,text: String,timestamp: Date});// Socket.io connectionio.on('connection',(socket)=>{console.log('New client connected');// Handle user joinsocket.on('join',async(userData)=>{const{ username, wallet, color, provider }=userData;// Save or update userawaitUser.findOneAndUpdate({ wallet },{ username, wallet, color, provider,lastSeen: newDate()},{upsert: true});// Add user to socket roomsocket.join('main-room');// Broadcast user joinedio.to('main-room').emit('user-joined',{
username,
color,timestamp: newDate()});// Send last 50 messagesconstlastMessages=awaitMessage.find().sort({timestamp: -1}).limit(50).lean();socket.emit('message-history',lastMessages.reverse());});// Handle chat messagesocket.on('chat-message',async(messageData)=>{const{ text, username, wallet, color }=messageData;// Save messageconstmessage=newMessage({
username,
wallet,
color,
text,timestamp: newDate()});awaitmessage.save();// Broadcast messageio.to('main-room').emit('chat-message',{
username,
color,
text,timestamp: newDate()});});// Handle disconnectsocket.on('disconnect',()=>{console.log('Client disconnected');});});// Start serverconstPORT=process.env.PORT||3000;server.listen(PORT,()=>{console.log(`Server running on port ${PORT}`);});See the MULTI-USER INTEGRATION GUIDE.md for more detailed implementation instructions.
TropiChat now supports a decentralized peer-to-peer architecture using WebRTC:
- Direct Communication: Users connect directly to each other without messages passing through a central server
- Enhanced Privacy: Messages can be end-to-end encrypted using wallet keys
- Wallet Authentication: Uses wallet signatures to verify user identity
- Minimal Server: Only requires a small signaling server for initial connections
P2P Implementation Steps:
- Set up a minimal signaling server:
// Minimal signaling server exampleconstexpress=require('express');consthttp=require('http');constsocketIo=require('socket.io');constapp=express();constserver=http.createServer(app);constio=socketIo(server);io.on('connection',(socket)=>{console.log('New connection:',socket.id);// Handle authenticationsocket.on('authenticate',(userData)=>{// Verify wallet signature (can be added)socket.broadcast.emit('peer_joined',userData);});// WebRTC signalingsocket.on('signal',(data)=>{const{ peerId, signal }=data;io.to(peerId).emit('signal',{peerId: socket.id,
signal
});});// Handle disconnectionsocket.on('disconnect',()=>{socket.broadcast.emit('peer_left',{id: socket.id});});});server.listen(3000,()=>console.log('Signaling server running on port 3000'));- Include WebRTC libraries:
<scriptsrc="https://cdn.socket.io/4.5.4/socket.io.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/npm/simple-peer@9.11.1/simplepeer.min.js"></script>For complete P2P implementation details, see the P2P-CHAT-IMPLEMENTATION.md guide.
The chat room includes a built-in debug console that can help troubleshoot wallet connection issues:
Accessing the Debug Console:
- A small "Debug" button appears in the bottom right corner
- Click it to toggle the debug console
Available Debug Commands:
help- Show available commandsclear- Clear the consoleinfo- Show system informationdetect- Detect available wallet providersconnect- Try to connect to a walletlocalStorage- Show stored data
Troubleshooting Wallet Connection:
- If wallet connection fails, open the debug console and type
infoto see if wallets are detected - Use
detectto force a new wallet detection scan - Check browser console (F12) for additional error messages
- If wallet connection fails, open the debug console and type
Disabling Debug Mode:
- For production deployment, you can disable debug mode by setting
debug: falsein the appState object in app.js
- For production deployment, you can disable debug mode by setting
You can customize TropiChat by:
- Modifying
config.jsto change settings, mock users, and responses - Updating
style.cssto change the visual appearance - Adding new commands in the
handleCommandfunction inchat.js - Adding new emoji options to the emoji picker in
index.html - Implementing new wallet providers in
wallet.js
When implementing this chat in production:
- Always verify wallet signatures on the server to prevent address spoofing
- Implement rate limiting to prevent spam
- Add moderation tools for inappropriate content
- Consider encrypting messages for privacy
- Store sensitive data securely and follow data protection regulations
The P2P implementation supports several advanced features:
End-to-End Encryption:
- Messages can be encrypted using wallet keys
- Only the intended recipients can decrypt messages
NFT-Gated Chat Rooms:
- Create exclusive chat rooms that require NFT ownership
- Verify NFT ownership through wallet authentication
Decentralized Identity:
- Integrate with DIDs (Decentralized Identifiers)
- Create persistent user profiles without central servers
Distributed Data Storage:
- Store chat history using IPFS
- Implement Orbit-DB for distributed databases# tropiChat
This project is licensed under the MIT License with Additional Clauses - see the LICENSE file for details.
Created by @kitbaroness for DevCorp Organization on GitHub.