Status: Active Development | Version: 0.4.1
Deployed: caishen.iseethereaper.com
A Telegram-first AI wallet assistant for the Sui blockchain with zkLogin (Google OAuth), Slush/Wallet Standard support, AI-driven natural language intents, and a React-based signing web dApp.
- Python 3.11+ (bot backend)
- Node.js 20+ (web dApp)
- PostgreSQL 16 (database)
- Docker (recommended for deployment)
# 1. Bot (Python/aiogram)
cd bot
python -m venv .venv && source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -r requirements.txt
cp .env.example .env # Configure: TELEGRAM_BOT_TOKEN, POSTGRES_*, GEMINI_API_KEY
python -m src.bot.bot
# 2. Web dApp (React/Vite)
cd services/web-dapp
npm install
cp .env.example .env # Configure: VITE_API_BASE_URL, VITE_GOOGLE_CLIENT_ID, VITE_SUI_NETWORK
npm run dev
# 3. Database
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=caishen postgres:16
psql -U postgres -d caishen -f database/init/001_schema.sqlπ Full guides: QUICKSTART.md | INSTALLATION.md
- π¬ Natural Language Interface - Chat or voice commands powered by Gemini 2.0 Flash
- π zkLogin + Wallet Standard - Google OAuth zkLogin or connect Slush/any Sui wallet
- π Persistent Wallet Linking - Bind Telegram account to wallet via secure web flow
- π° Sui Blockchain Integration - Balance, send, NFTs, transaction history
- π― AI Function Calling - 5+ tools: balance, send, contacts, history, portfolio
- π± Contact Management - Store friendly names for addresses (database + on-chain registry)
- π Smart Contracts - Batch transfers, contact registry, spending guardrails (Move)
- π€ Voice Input - Gemini multimodal transcription (replaces Whisper)
βββββββββββββββββββ HTTPS/Webhook ββββββββββββββββββββ
β Telegram β ββββββββββββββββββββββΆβ nginx (SSL) β
β Users β β Port 443/80 β
βββββββββββββββββββ ββββββββββ¬ββββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Python Bot β β PostgreSQL β β React Web dApp β
β (aiogram) β<<β Database β β (Vite) β
β Port 3001 β β Port 5432 β β Static Build β
ββββββββββ¬βββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ
β β
β Sui RPC β zkLogin OAuth
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Sui Blockchain β β Mysten Labs β
β (testnet) β β Salt/Prover β
βββββββββββββββββββ βββββββββββββββββββ
- Bot: Python 3.11, aiogram, aiohttp, httpx (Sui RPC), google-genai (Gemini)
- Web dApp: React 18, Vite, @mysten/dapp-kit, @mysten/sui/zklogin
- Database: PostgreSQL 16 (users, wallet_links, contacts, linking_sessions)
- Chain: Sui testnet/mainnet via JSON-RPC
- AI: Gemini 2.0 Flash (NLP + voice transcription + function calling)
- Infra: nginx (reverse proxy + SSL), Docker Compose
User sends /start in Telegram
β
Bot creates 15-min token, returns link:
https://caishen.iseethereaper.com/link/@username?token=abc123
β
User chooses on web page:
[Create zkLogin wallet] or [Connect Slush/other wallet]
β
If zkLogin: Google OAuth β Mysten salt/prover β zkLogin address
If Slush: Wallet Standard connection β address
β
Telegram Login Widget verifies Telegram account (HMAC)
β
Bot API binds: telegram_id + wallet_address + zkLogin salt/sub
β
Done! Now user can use /balance, /send, /history, AI commands
# Balance check
User: "/balance"
Bot: "π° Your balance: 1,234.56 SUI"
# Natural language send
User: "Send 10 SUI to Alice"
Bot: [Gemini parses intent] β [Builds unsigned tx] β [Returns signing link]
User clicks link β Web dApp opens β Wallet signs β Tx confirmed
# Voice command
User: [π€ Voice note] "What's my transaction history?"
Bot: [Gemini transcribes] β [Fetches history] β "π Last 5 transactions..."
# Contact management
User: "/contacts add Alice 0x1234..."
Bot: "β
Added Alice"
User: "Send 5 SUI to Alice"
Bot: [Resolves Alice β 0x1234...] β [Builds tx]On-chain smart contracts deployed to Sui. See SMART_CONTRACTS.md for full documentation.
| Contract | Purpose | Key Benefit | Status |
|---|---|---|---|
| BatchTransfer | Multi-recipient payments | "Pay 10 people" in 1 tx | β Implemented, but not used yet |
| ContactRegistry | On-chain address book | Portable, shared contacts | β Implemented, but not used yet |
| SpendingGuardian | Rate-limited transfers | Anti-theft, spending limits | β Implemented, but not used yet |
# Build contracts
cd move && sui move build
# Run tests
sui move test
# Deploy to testnet
sui client publish --gas-budget 100000000"Send 5 SUI to alice, bob, and carol" β BatchTransfer.batch_send_sui()
"Add alice as 0x123..." β ContactRegistry.add_contact()
"Set my daily limit to 100 SUI" β SpendingGuardian.set_limit()
"Freeze my account" β SpendingGuardian.freeze()
.
βββ bot/ # Python Telegram Bot
β βββ src/
β β βββ bot/
β β β βββ bot.py # Main bot entry point (aiogram)
β β β βββ handlers/ # Command handlers
β β βββ services/
β β β βββ gemini.py # Gemini AI integration
β β β βββ sui.py # Sui RPC client (httpx)
β β βββ database/
β β β βββ postgres.py # PostgreSQL connection
β β βββ utils/
β β βββ audio_processor.py # Voice transcription
β βββ requirements.txt
β βββ Dockerfile
β
βββ services/
β βββ web-dapp/ # React Signing Interface
β β βββ src/
β β β βββ App.tsx # Main app with wallet connection
β β β βββ LinkPage.tsx # /link/:handle page (zkLogin/Slush)
β β β βββ main.tsx # Vite entry point
β β βββ package.json
β β βββ vite.config.ts
β β
β βββ transaction-builder/ # (Legacy - now in bot)
β βββ user-service/ # (Legacy - now in bot)
β βββ zklogin-service/ # (External Mysten APIs)
β βββ nlp-service/ # (Now Gemini in bot)
β βββ notification-service/ # (Future - webhooks)
β
βββ move/ # Smart Contracts (Sui Move)
β βββ sources/
β β βββ batch_transfer.move # Multi-recipient transfers
β β βββ contact_registry.move # On-chain address book
β β βββ spending_guardian.move # Rate-limited spending
β βββ tests/
β βββ Move.toml
β
βββ database/
β βββ init/
β βββ 001_schema.sql # PostgreSQL schema (users, wallet_links, contacts)
β
βββ nginx/
β βββ nginx.conf # Main nginx config (SSL termination)
β βββ caishen.iseethereaper.com.conf # Site-specific config
β βββ ssl/ # SSL certificates (Let's Encrypt)
β
βββ docker-compose.yml # Multi-service orchestration
βββ .env.example # Environment template
βββ README.md # This file
cd bot
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Run with hot reload
python -m src.bot.bot
# Run tests
pytest tests/cd services/web-dapp
npm install
npm run dev # Runs on http://localhost:5173
# Build for production
npm run build # Output: out/cd move
sui move build
sui move test
sui client publish --gas-budget 100000000# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token_from_BotFather
TELEGRAM_WEBHOOK_SECRET=random_secret_for_webhook_validation
WEBHOOK_BASE_URL=https://caishen.iseethereaper.com
WEBAPP_URL=https://caishen.iseethereaper.com
# Database
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=caishen
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_password
# AI
GEMINI_API_KEY=your_google_ai_api_key
# Sui
SUI_NETWORK=testnet # or mainnet
SUI_RPC_URL=https://fullnode.testnet.sui.io:443VITE_API_BASE_URL=https://caishen.iseethereaper.com
VITE_TELEGRAM_BOT_USERNAME=your_bot_username
VITE_GOOGLE_CLIENT_ID=your_google_oauth_client_id
VITE_SUI_NETWORK=testnet
VITE_ZKLOGIN_SALT_SERVICE_URL=https://salt.api.mystenlabs.com/get_salt
VITE_ZKLOGIN_PROVER_URL=https://prover-dev.mystenlabs.com/v1 # testnet# 1. Clone and configure
git clone https://github.com/your-org/caishen.git
cd caishen
cp .env.example .env
# Edit .env with production values
# 2. Build and deploy
docker-compose up -d --build
# 3. Sync web dApp static files
docker-compose exec web-dapp npm run build
sudo rsync -av --delete services/web-dapp/out/ /var/www/caishen/web/
# 4. Set webhook
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook" \
-d "url=https://caishen.iseethereaper.com/webhook" \
-d "secret_token=<TELEGRAM_WEBHOOK_SECRET>"
# 5. Reload nginx
sudo systemctl reload nginxSee DEPLOY_TO_VPS.md for detailed instructions.
# Bot tests (Python)
cd bot && pytest
# Move contract tests
cd move && sui move test
# Web dApp tests
cd services/web-dapp && npm testError: "Token expired or invalid"
Cause: Linking token is valid for 15 minutes only
Fix: Return to Telegram bot and run /start again for a fresh link
Error: Telegram webhook returns 404 or 405
Cause: nginx not proxying correctly to bot on port 3001
Fix:
# Check nginx config
sudo nginx -t
# Verify bot is running
docker-compose logs telegram-bot
# Check port binding
sudo netstat -tlnp | grep 3001Error: "Chat not found" when bot tries to message user
Cause: User never sent /start to bot
Fix: User must initiate conversation with bot first
Error: Google OAuth fails or prover errors
Fix:
- Verify
VITE_GOOGLE_CLIENT_IDmatches OAuth consent screen - Add authorized redirect URI:
https://caishen.iseethereaper.com/* - Check Mysten prover URL matches network (testnet vs mainnet)
Error: Gemini function call fails with "invalid parameters"
Cause: Tool schema mismatch or missing required fields
Fix: Check bot/src/services/gemini.py tool definitions match handlers
Error: Web dApp shows old version after deployment
Fix:
# Force rebuild and sync
cd services/web-dapp
rm -rf out/
npm run build
sudo rsync -av --delete out/ /var/www/caishen/web/
sudo systemctl reload nginx- π Product Specification - Complete architecture and design
- β Implementation Status - Development progress (188 checkpoints)
- π Quick Start Guide - Fast-track setup
- π¦ Installation Guide - Detailed setup steps
- ποΈ Smart Contracts - Move contracts documentation
- π³ Docker Setup - Container orchestration
- π VPS Deployment - Production deployment guide
See IMPLEMENTATION_STATUS.md for detailed checkpoints.
Phase 1: Foundation (π§ In Progress - ~60% complete)
- β Python bot with aiogram
- β Gemini AI integration
- β Sui RPC client
- β PostgreSQL database
- π§ Transaction builder
- π§ NFT service
Phase 2: Smart Contracts (β Complete)
- β BatchTransfer contract
- β ContactRegistry contract
- β SpendingGuardian contract
- βΈοΈ Deployment to testnet
- βΈοΈ Bot integration
Phase 3: Web dApp (π§ In Progress - ~70% complete)
- β React + Vite setup
- β zkLogin flow
- β Wallet Standard connection
- β Telegram verification
- π§ Transaction signing UI
- π Transaction history view
Phase 4: Production (π Planned)
- π Rate limiting
- π Error monitoring (Sentry)
- π Analytics
- π Backup/restore
- π Multi-language support
This is an active development project. Contributions welcome!
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
MIT License - see LICENSE file
- Sui Documentation: https://docs.sui.io/
- Telegram Bot API: https://core.telegram.org/bots/api
- Google Gemini: https://ai.google.dev/gemini-api/docs
- Mysten zkLogin: https://docs.sui.io/concepts/cryptography/zklogin
- Project Issues: https://github.com/Sui-Romanian-Hackathon/Caishen/issues
Built with β€οΈ for the Sui ecosystem
src/services/llm/toolHandlers.tsβ tool execution stubs hooking Sui/contact services.src/services/sui/client.tsβ SuiClient factory pinned toSUI_RPC_URL.src/services/sui/suiService.tsβ balance lookups via Sui JSON-RPC.src/services/sui/txBuilder.tsβ unsigned transaction building for SUI, tokens, NFTs (SDK-based).src/services/sui/utils.tsβ metadata cache + amount conversions.src/services/sui/nftService.tsβ NFT listing (ownership view + display metadata).src/services/sui/historyService.tsβ transaction history fetcher with basic sent/received classification.src/services/contacts/contactStore.tsβ in-memory contacts and resolution helper.src/utils/security.tsβ bcrypt hashing + nonce helper.src/utils/logger.tsβ pino logger config.
- Docker/Docker Compose definitions for all microservices + infra live in
docker-compose.yml(nginx front-end, api-gateway, Telegram gateway, NLP, transaction-builder, user, notification, Redis). SQLite3 is used instead of Postgres to fit the 2GB footprint. - nginx reverse proxy configs are in
nginx/nginx.conf(public) andnginx/api-gateway.conf(internal service mesh). Self-signed cert instructions are innginx/ssl/README.md. - For now, zkLogin uses external Mysten Labs services (salt + prover); no local zklogin-service container.
- See
DOCKER_SETUP.mdfor WSL-friendly commands, SSL generation steps, and the 2GB-optimized deployment notes.
- Lint:
npm run lint - Format:
npm run format - Type check:
npm run check - Build:
npm run build
- Wire
llmServiceto OpenAI/Gemini (function calling) using the schemas from the spec. - Extend Sui layer for transaction building (send SUI/tokens, NFTs) and deep-link generation to the signing dApp (bytes are already built).
- Persist sessions/contacts in SQLite/Redis (per the 2GB compose) instead of memory; reuse
tokenServicehelpers to store only hashed secrets. - Add end-to-end tests around the webhook flow and Telegram client mocking.
- Harden RPC usage (timeouts/retries), expand history/NFT queries via indexer, and add rate limiting.