- Overview
- Features
- Technology Stack
- Architecture
- Prerequisites
- Installation
- Smart Contract
- Testing
- Usage
- API Documentation
- Contributing
- Developer
- License
Chatty is a cutting-edge decentralized chat application that combines the power of blockchain technology with modern web development. Built on Ethereum, it allows users to create and join paid chat channels using smart contracts, while enjoying real-time messaging through WebSocket connections.
- π Blockchain Authentication - Secure wallet-based login
- π° Monetized Channels - Create paid access channels
- β‘ Real-time Messaging - Instant communication via Socket.io
- π¨ Modern UI/UX - Glassmorphism design with smooth animations
- π§ͺ Fully Tested - Comprehensive smart contract testing suite
- MetaMask Integration - Seamless wallet connectivity
- Smart Contract Channels - Decentralized channel management
- NFT Membership - Channel access tokens as NFTs
- Ethereum & Testnets - Support for multiple networks
- Instant Messaging - Real-time chat functionality
- Channel-based Communication - Organized discussion spaces
- Message History - Persistent chat storage
- User Identification - Wallet address-based identity
- Responsive Design - Mobile and desktop optimized
- Glassmorphism UI - Modern blur effects and transparency
- Smooth Animations - Fluid transitions and micro-interactions
- Dark Theme - Eye-friendly interface design
- Wallet Authentication - No centralized account system
- Paid Access Control - Smart contract-enforced permissions
- Decentralized Storage - No single point of failure
- React 18.2.0 - Modern JavaScript library for building user interfaces
- CSS3 - Advanced styling with custom properties and animations
- Socket.io Client 4.8.1 - Real-time bidirectional event-based communication
- Ethers.js 6.4.0 - Ethereum wallet implementation and utilities
- Node.js - JavaScript runtime environment
- Express.js 5.1.0 - Fast, unopinionated, minimalist web framework
- Socket.io 4.8.1 - Real-time communication server
- CORS 2.8.5 - Cross-origin resource sharing middleware
- Solidity 0.8.20 - Smart contract programming language
- Hardhat 2.26.1 - Ethereum development environment
- OpenZeppelin 5.4.0 - Secure smart contract library
- Ethers.js 6.4.0 - Ethereum interaction library
- Yarn 4.6.0 - Package manager
- ESLint 8.57.0 - Code linting and style enforcement
- Chai 4.2.0 - BDD/TDD assertion library
- TypeScript 5.9.2 - Type-safe JavaScript development
- Hardhat Testing - Smart contract testing suite
- Mocha - JavaScript test framework
- React Testing Library - Frontend component testing
Chatty.sol (ERC721)
βββ Channel Management
βββ NFT Minting for Access
βββ Payment Processing
βββ Ownership Control
server.js
βββ Socket.io Server
βββ Message Broadcasting
βββ Real-time Communication
βββ CORS Configuration
React App
βββ Wallet Integration (MetaMask)
βββ Smart Contract Interaction
βββ Real-time UI Updates
βββ Modern Component Architecture
Before you begin, ensure you have the following installed:
- Node.js (v16.0.0 or later)
- Yarn (v4.6.0 or later)
- MetaMask browser extension
- Git for version control
- OS: Windows 10+, macOS 10.14+, or Linux
- Memory: 4GB RAM minimum, 8GB recommended
- Storage: 1GB free space
git clone https://github.com/kellspell/chatty.git
cd chatty# Install all dependencies
yarn install
# Or if you prefer npm
npm installCreate a .env file in the root directory:
# Alchemy API Configuration
ALCHEMY_API_URL=your_alchemy_api_url_here
# Private Keys (NEVER commit these to version control)
PRIVATE_KEY_METAMASK=your_private_key_here
# API Keys
ETHERSCAN_API_KEY=your_etherscan_api_key
COINMARKETCAP_API_KEY=your_coinmarketcap_api_key# Start Hardhat local network
npx hardhat node# Deploy to local network
npx hardhat run scripts/Deploy.js --network localhost
# Deploy to Sepolia testnet
npx hardhat run scripts/Deploy.js --network sepolia# Terminal 1: Start the React frontend
yarn start
# Terminal 2: Start the Socket.io backend
node server.js
# Terminal 3: Keep Hardhat node running
npx hardhat nodeThe core smart contract inherits from OpenZeppelin's ERC721 standard and implements:
createChannel()- Create new paid chat channelsmint()- Purchase access to channels (mints NFT)getChannel()- Retrieve channel informationchannelCount()- Get total number of channelswithdraw()- Owner withdrawal of collected fees
- ERC721 Compliance - Standard NFT functionality
- Access Control - Only channel payment grants access
- Fee Collection - Automatic payment processing
- Channel Metadata - Name, description, cost, creator info
- Owner-only Functions - Channel creation restricted to owner
- Payment Validation - Exact payment required for access
- Reentrancy Protection - Safe withdrawal patterns
- Input Validation - Comprehensive parameter checking
# Run all tests
yarn test
# Run tests with coverage
yarn coverage
# Run specific test file
npx hardhat test test/Chatty.test.jsThe test suite covers:
- β Contract deployment and initialization
- β Channel creation functionality
- β User joining and payment processing
- β NFT minting and ownership
- β Fee withdrawal mechanisms
- β Access control and permissions
Chatty
Deployment
β Sets Name (45ms)
β Sets Symbol (38ms)
β Sets Owner (41ms)
Creating Channels
β Returns total Number of Channels (52ms)
β Returns Channel Details (48ms)
Joining Channels
β join the user (89ms)
β Increases total supply (67ms)
β Updates the contract balance (71ms)
Withdrawing
β Updates the owner balance (95ms)
β Updates the contract balance (78ms)
9 passing (1.2s)- Install MetaMask browser extension
- Click "Connect Wallet" in the application
- Approve the connection request
- Browse available channels in the sidebar
- Click on a channel to view details
- Pay the required amount to join
- Start chatting immediately
- Select an active channel
- Type your message in the input field
- Press Enter or click Send
- Messages appear in real-time for all users
- Deploy the smart contract as the owner
- Use the
createChannelfunction with:- Channel name and description
- Access cost in ETH
- IPFS image URL (optional)
// Request all messages for current channel
socket.emit('get messages');
// Send a new message
socket.emit('new message', {
channel: '1',
account: '0x...',
text: 'Hello World!',
timestamp: new Date().toISOString()
});// Receive all messages
socket.on('get messages', (messages) => {
// Handle messages array
});
// Receive new message broadcast
socket.on('new message', (messages) => {
// Handle updated messages array
});
// Connection established
socket.on('connect', () => {
// Handle connection
});function channelCount() public view returns (uint256)
function getChannel(uint256 _channelId) external view returns (Channel memory)
function hasJoined(uint256 _channelId, address _user) public view returns (bool)
function totalSupply() public view returns (uint256)function createChannel(
string memory _name,
string memory _description,
string memory _imageUrl,
uint256 _cost,
address _creator,
uint256 _createdAt
) public onlyOwner
function mint(uint256 _id) public payable
function withdraw() public onlyOwnerWe welcome contributions to Chatty! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Add tests for new functionality
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style and conventions
- Write comprehensive tests for new features
- Update documentation for any API changes
- Ensure all tests pass before submitting PR
- π Bug fixes and improvements
- β¨ New features and enhancements
- π Documentation improvements
- π§ͺ Additional test coverage
- π¨ UI/UX enhancements
Kellspell is a passionate full-stack blockchain developer with expertise in:
- π Blockchain Development - Solidity, Smart Contracts, DeFi
- βοΈ Frontend Technologies - React, JavaScript, Modern CSS
- π§ Backend Systems - Node.js, Express, Database Design
- π§ͺ Testing & DevOps - Automated Testing, CI/CD, Cloud Deployment
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenZeppelin - For secure smart contract implementations
- Hardhat Team - For excellent Ethereum development tools
- React Team - For the amazing frontend framework
- Socket.io - For real-time communication capabilities
- Ethereum Community - For continuous innovation and support
Built with β€οΈ by Kellspell
If you found this project helpful, please give it a β

