A robust utility library for monitoring Ethereum/Base smart contract events and state changes with automatic retry, error handling, and rate limiting.
- 🔄 Automatic retry with exponential backoff for failed requests
- 🚦 Rate limiting to prevent API throttling
- 📊 Event filtering and transformation
- 🔌 Support for multiple providers (Infura, Alchemy, custom RPC)
- 🎯 TypeScript support
- ⚡ Optimized for Base and other L2 solutions
npm install eth-contract-watcherimport { ContractWatcher } from 'eth-contract-watcher';
// Initialize watcher
const watcher = new ContractWatcher({
address: '0x...', // Contract address
abi: [...], // Contract ABI
provider: 'https://...' // RPC URL
});
// Watch for events
watcher.watchEvent('Transfer', {
fromBlock: 'latest',
handler: async (event) => {
console.log('Transfer detected:', {
from: event.args.from,
to: event.args.to,
value: event.args.value.toString()
});
}
});
// Watch state changes
watcher.watchState({
method: 'totalSupply',
pollInterval: 5000, // 5 seconds
handler: async (newValue, oldValue) => {
console.log('Total supply changed:', {
old: oldValue,
new: newValue
});
}
});First, install the package using npm:
```bash npm install eth-contract-watcher ```
The library provides two main functionalities:
- Event watching with automatic retry
- State monitoring with customizable polling
Check the API Reference for detailed documentation.
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
MIT License - see the LICENSE file for details.
- Create an issue for bug reports or feature requests
- Join our Discord community for discussions
- Follow us on Twitter for updates
For security concerns, please email security@example.com or create a security advisory on GitHub.