A feature-rich Telegram bot that monitors real-time gas fees across multiple blockchains (Ethereum, BSC, Polygon) and sends smart alerts when fees drop below user-defined thresholds. Now with enhanced UI, decimal support, and comprehensive alert management!
- Multi-Chain Support: Track gas fees on Ethereum, BSC, Polygon, and more
- Smart Alerts: Get notified when fees drop below your custom threshold (supports decimals like 0.8 Gwei!)
- Real-Time Data: Fetches live gas prices from blockchain explorers every 2 minutes
- User-Friendly: Rich interface with emojis, inline keyboards, and intuitive commands
- Alert Management: View, set, and delete your gas price alerts
- Visual Indicators: Color-coded gas prices (π’ Low, π‘ Medium, π΄ High)
- Decimal Support: Set precise thresholds like 0.8, 1.5, or 2.3 Gwei
- Core: Python 3.10+
- Telegram Bot:
python-telegram-botlibrary - APIs: Etherscan, BscScan, PolygonScan
- Scheduler: APScheduler with background monitoring
- Database: SQLite with decimal support
- Deployment: Docker + AWS EC2/VPS ready
- Python 3.10+
- Telegram Bot Token (Get from @BotFather)
- Free API keys from:
-
Clone the repository
git clone <your-repo-url> cd cross-chain-gasfee-tracker
-
Create virtual environment
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
cp .env.example .env # Edit .env with your API keys and bot token -
Run the bot
./start.sh # Or manually: python main.py
| Command | Description | Example |
|---|---|---|
/start |
Show main menu | /start |
/help |
Show help and tips | /help |
/status |
Show all chain prices | /status |
/myalerts |
View your active alerts | /myalerts |
- Main Menu: Navigate with inline buttons
- Gas Tracking: Select specific chains to monitor
- Alert Setup: Interactive chain selection and threshold input
- Alert Management: Delete alerts with one click
- Real-time Updates: Refresh gas prices instantly
TELEGRAM_BOT_TOKEN=your_bot_token_here
ETHERSCAN_API_KEY=your_etherscan_api_key
BSCSCAN_API_KEY=your_bscscan_api_key
POLYGONSCAN_API_KEY=your_polygonscan_api_keyThe bot is optimized to respect API rate limits while maintaining responsiveness:
- Check Interval: 2 minutes (30 times/hour instead of 360 times/hour)
- Smart Scheduling: Only checks chains where users have active alerts
- API Efficiency: Reduces unnecessary calls when no alerts exist
- Free Tier Compatible: Stays within Etherscan, BscScan, and PolygonScan free limits
API Usage: ~30 requests/hour vs previous 360 requests/hour (90% reduction!)
- β‘ Ethereum (ETH): Chain ID 1
- π‘ BSC: Chain ID 56
- π£ Polygon: Chain ID 137
- π’ Low: < 10 Gwei (Great for transactions)
- π‘ Medium: 10-50 Gwei (Normal usage)
- π΄ High: > 50 Gwei (Peak times)
- Chain Emojis: β‘ ETH, π‘ BSC, π£ Polygon
- Gas Price Emojis: π’ Low, π‘ Medium, π΄ High
- Rich Formatting: Markdown support with bold text
- Inline Keyboards: Easy navigation without typing
- Decimal Support: Set thresholds like 0.8, 1.5, 2.3 Gwei
- Instant Notifications: Get alerted when gas drops below your threshold
- Alert Management: View and delete alerts easily
- Confirmation Messages: Clear feedback when alerts are set
- 2-Minute Updates: Continuous background monitoring (respects API rate limits)
- Multi-Chain: Monitor all chains simultaneously
- Status Overview: See all chain prices at once
- Refresh Function: Get latest prices on demand
- Smart Scheduling: Only checks chains with active alerts to save API calls
cross-chain-gasfee-tracker/
βββ core/ # Main logic
β βββ gas_tracker.py # Multi-chain API interactions
β βββ alert_manager.py # Smart alert processing
β βββ scheduler.py # Background monitoring
βββ bot/ # Telegram handlers
β βββ command.py # Rich command interface
β βββ bot_init.py # Bot setup
βββ data/ # Database files
βββ config/ # API keys and constants
βββ .env # Environment variables
βββ start.sh # Easy startup script
βββ main.py # Entry point
./start.sh# Run in terminal
source .venv/bin/activate
python main.py# Run persistently using tmux
tmux new -s gasbot
source .venv/bin/activate
python main.py
# Ctrl+B then D to detachFROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]-
Import Error: No module named 'telegram'
- Ensure virtual environment is activated
- Reinstall dependencies:
pip install -r requirements.txt
-
Event Loop Error
- The bot automatically handles this - no action needed
-
API Timeout Errors
- Normal for free API tiers - bot will retry automatically
- Check your API key quotas
-
Bot Not Responding
- Check if bot token is correct in .env
- Verify bot is running:
ps aux | grep python
-
Decimal Thresholds Not Working
- Database supports decimals (REAL type)
- Use values like 0.8, 1.5, 2.3 Gwei
The bot provides real-time feedback:
- β Database initialized
- β Scheduler started
- β Bot is running
- π¨ Gas alerts sent
β οΈ API errors (handled automatically)
- Ethereum: Set threshold to 0.8 Gwei (current: ~0.7 Gwei)
- BSC: Set threshold to 3.5 Gwei (current: ~3.2 Gwei)
- Polygon: Set threshold to 30 Gwei (current: ~25 Gwei)
- When ETH gas drops from 0.8 to 0.7 Gwei β Alert! π¨
- When BSC gas drops from 3.5 to 3.2 Gwei β Alert! π¨
- When Polygon gas drops from 30 to 25 Gwei β Alert! π¨
- Add Solana and Avalanche support
- Implement gas fee predictions (AI)
- Create web dashboard for analytics
- Multi-language support
- Advanced alert types (time-based, trend-based)
- Push notifications to Discord/Slack
- Gas price forecasting
- MEV protection alerts
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
If you encounter any issues:
- Check the troubleshooting section above
- Review the logs for error messages
- Ensure all dependencies are installed correctly
- Verify your API keys are valid and have sufficient quota
- Check that your bot token is correct
- β Decimal Threshold Support: Now supports 0.8, 1.5, 2.3 Gwei
- β Enhanced UI: Rich emojis and visual indicators
- β Alert Management: View and delete alerts easily
- β Multi-Chain Status: See all chain prices at once
- β Better Error Handling: Graceful API failure handling
- β Startup Script: Easy one-command bot launch
- β API Optimization: 2-minute intervals with smart scheduling (90% API reduction)
- β Rate Limit Compliance: Respects free API tier limits
- π¨ Beautiful interface with chain and gas price emojis
- π± Intuitive inline keyboard navigation
- π Smart alert confirmations with current price hints
- π Real-time status overview for all chains
- ποΈ One-click alert deletion
- π‘ Helpful tips and examples throughout
The bot is now production-ready with enterprise-grade features and a delightful user experience!
