somai-terminal
v1.1.4
Published
SomAI Terminal is a blockchain-based AI messaging platform with a terminal-inspired UI built on the Somnia Testnet network.
Readme
SomAI Terminal
SomAI Terminal is a blockchain-based AI messaging platform with a terminal-inspired UI built on the Somnia Testnet network. It combines the power of blockchain technology with AI capabilities to create a unique messaging experience. Users can chat, create custom tokens, and interact with the Somnia blockchain network through an intuitive terminal-style interface.
Features
- Blockchain Messaging: Send and receive messages stored on the Somnia blockchain
- Message Verification: All messages are cryptographically signed for authenticity
- Token Creation: Create your own ERC-20 tokens directly from the chat interface
- AI Integration: Interact with an AI assistant when the blockchain is unavailable
- Terminal UI: Enjoy a nostalgic terminal-inspired user interface
- Network Information: View and configure Somnia Testnet network details
- Responsive Design: Works on both desktop and mobile devices
Technologies Used
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Blockchain: Ethereum/Somnia Testnet, ethers.js
- Smart Contracts: Solidity (ERC-20 Token Factory, Public Chat)
- AI: Gemini API integration
- Styling: Custom terminal-inspired CSS, shadcn/ui components
- Authentication: MetaMask wallet integration
- State Management: React hooks and context
Project Structure
``` somAI-terminal/ ├── app/ # Next.js app directory │ ├── globals.css # Global styles including terminal UI │ ├── layout.tsx # Root layout component │ └── page.tsx # Main application page ├── components/ # React components │ ├── chat-interface.tsx # Chat UI component │ ├── header.tsx # Application header │ ├── message-bubble.tsx # Message display component │ ├── network-info.tsx # Network information display │ ├── terminal-header.tsx # Terminal window header │ ├── token-card.tsx # Token display component │ └── ui/ # UI components (shadcn/ui) ├── hooks/ # Custom React hooks ├── lib/ # Utility functions and services │ ├── ai-service.ts # AI integration service │ ├── chat-service.ts # Blockchain chat service │ ├── contract-abis.ts # Smart contract ABIs │ ├── network-utils.ts # Network utility functions │ ├── token-service.ts # Token creation service │ └── utils.ts # General utility functions └── public/ # Static assets ```
Installation
Prerequisites
- Node.js (v16 or later)
- npm or yarn
- MetaMask browser extension
Setup
Clone the repository: ```bash git clone https://github.com/yourusername/somai-terminal.git cd somai-terminal ```
Install dependencies: ```bash npm install
or
yarn install ```
Create a
.env.localfile in the root directory with the following variables: ``` NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_api_key ```Start the development server: ```bash npm run dev
or
yarn dev ```
Open http://localhost:3000 in your browser to see the application.
Usage
Connecting to Somnia Testnet
- Install MetaMask if you haven't already
- Click "Connect Wallet" in the application header
- If you're not already on the Somnia Testnet, the application will prompt you to switch networks
- If the automatic network switch fails, go to the "Network" tab for manual configuration instructions
Chatting
- Navigate to the "Chat" tab
- Type your message in the input field at the bottom
- Press Enter or click the send button to send your message
- Your message will be signed with your wallet and stored on the blockchain
- Messages from other users will appear in the chat as they are sent
Creating Tokens
- Navigate to the "Chat" tab
- Use the command format:
/create-token [name] [symbol] [initialSupply]- Example:
/create-token MyToken MTK 1000000
- Example:
- Sign the transaction with your wallet
- Once the transaction is confirmed, your token will be created on the blockchain
- View your created tokens in the "Tokens" tab
Viewing Network Information
- Navigate to the "Network" tab
- View detailed information about the Somnia Testnet
- Use the "Add to MetaMask" button to easily configure your wallet
- Copy network parameters as needed for manual configuration
Network Configuration
Somnia Testnet Details
- Network Name: Somnia Testnet
- RPC URL: https://rpc.ankr.com/somnia_testnet/6e3fd81558cf77b928b06b38e9409b4677b637118114e83364486294d5ff4811
- Chain ID: 50312 (decimal) or 0xC498 (hex)
- Currency Symbol: STT
- Block Explorer: https://shannon-explorer.somnia.network/
Smart Contracts
The application interacts with two main smart contracts on the Somnia Testnet:
Token Factory Contract: Allows users to create custom ERC-20 tokens
- Address:
0x8Cb47d0148bD49EC5B74BE2C9E7149Dfe531c981
- Address:
Public Chat Contract: Stores and retrieves messages on the blockchain
- Address:
0xC0898F0d62692086342c7D660f83b18B2ef22a6A
- Address:
Future Improvements
- End-to-End Encryption: Add encryption for private messaging
- Token Trading: Implement a simple DEX for trading created tokens
- Advanced AI Integration: Enhance AI capabilities with more context awareness
- Multi-Network Support: Add support for additional blockchain networks
- Message Threading: Implement threaded conversations
- User Profiles: Add customizable user profiles with avatars
- File Sharing: Enable sharing of files and images in the chat
- Mobile App: Develop a native mobile application
- Notifications: Add support for browser notifications for new messages
- Theme Customization: Allow users to customize the terminal theme
- Message Search: Implement full-text search for messages
- Token Management: Add more token management features like transfers and allowances
- Governance: Implement DAO-like governance for community decisions
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- Somnia Network for providing the testnet infrastructure
- The ethers.js team for the excellent Ethereum library
- The Next.js and React teams for the frontend framework
- The shadcn/ui team for the UI components
