A JavaScript project for real-time event listening using Ethers.js and Node.js runtime. This project provides high-performance event listening capabilities for ERC20 tokens and Uniswap V2/V3 pools.
- Real-time event monitoring using WebSocket connections
- Support for multiple contract types:
- ERC20 Tokens (Transfer, Approval events)
- Uniswap V2 Pools (Swap, Sync, Mint, Burn events)
- Uniswap V3 Pools (Swap, Flash, Mint, Burn, Collect events)
- Contract interactions using Ethers.js
- High-performance execution with Node.js runtime
- Configurable through environment variables
- Node.js 21.x or higher
- An Ethereum WebSocket provider URL
- Runtime: Node.js - v21.x or higher - JavaScript runtime
- Ethereum Client: Ethers.js v6.13.5 - Ethereum Client interactions
- Smart Contract Standards:
- @openzeppelin/contracts v5.2.0
- @uniswap/v2-core v1.0.1
- @uniswap/v3-core v1.0.1
- dotenv v16.4.7
- Clone the repository:
git clone https://github.com/horizon-eth/continuous-event-listener-nodejs-ethersjs.git
cd continuous-event-listener-nodejs-ethersjs
- Install dependencies:
npm install
- Create a
.env
file based onexample.env
:
cp example.env .env
- Configure your environment variables in
.env
:
PROVIDER_WSS_URL="your_websocket_provider_url"
TYPE="TOKEN" # or "UNISWAPV2" or "UNISWAPV3"
ADDRESS="your_contract_address"
EVENT_NAME="Transfer" # or other supported events
Start the event listener:
npm start
- Transfer
- Approval
- Swap
- Sync
- Mint
- Burn
- Swap
- Flash
- Mint
- Burn
- Collect
- IncreaseObservationCardinalityNext
- SetFeeProtocol
- CollectProtocol
The project uses environment variables for configuration. See example.env
for all available options:
PROVIDER_WSS_URL
: WebSocket provider URL for Ethereum networkTYPE
: Contract type ("TOKEN", "UNISWAPV2", or "UNISWAPV3")ADDRESS
: Contract address to monitorEVENT_NAME
: Event name to listen for
For optimal event listening performance:
- Use a reliable WebSocket provider
- Adjust polling intervals and other settings based on your needs:
export const provider_wss_config = { staticNetwork: ethers.Network.from(CHAIN_ID), // polling: true, // pollingInterval: 1000, };
The project uses JavaScript in the codebase. Key files:
index.js
: Application entrypointsrc/callback/callback.js
: Event processing logicsrc/config/config.js
: Application Configssrc/listener/listener.js
: Event listening & reconnection logicsrc/utils/utils.js
: Utility functions
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.