A standalone, modular Python application for monitoring Relay transactions and tracking ShapeShift affiliate fees across multiple blockchain networks.
- Multi-chain Support: Monitors Ethereum, Polygon, Arbitrum, Optimism, Base, and Avalanche
- CSV Output: Stores all transaction data in organized CSV files
- Affiliate Tracking: Automatically detects and tracks ShapeShift affiliate fee transactions
- Block Tracking: Maintains progress across restarts with persistent block tracking
- Rate Limiting: Built-in rate limiting to respect RPC provider limits
- Configurable: Easy configuration via YAML and environment variables
- Python 3.8+
- Web3.py
- PyYAML
- python-dotenv
- Alchemy API key (or other RPC provider)
-
Clone the repository
git clone <your-repo-url> cd relay
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp env.example .env # Edit .env with your API keys -
Configure the application
cp config/config.example.yaml config/config.yaml # Edit config.yaml with your settings
ALCHEMY_API_KEY=your_alchemy_api_key_here
INFURA_API_KEY=your_infura_api_key_here # Optional fallbackapi:
alchemy_api_key: "${ALCHEMY_API_KEY}"
infura_api_key: "${INFURA_API_KEY}"
shapeshift_affiliates:
mainnet: "0x90A48D5CF7343B08dA12E067680B4C6dbfE551Be"
base: "0x9c9aA90363630d4ab1D9dbF416cc3BBC8d3Ed502"
# ... more addresses
chains:
ethereum:
name: "Ethereum Mainnet"
rpc_url: "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
start_block: 19000000
chunk_size: 100
delay: 0.5python relay_listener.pypython relay_listener.py --config custom_config.yamlpython relay_listener.py --chains ethereum,baseThe listener creates two main CSV files:
data/relay_transactions.csv- All detected affiliate transactionsdata/relay_block_tracker.csv- Processing progress tracking
tx_hash- Transaction hashchain- Blockchain networkblock_number- Block numbertimestamp- Block timestampfrom_address- Sender addressto_address- Recipient addressaffiliate_address- ShapeShift affiliate addressaffiliate_fee_amount- Affiliate fee amountaffiliate_fee_token- Token used for feeaffiliate_fee_usd- Fee value in USDvolume_amount- Transaction volumevolume_token- Volume tokenvolume_usd- Volume in USDgas_used- Gas consumedgas_price- Gas pricecreated_at- Record creation timestamp
relay/
├── relay_listener.py # Main listener application
├── config/
│ ├── config.yaml # Configuration file
│ └── config_loader.py # Configuration management
├── data/ # Output CSV files
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
└── README.md # This file
- Processing Speed: ~100 blocks per batch (configurable)
- Rate Limiting: 0.5 second delay between batches
- Memory Usage: Minimal, processes data in chunks
- Storage: CSV-based for easy analysis and portability
The listener provides real-time logging and statistics:
INFO:relay_listener:Connected to ethereum: Ethereum Mainnet
INFO:relay_listener:Connected to base: Base
INFO:relay_listener:Found 1642 logs on base
INFO:relay_listener:Saved 1123 Relay affiliate events to CSV-
RPC Connection Failed
- Check your API key in
.env - Verify RPC endpoint URLs
- Check network connectivity
- Check your API key in
-
No Transactions Found
- Verify affiliate addresses in config
- Check start block numbers
- Ensure contracts are deployed on specified blocks
-
Rate Limiting Errors
- Increase
delayin config - Reduce
chunk_size - Use premium RPC provider
- Increase
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for ShapeShift affiliate fee tracking
- Uses Web3.py for blockchain interaction
- CSV output for easy data analysis