AutoZap is a sophisticated bot for the Nostr network that monitors reposts of specific notes and automatically rewards users with Lightning Network payments (zaps). Built with Python and powered by LNbits, it enables automated engagement rewards in the Nostr ecosystem.
- Automated Repost Monitoring: Track specific notes across multiple Nostr relays
- Lightning Rewards: Instant payments to users who engage with content
- Rate Limiting: Prevent abuse with configurable payment timeouts
- Payment Tracking: SQLite database for tracking all transactions
- Robust Error Handling: Comprehensive error recovery and logging
- Type Safety: Full Python type hints for code reliability
- Python 3.10+
- Nostr: For decentralized social networking
- LNbits: Lightning Network payment processing
- SQLite: Local payment tracking database
- Type Hints: Python typing for code safety
- Python Environment: Python 3.10 or higher
- LNbits Account: Access to a LNbits instance for payment processing
- Nostr Account: Access to Nostr relays
- System Requirements:
- Linux/macOS/Windows
- 512MB RAM minimum
- 1GB disk space
-
Clone the Repository:
git clone https://github.com/NOSTR-HUB/AutoZap.git cd AutoZap -
Create Virtual Environment:
python3 -m venv venv source venv/bin/activate # Linux/macOS # or .\\venv\\Scripts\\activate # Windows
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment:
cp config/.env.example .env
Edit
.envwith your settings:# LNbits Configuration LNBITS_API_KEY=your_api_key LNBITS_URL=https://your.lnbits.instance # Nostr Configuration NOSTR_RELAY_URLS=wss://relay1.com,wss://relay2.com # Payment Settings PAYMENT_AMOUNT=1000 # Amount in satoshis RATE_LIMIT_HOURS=24 # Hours between payments to same user DB_PATH=payments.db # SQLite database path
-
Start the Bot:
# Ensure virtual environment is active source venv/bin/activate # Run the bot PYTHONPATH=$(pwd)/src python3 -m backend.nostr_bot.bot
-
Monitor Operation:
- Check logs for operation status
- View payment history in SQLite database
- Monitor LNbits wallet balance
-
Configuration Options:
Setting Description Default PAYMENT_AMOUNTSatoshis per payment 1000 RATE_LIMIT_HOURSHours between payments 24 DB_PATHDatabase location payments.db
The SQLite database (payments.db) tracks all payments:
CREATE TABLE payments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
npub TEXT NOT NULL,
amount INTEGER NOT NULL,
bolt11 TEXT NOT NULL,
status TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
note_id TEXT NOT NULL
);-
Type Checking:
mypy src/
-
Run Tests:
pytest tests/
-
Code Style:
black src/ flake8 src/
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Please ensure your PR:
- Includes type hints
- Adds tests for new features
- Updates documentation
- Follows code style guidelines
This project is licensed under the MIT License - see LICENSE for details.
-
Connection Errors:
- Check relay URLs are valid and accessible
- Verify internet connection
- Ensure websocket support
-
Payment Failures:
- Verify LNbits API key and URL
- Check wallet balance
- Confirm rate limits
-
Database Issues:
- Check write permissions
- Verify SQLite installation
- Check disk space
Enable debug logging:
export LOG_LEVEL=DEBUGSee API.md for detailed API documentation.
- All payments are rate-limited by user and note
- API keys are loaded from environment only
- SQLite database prevents SQL injection
- Input validation on all external data
AutoZap/
├── src/
│ └── backend/
│ ├── config.py # Configuration management
│ ├── db/
│ │ └── models.py # Database models
│ ├── ln_wallet/
│ │ └── wallet.py # Lightning payment handling
│ └── nostr_bot/
│ ├── bot.py # Main bot logic
│ ├── events.py # Event processing
│ └── transactions.py # Payment processing
├── tests/ # Test suite
├── docs/ # Documentation
└── config/
└── settings.py # Default settings