Event Processors
Learn about structure of a custom event processor script
As defined in manifest.yml each custom event processor has a handler.ts
and an abi.json
. When a custom processor is deployed it listens for all the "event" topics defined in the abi.json, and executes handler.js for every single event.
As mentioned in Getting Started guide, you can see the basic structure of a processor in the starter-boilerplate repo.
Example of an empty processor
handler.ts
handler.ts
handler.js must export a function named
processEvent
processEvent
function will receive 1 argument:An object that gives you
event
that gives you access to the received transaction log and parsed event.
processEvent
function must return either:true
which means event was processedfalse
which means event was skipped for any reasonundefined
which is considered a success
processEvent
has a timeout of 60 seconds (a soft-limit that can be increased if you needed).The boolean value returned by
processEvent
is only used for statistics reasons, so it won't impact your processor logic if anything (or nothing) is returned.
abi.json
abi.json
This file is used to know which event topics to listen to and parse incoming transaction logs, before they are handed over to your processor handler function above.
Example of an abi.json:
Importing others files or libraries
You can import any .ts, .js, and .json file relative your handler.ts processor as long as they are under the same src/ directory. If you need any help ping our engineers 🙂
Last updated