Skip to content
sagaratalattiPublic

About

A basic telegram DAO bot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Telegram DAO Platform - Phase 2: Smart Contracts ✅

🎯 Current Status: Phase 2 Complete

Phase 1 (Wallet System) ✅ and Phase 2 (Smart Contracts) ✅ have been successfully implemented. The platform now provides a complete blockchain infrastructure for DAO creation, management, and treasury operations.

✅ Phase 1: Wallet System (Complete)

  • Automatic Wallet Generation: Each Telegram user gets a unique Web3 wallet
  • Secure Storage: Private keys encrypted with AES-256 and stored in Firebase Firestore
  • Transaction Signing: Ready for on-chain interactions
  • Telegram Integration: Seamless bot commands for wallet management

✅ Phase 2: Smart Contracts (Complete)

  • DAOFactory Contract: Create and manage DAO instances with vault registry
  • DAO Contract: Full proposal and voting system with member management
  • Vault System: Modular treasury management with multi-signature support
  • VaultFactory Contract: Automated vault creation with configurable parameters
  • Deployment Infrastructure: Complete deployment and verification system
  • Security Framework: OpenZeppelin integration with comprehensive protections

Bot Commands Available

  • /start - Create your Web3 wallet (< 2s creation time)
  • /wallet - View your wallet information
  • /help - Show available commands

🏗️ Architecture

Current Implementation (Phase 1 + 2)

Telegram Bot (Telegraf.js)
    ↓
Wallet Service (ethers.js) ←→ Smart Contracts (Arbitrum)
    ↓                              ↓
Firebase Firestore          DAOFactory & VaultFactory
(Encrypted Storage)              ↓
                            DAO & Vault Instances

Key Components

Phase 1: Wallet System

  1. TelegramBotService (src/services/TelegramBotService.ts)

    • Handles all Telegram interactions
    • Command processing and user management
    • Integration with wallet and Firebase services
  2. WalletService (src/services/WalletService.ts)

    • Web3 wallet creation and management
    • Secure transaction signing
    • Integration with ethers.js
  3. FirebaseService (src/services/FirebaseService.ts)

    • Encrypted data storage and retrieval
    • User wallet mapping
    • Secure key management

Phase 2: Smart Contracts

  1. DAOFactory Contract (contracts/DAOFactory.sol)

    • DAO creation and management
    • Vault registry system
    • User DAO tracking
  2. DAO Contract (contracts/DAO.sol)

    • Proposal and voting system
    • Member management
    • Vault attachment capabilities
  3. Vault System (contracts/Vault.sol + VaultFactory.sol)

    • Treasury management
    • Multi-signature operations
    • Spending proposals
  4. Contract Configuration (src/config/contracts.ts)

    • Contract addresses and ABIs
    • Network configurations
    • Integration constants

Project Structure

src/
├── services/
│   ├── WalletService.ts      # Web3 wallet creation & management
│   ├── FirebaseService.ts    # Firestore database operations
│   └── TelegramBotService.ts # Telegram bot interactions
├── config/
│   └── contracts.ts          # Smart contract configurations
└── index.ts                  # Main application entry point

contracts/
├── DAOFactory.sol            # DAO creation and management
├── DAO.sol                   # Proposal and voting system
├── Vault.sol                 # Treasury management
└── VaultFactory.sol          # Vault creation system

🔧 Setup Instructions

Prerequisites

  • Node.js 18+ and npm
  • Firebase project with Firestore enabled
  • Telegram Bot Token from @BotFather

Installation

  1. Clone and install dependencies:

    cd /Users/ibitcoinist/Documents/Blockchain/deffy
    npm install
  2. Configure environment variables:

    cp .env.example .env

    Edit .env with your configuration:

    # Telegram Bot Configuration
    TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
    
    # Firebase Configuration
    FIREBASE_PROJECT_ID=your_firebase_project_id
    FIREBASE_PRIVATE_KEY=your_firebase_private_key
    FIREBASE_CLIENT_EMAIL=your_firebase_client_email
    
    # Security
    ENCRYPTION_SALT=your_encryption_salt_here
  3. Build and run:

    npm run build
    npm start

    Or for development:

    npm run dev

🔐 Security Features

Wallet Security

  • AES-256 Encryption: Private keys encrypted using industry-standard encryption
  • Key Derivation: Encryption key derived from Telegram ID + application salt
  • No Plaintext Storage: Private keys never stored in plaintext
  • One-time Backup: Private key shown only once during wallet creation

Data Protection

  • Firebase Security Rules: Firestore configured with proper access controls
  • Environment Variables: Sensitive data stored in environment variables
  • Error Handling: Comprehensive error handling without exposing sensitive data

📊 Performance Targets

  • ✅ Wallet Creation: < 2 seconds
  • ✅ Bot Response Time: < 1 second for most commands
  • ✅ Secure Storage: Encrypted data storage in Firestore
  • ✅ Error Recovery: Graceful error handling and user feedback

🚀 Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Telegram Bot Token
  • Firebase Project
  • Alchemy API Key
  • Deployer wallet with ETH for gas

Installation

  1. Clone and Install

    git clone <repository-url>
    cd telegram-dao-platform
    npm install
  2. Environment Setup

    cp .env.example .env
    # Edit .env with your configuration
  3. Compile Smart Contracts

    npm run compile
  4. Run Tests

    npm run test
  5. Deploy Contracts

    # Deploy to Arbitrum Mainnet
    npm run deploy:arbitrum
    
    # Deploy to Arbitrum Sepolia (testnet)
    npm run deploy:arbitrum-sepolia
    
    # Deploy to Ethereum Sepolia (testnet)
    npm run deploy:ethereum-sepolia
    
    # Deploy to local Hardhat network
    npm run deploy:local
  6. Build and Start Bot

    npm run build
    npm run start

🔮 Upcoming Phases

Phase 3: Bot Core

  • Advanced command routing
  • Group vs private chat handling
  • Command validation and permissions

Phase 4: DAO Logic

  • /create_dao command implementation
  • /propose command for proposal creation
  • Inline voting with callback handlers
  • Vault attachment and management

🛠️ Development

Available Scripts

npm run dev                    # Start development server with hot reload
npm run build                  # Build TypeScript to JavaScript
npm start                      # Start production server
npm run compile                # Compile smart contracts
npm run deploy:arbitrum        # Deploy contracts to Arbitrum Mainnet
npm run deploy:arbitrum-sepolia # Deploy contracts to Arbitrum Sepolia
npm run deploy:ethereum-sepolia # Deploy contracts to Ethereum Sepolia
npm run deploy:local           # Deploy contracts to local Hardhat network
npm test                       # Run tests

Project Structure

.
├── src/                    # TypeScript source code
│   ├── services/          # Core services
│   └── index.ts           # Application entry point
├── contracts/             # Solidity contracts (Phase 2)
├── scripts/               # Deployment scripts (Phase 2)
├── test/                  # Test files
├── .env.example           # Environment variables template
├── hardhat.config.ts      # Hardhat configuration
├── package.json           # Dependencies and scripts
└── tsconfig.json          # TypeScript configuration

🌐 Network Configuration

Supported Networks

  • Arbitrum Mainnet: Production deployment
  • Arbitrum Sepolia: Arbitrum testnet for testing
  • Ethereum Sepolia: Ethereum testnet for testing
  • Hardhat Local: Local development network

Infrastructure

  • RPC Provider: Alchemy
  • Database: Firebase Firestore
  • Bot Framework: Telegraf.js

📝 Phase 1 Success Criteria

  • ✅ Wallet created < 2s and securely stored
  • ✅ AES-256 encryption implementation
  • ✅ Firebase Firestore integration
  • ✅ Telegram bot fully functional
  • ✅ Transaction signing capability ready
  • ✅ Error handling and user feedback
  • ✅ Graceful application lifecycle management

🤝 Contributing

This project follows a phased development approach. Currently in Phase 1 (Wallet System). Each phase builds upon the previous one to create a comprehensive DAO platform.

📄 License

MIT License - see LICENSE file for details.


Next Phase: Smart contract development and deployment (Phase 2)

Contact: For support or questions about the Telegram DAO Platform

About

A basic telegram DAO bot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages