This project is a full-featured Telegram bot for interacting with Solana wallets. The main goal is to provide a convenient and secure interface for creating, managing, and performing operations with Solana wallets directly from Telegram.
# clone the repository
git clone https://github.com/Shrekulka/solana-webwallet.git
cd solana-webwallet/
# install and activate the virtual environment
python3.12 -m venv env
source env/bin/activate
# insatll requirements
pip install -r requirements.txt
Before running, you need to create and populate the .env settings file.
You need to specify your token for accessing the Telegram API and the database engine in it.
Example .env
:
# Settings for the token and list of administrators for the bot.
# BOT_TOKEN - token for accessing the Telegram API.
BOT_TOKEN=5424991242:AAGwomxQz1p46bRi_2m3V7kvJlt5RjK9yr0
# ADMIN_IDS - list of bot administrator IDs, separated by comma.
ADMIN_IDS=[173901673,124543434,143343455]
# Settings for connecting to the database.
# DB_NAME - database name
DB_NAME=my_database
# DB_HOST - database host
DB_HOST=localhost
# DB_USER - database user
DB_USER=dbUser
# DB_PASSWORD - password
DB_PASSWORD=dbPassword
# DB_ENGINE - engine
DB_ENGINE=sqlite
# DB_ENGINE=postgresql
If postgresql
is selected as the database, then you can run it in Docker.
postgresql
cd solana-webwallet/compose/
# start postgresql container:
docker-compose -f docker-compose.yml up -d
# stop:
docker-compose -f docker-compose.yml down -v
cd solana-webwallet/
# if not activated yet, then activate the virtual environment
source env/bin/activate
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
cd solana-webwallet/
# if not activated yet, then activate the virtual environment
source env/bin/activate
python manage.py runserver
cd solana-webwallet/
# if not activated yet, then activate the virtual environment
source env/bin/activate
# run the bot
python bot.py
The presented Telegram bot project for managing Solana wallets is a fully functional and well-designed application. It
provides users with the ability to create new Solana wallets, connect existing ones, track balances, transfer tokens
between wallets, and view transaction history.
The project follows modern software development practices, with clear division into modules and components, ensuring
good maintainability and extensibility of the code. The use of the aiogram
framework and solana-py library facilitates
interaction with the Telegram and Solana APIs respectively.
Thanks to the use of finite state machines (FSMs), the bot is able to track the current interaction state with the user
and respond accordingly to their input. This provides a smooth and intuitive user experience.
Error handling and exception handling are implemented at a high level, with detailed error logging to facilitate
debugging. Caching of data such as wallet balances and transaction history improves performance and reduces load on
Solana network nodes.
Overall, this project demonstrates a deep understanding of software design principles by the developers, interaction
with external APIs, and ensuring a quality user experience. The bot is ready for deployment and use by the Solana
community for secure and convenient management of cryptocurrency wallets.
π solana_wallet_telegram_bot/ # Project directory containing the main bot files
β
βββ .env # File with environment variables such as bot token and secrets
β
βββ .env.example # Example .env file for other developers
β
βββ .gitignore # File indicating to Git which files and directories to ignore
β
βββ bot.py # Main project file, entry point for running the bot
β
βββ requirements.txt # File listing project dependencies for installation via pip
β
βββ requirements.in # Dependency file for the project in ini format
β
βββ logger_config.py # Logger configuration file for logging
β
βββ README.md # File with project description and instructions
β
βββ *.db # SQLite database file used in the project
β
βββ π compose/ # Directory for Docker Compose files
β βββ docker-compose.yml # Docker Compose file for running containers
β
βββ π config_data/ # Package with configuration data
β βββ __init__.py # File indicating that the directory is a Python package
β βββ config.py # Module with configuration data
β
βββ π database/ # Package for working with the database
β βββ __init__.py # Package initializer file
β βββ database.py # Module with the database template
β
βββ π doc_media/ # Directory for documentation media files
β βββ πdemo/ # Directory for demonstration files with videos
β βββ πimg/ # Directory for demonstration files with images
β
βββ π external_services/ # Package for interacting with external services and APIs
β βββ π solana/ # Subpackage related to integration with Solana
β β βββ __init__.py # Subpackage initializer file
β β βββ solana.py # Module with functions for working with Solana wallets and transactions
β βββ __init__.py # Package initializer file for external_services
β
βββ π handlers/ # Package with command and request handlers for the bot
β βββ __init__.py # Package initializer file
β βββ back_button_handler.py # Handler for pressing the "Back" button
β βββ connect_wallet_handlers.py # Handlers for connecting an existing wallet
β βββ create_wallet_handlers.py # Handlers for creating a new wallet
β βββ other_handlers.py # Handlers for unexpected commands and messages
β βββ transaction_handlers.py # Handlers for viewing transaction history
β βββ transfer_handlers.py # Handlers for transferring tokens
β βββ user_handlers.py # Handlers for user-related commands
β
βββ π keyboards/ # Package with modules for working with bot keyboards
β βββ __init__.py # Package initializer file
β βββ back_keyboard.py # Module for creating a keyboard with a "Back" button
β βββ main_keyboard.py # Module for creating the main bot keyboard
β βββ transfer_transaction_keyboards.py # Module for creating keyboards for token transfer and history view
β
βββ π lexicon/ # Package for storing bot response texts
β βββ __init__.py # Package initializer file
β βββ lexicon_en.py # Module with texts in English
β
βββ π models/ # Package with data models for the database
β βββ __init__.py # Package initializer file
β βββ models.py # Contains data model definitions for SQLAlchemy ORM
β
βββ π services/ # Package with services for working with data
β βββ __init__.py # Package initializer file
β βββ wallet_service.py # Module with services for working with wallets
β
βββ π states/ # Package with user state classes
β βββ __init__.py # Package initializer file
β βββ states.py # Module with user state classes
β
βββ π utils/ # Package with auxiliary modules
βββ __init__.py # Package initializer file
βββ validators.py # Module with functions for data validation