Video thumbnail

TonEthBot

Bridging Ukraine & Russia through crypto transfers, wallet connections, and cross-border swaps.

TonEthBot

Created At

Unite Defi

Project Description

TonEthBot - Uniting Hearts Through Crypto

Our Telegram chatbot bridges divides between people in conflict zones like Russia and Ukraine through the universal language of cryptocurrency. Using both TON and Ethereum blockchains, users can connect their wallets, check balances, and exchange digital assets seamlessly across borders.

Built with 1inch API integration for optimal swap rates, TonEthBot facilitates financial interactions when traditional banking systems fail. Beyond transactions, it creates a neutral space where individuals can engage in direct peer-to-peer value exchange regardless of geopolitical barriers.

Available in English, Ukrainian, and Russian, this multi-language bot empowers users to maintain financial connections when other communication channels break down, proving that blockchain technology can be a powerful tool for peace.

How it's Made

Building the TonEthBot: Bridging Conflict Zones Through Cryptocurrency

Project Overview

We built TonEthBot, a Telegram bot designed to facilitate cryptocurrency exchanges between people in conflict zones like Russia and Ukraine. Our core mission was to create a neutral financial bridge when traditional systems fail.

Technology Stack

  • Python: The entire bot is written in Python, chosen for its robust libraries and ease of development.
  • aiogram: We used this asynchronous framework for Telegram Bot API to handle user interactions efficiently.
  • dotenv: For secure environment variable management, keeping sensitive API keys protected.
  • UUID: Generated unique IDs for each wallet connection request to maintain session integrity.

Core Functionality

  1. Multi-language Support: The bot operates in English, Ukrainian, and Russian, using a custom text management system with language-specific dictionaries.

  2. Wallet Integration:

    • Implemented direct connections to both Ethereum (via MetaMask) and TON wallets
    • Used deep links to navigate users to their respective wallet apps (Tonkeeper for TON and MetaMask for ETH)
    • Created a simple but effective validation system for wallet addresses
    • Added dedicated /connect_metamask and /connect_ton commands for direct wallet connections
  3. 1inch API Integration:

    • Leveraged the 1inch API to provide users with real-time swap rates between different tokens
    • This allows users to make informed decisions before executing exchanges
  4. Command Structure:

    • /start - Entry point with language selection
    • /connect - Multi-wallet connection system
    • /connect_metamask - Direct connection to MetaMask wallet
    • /connect_ton - Direct connection to TON wallet
    • /wallet - View wallet addresses and balances
    • /receive - Generate address details for receiving funds
    • /send - Sending functionality (in development)
    • /swap - Crypto exchange functionality using 1inch rates
    • /language - Language preferences

Technical Challenges & Solutions

One of our hacky but effective solutions was implementing a "pending connections" system using UUID. Rather than maintaining complex state machines, we generate a unique ID for each wallet connection request and store it in a dictionary. This allows multiple users to connect wallets simultaneously without conflicts.

For wallet validation, we implemented basic pattern matching that checks address formats (0x... for ETH and EQ/UQ... for TON) without requiring full blockchain validation, making the bot responsive even in areas with poor internet connectivity.

Partner Technologies Integration

  1. 1inch API: Instead of building our own DEX aggregator, we tapped into 1inch's robust API for optimal swap rates. This saved significant development time while providing users with the best possible exchange rates.

  2. TON Connect: For TON wallet integration, we implemented a simplified version of the TON Connect protocol with direct links to Tonkeeper through our /connect_ton command.

  3. MetaMask Deep Links: We used MetaMask deep links via our /connect_metamask command to facilitate smooth wallet connections without requiring users to navigate through multiple menus.

Our approach prioritized accessibility and simplicity, ensuring that users in conflict zones with potentially limited technical knowledge could easily connect wallets and exchange assets across borders, regardless of geopolitical tensions.

background image mobile

Join the mailing list

Get the latest news and updates