Skip to content

Event processor library useful for processing MultiversX logs&events

Notifications You must be signed in to change notification settings

multiversx/mx-sdk-event-processor

Repository files navigation

Event Processor for JavaScript

Event processor for JavaScript and TypeScript (written in TypeScript).

Distribution

npm

Usage

let lastProcessedTimestamp = 1727858320;
const eventProcessor = new EventProcessor();
await eventProcessor.start({
    elasticUrl: 'https://index.multiversx.com',
    eventIdentifiers: ['swapTokensFixedInput'],
    emitterAddresses: ['erd1qqqqqqqqqqqqqpgqt0uek344kaerr4gf9g2r8l0f4l8ygyha2jps82u9r6'],
    pageSize: 1000,
    scrollTimeout: "1m",
    delayBetweenRequestsInMilliseconds: 100,
    getLastProcessedTimestamp: async () => {
        return lastProcessedTimestamp;
    },
    setLastProcessedTimestamp: async (timestamp: number) => {
        lastProcessedTimestamp = timestamp;
    },
    onEventsReceived: async (highestTimestamp, events) => {
        console.log(`Received ${events.length} events with the highest timestamp ${highestTimestamp}`);
    },
});

Example

The example directory contains an example script that illustrates how to use the event processor.

ts-node example/example.ts

About

Event processor library useful for processing MultiversX logs&events

Resources

Stars

Watchers

Forks

Packages

No packages published