Configuration
This guide covers all configuration options for the Somnia Validator Monitor Bot.
Environment Variables
Required Variables
These variables MUST be set for the bot to function:
BOT_TOKEN
- Description: Telegram bot token from BotFather
- Format:
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 - Example:
BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TELEGRAM_ADMIN_IDS
- Description: Comma-separated list of Telegram user IDs with admin access
- Format: Numeric IDs separated by commas
- Example:
TELEGRAM_ADMIN_IDS=123456789,987654321
SOMNIA_RPC_URL
- Description: Somnia Network RPC endpoint URL
- Format: Full HTTPS URL
- Example:
SOMNIA_RPC_URL=https://dream.somnia.network
NODE_COMMITTEE_CONTRACT_ADDRESS
- Description: Address of the Node Committee smart contract
- Format: Ethereum address (0x...)
- Example:
NODE_COMMITTEE_CONTRACT_ADDRESS=0x7b8b1bb68c6f0e29f3addcb45a6c0bb8e8e331c7
SOMNIA_STAKING_CONTRACT_ADDRESS
- Description: Address of the Staking smart contract
- Format: Ethereum address (0x...)
- Example:
SOMNIA_STAKING_CONTRACT_ADDRESS=0x44c185a0604b1227092305542a176840742f5342
Optional Variables
These variables have defaults but can be customized:
Monitoring Settings
Database Settings
Redis Settings (Optional Queue System)
Display Settings
Performance Settings
Logging Settings
Network Settings
Bot Settings
Configuration File (.env)
Create a .env file in the project root:
Allowed Users Configuration
If you want to restrict bot access, create allowed_users.json:
Configuration Validation
The bot validates configuration on startup:
- Required variables: Bot won't start without them
- Type validation: Numbers are parsed correctly
- Format validation: Addresses are checked for validity
- Range validation: Intervals must be positive
Common Validation Errors
Configuration Best Practices
Security
- Never commit
.envfiles to version control - Use strong, unique bot tokens
- Limit admin IDs to trusted users only
- Use environment-specific configurations
Performance
- Monitoring intervals: Balance between real-time updates and resource usage
- Batch sizes: Larger batches are more efficient but use more memory
- Cache TTL: Longer cache reduces RPC calls but may show stale data
Maintenance
- Backup configuration before changes
- Test changes in development first
- Document any non-standard settings
- Monitor after configuration changes
Environment-Specific Configurations
Development
Production
Testing
Updating Configuration
Runtime Updates
Some configurations can be updated without restart:
- Log level (via admin panel)
- Monitoring intervals (via admin commands)
- Cache settings
Restart Required
These changes require bot restart:
- Bot token
- Admin IDs
- RPC URL
- Contract addresses
- Database path
Update Process
- Update
.envfile - Stop bot gracefully
- Verify configuration
- Start bot
- Check logs for errors
- Verify functionality