Skip to content

lbbcym/robin-eth-contract-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eth-contract-watcher

A robust utility library for monitoring Ethereum/Base smart contract events and state changes with automatic retry, error handling, and rate limiting.

Features

  • 🔄 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

Installation

npm install eth-contract-watcher

Quick Start

import { 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
    });
  }
});

Documentation

Installation

First, install the package using npm:

```bash npm install eth-contract-watcher ```

Basic Usage

The library provides two main functionalities:

  1. Event watching with automatic retry
  2. State monitoring with customizable polling

Check the API Reference for detailed documentation.

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

MIT License - see the LICENSE file for details.

Support

  • Create an issue for bug reports or feature requests
  • Join our Discord community for discussions
  • Follow us on Twitter for updates

Security

For security concerns, please email security@example.com or create a security advisory on GitHub.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors