Event Monitor Tutorial
Monitor Structure
Description here
Event Monitor
start_monitor
stop_monitor
get_monitor_status
monitor
Event Sync
start_sync
stop_sync
watch_sync
get_sync_status
sync
Event Handler
start_event_handler
stop_event_handler
get_event_handler_status
event_handler
handle_event
Helpers
get_events_df
get_events_list
get_queue_size
get_contract_events
Setup
The event monitor requires a blockexplorer for initialization. The purpose of this blockexplorer is to get the contract source code so that contract interactions (Data & Logs) can be decoded into human readable events.
[1]:
from messari.blockexplorers import Etherscan
API_KEY = 'YOUR_API_KEY'
ES = Etherscan(api_key=API_KEY)
The event monitor also requires the endpoint for an RPC. This should belong to the same network as the blockexplorer.
[2]:
from messari.eventmonitor import EventMonitor
rpc_url = 'YOUR_RPC_URL'
Finally the event monitor must be initialized with the adress to monitor for events.
NOTE: The source code for this contract must be verified on the selected blockexplorer or else the event monitor will not be able to decode events for the given contract
[15]:
DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'
Initalize with contract(s), blockexplorer, & RPC
[29]:
dai_monitor = EventMonitor(DAI, ES, rpc_url)
Event Monitor
start_monitor
Start the event monitor in a dedicated thread. The monitor thread will continue to run until stop_monitor() is called. The monitor thread can be accessed with EventMonitor.monitor_thread.
[22]:
dai_monitor.start_monitor()
stop_monitor
Stop the event monitor thread. This function will set an internal flag in the EventMonitor which tells the monitor thread to exit its loop. The monitor thread will not stop until it finishes the current loop and reaches the top again.
[9]:
dai_monitor.stop_monitor()
get_monitor_status
Returns the operating status of the event monitor - RUNNING: event monitor is running - STOPPING: event monitor is stopping. If the monitor takes too long to stop then something is likely wrong - CRASH: event monitor thread crashed. - DEAD: event monitor is dead/stopped.
[23]:
monitor_status = dai_monitor.get_monitor_status()
monitor_status
[23]:
'RUNNING'
monitor
This function runs the main loop for live event monitoring
WARNING: It is highly recomended that you only interact with this function through the start_monitor() and stop_monitor() functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script.
[7]:
# dai_monitor.monitor()
Event Sync
start_sync
Start the event sync in a dedicated thread. The sync thread will find and submit all events in the given block range to the event handler. The sync thread will continue to run until stop_sync() is called or the sync is finished. The sync thread can be accessed with self.sync_thread.
The parameters for this function are: * start: starting block, default is 0 * end: ending block, default is ‘latest’
[30]:
dai_monitor.start_sync()
stop_sync
Stop the event sync thread. This function will set an internal flag in the EventMonitor which tells the sync thread to exit its loop. The sync thread will not stop until it finishes the current loop and reaches the top again.
[15]:
dai_monitor.stop_sync()
watch_sync
This function can be used to watch the status of any given sync. Every 10 seconds this function will print an update on the progress of a sync.
NOTE: This is a a blocking function meaning it will be run on the main thread until concluding. ie if there is 10 minutes left in a sync and you call this function, you’ll be watching this function for the next 10 minutes
[31]:
dai_monitor.watch_sync()
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (5697662 - 10144606), Goal: 13896705, Increment: 4446944
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (7921135 - 9022420), Goal: 13896705, Increment: 1101285
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (7921135 - 8471777), Goal: 13896705, Increment: 550642
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (8471778 - 8976000), Goal: 13896705, Increment: 504222
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (8976001 - 9412808), Goal: 13896705, Increment: 436807
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (9412809 - 9767845), Goal: 13896705, Increment: 355036
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (9767846 - 10029223), Goal: 13896705, Increment: 261377
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10029224 - 10210828), Goal: 13896705, Increment: 181604
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10333122 - 10409835), Goal: 13896705, Increment: 76713
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10454936 - 10480489), Goal: 13896705, Increment: 25553
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10509427 - 10543235), Goal: 13896705, Increment: 33808
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10618299 - 10657258), Goal: 13896705, Increment: 38959
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10728739 - 10757282), Goal: 13896705, Increment: 28543
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10840419 - 10853032), Goal: 13896705, Increment: 12613
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10955197 - 11011578), Goal: 13896705, Increment: 56381
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11050341 - 11078194), Goal: 13896705, Increment: 27853
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11112939 - 11123410), Goal: 13896705, Increment: 10471
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11148370 - 11161635), Goal: 13896705, Increment: 13265
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11170081 - 11181350), Goal: 13896705, Increment: 11269
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11209103 - 11221012), Goal: 13896705, Increment: 11909
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11221534 - 11227821), Goal: 13896705, Increment: 6287
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11227822 - 11234248), Goal: 13896705, Increment: 6426
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11252363 - 11258387), Goal: 13896705, Increment: 6024
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11276990 - 11284276), Goal: 13896705, Increment: 7286
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11301454 - 11306157), Goal: 13896705, Increment: 4703
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11317118 - 11323434), Goal: 13896705, Increment: 6316
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11347309 - 11356812), Goal: 13896705, Increment: 9503
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11380420 - 11396898), Goal: 13896705, Increment: 16478
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11438003 - 11443404), Goal: 13896705, Increment: 5401
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11451059 - 11461085), Goal: 13896705, Increment: 10026
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11473170 - 11487031), Goal: 13896705, Increment: 13861
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11538404 - 11559897), Goal: 13896705, Increment: 21493
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11604070 - 11623525), Goal: 13896705, Increment: 19455
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11642682 - 11662231), Goal: 13896705, Increment: 19549
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11704082 - 11725601), Goal: 13896705, Increment: 21519
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11786634 - 11806992), Goal: 13896705, Increment: 20358
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11881481 - 11915394), Goal: 13896705, Increment: 33913
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11954531 - 11999019), Goal: 13896705, Increment: 44488
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12048340 - 12101150), Goal: 13896705, Increment: 52810
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12155144 - 12206263), Goal: 13896705, Increment: 51119
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12250094 - 12283877), Goal: 13896705, Increment: 33783
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12283878 - 12308600), Goal: 13896705, Increment: 24722
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12325472 - 12337803), Goal: 13896705, Increment: 12331
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12365342 - 12374016), Goal: 13896705, Increment: 8674
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12430868 - 12460147), Goal: 13896705, Increment: 29279
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12460148 - 12499832), Goal: 13896705, Increment: 39684
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12493730 - 12513183), Goal: 13896705, Increment: 19453
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12539967 - 12575137), Goal: 13896705, Increment: 35170
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12622709 - 12652726), Goal: 13896705, Increment: 30017
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12668291 - 12685323), Goal: 13896705, Increment: 17032
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12723853 - 12742160), Goal: 13896705, Increment: 18307
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12759322 - 12776135), Goal: 13896705, Increment: 16813
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12852826 - 12877615), Goal: 13896705, Increment: 24789
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12937121 - 12972959), Goal: 13896705, Increment: 35838
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13012798 - 13055415), Goal: 13896705, Increment: 42617
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13184458 - 13224001), Goal: 13896705, Increment: 39543
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13260374 - 13295552), Goal: 13896705, Increment: 35178
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13398430 - 13436224), Goal: 13896705, Increment: 37794
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13585524 - 13651296), Goal: 13896705, Increment: 65772
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13809698 - 13896483), Goal: 13896705, Increment: 86785
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (7921135 - 10136157), Goal: 13896705, Increment: 2215022
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (7921135 - 9028646), Goal: 13896705, Increment: 1107511
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9028647 - 9527912), Goal: 13896705, Increment: 499265
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9527913 - 10381756), Goal: 13896705, Increment: 853843
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9954835 - 10291120), Goal: 13896705, Increment: 336285
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10291121 - 10545957), Goal: 13896705, Increment: 254836
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10545958 - 10722941), Goal: 13896705, Increment: 176983
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10915298 - 11009681), Goal: 13896705, Increment: 94383
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11091454 - 11103066), Goal: 13896705, Increment: 11612
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11146197 - 11163678), Goal: 13896705, Increment: 17481
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11192180 - 11203058), Goal: 13896705, Increment: 10878
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11192180 - 11203058), Goal: 13896705, Increment: 10878
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11223764 - 11234786), Goal: 13896705, Increment: 11022
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11248889 - 11256555), Goal: 13896705, Increment: 7666
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11277593 - 11289018), Goal: 13896705, Increment: 11425
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11298998 - 11307513), Goal: 13896705, Increment: 8515
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11325773 - 11328397), Goal: 13896705, Increment: 2624
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11341862 - 11351383), Goal: 13896705, Increment: 9521
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11424539 - 11469166), Goal: 13896705, Increment: 44627
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11481110 - 11505047), Goal: 13896705, Increment: 23937
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11561907 - 11591556), Goal: 13896705, Increment: 29649
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11618983 - 11643089), Goal: 13896705, Increment: 24106
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11697032 - 11708298), Goal: 13896705, Increment: 11266
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11747234 - 11759799), Goal: 13896705, Increment: 12565
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11832186 - 11879022), Goal: 13896705, Increment: 46836
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11911247 - 11957235), Goal: 13896705, Increment: 45988
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12016156 - 12084502), Goal: 13896705, Increment: 68346
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12156362 - 12221206), Goal: 13896705, Increment: 64844
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12270009 - 12300529), Goal: 13896705, Increment: 30520
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12343822 - 12347340), Goal: 13896705, Increment: 3518
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12362904 - 12373535), Goal: 13896705, Increment: 10631
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12456620 - 12470443), Goal: 13896705, Increment: 13823
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12524393 - 12566007), Goal: 13896705, Increment: 41614
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12589728 - 12617754), Goal: 13896705, Increment: 28026
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12681864 - 12699016), Goal: 13896705, Increment: 17152
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12726999 - 12738822), Goal: 13896705, Increment: 11823
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12798988 - 12822097), Goal: 13896705, Increment: 23109
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12849464 - 12883046), Goal: 13896705, Increment: 33582
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12922762 - 12967495), Goal: 13896705, Increment: 44733
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13014726 - 13060075), Goal: 13896705, Increment: 45349
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13192084 - 13216055), Goal: 13896705, Increment: 23971
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13261273 - 13287233), Goal: 13896705, Increment: 25960
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13318599 - 13359077), Goal: 13896705, Increment: 40478
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13411578 - 13480120), Goal: 13896705, Increment: 68542
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13480121 - 13563468), Goal: 13896705, Increment: 83347
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13658618 - 13759075), Goal: 13896705, Increment: 100457
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13759076 - 13854811), Goal: 13896705, Increment: 95735
Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13759076 - 13854811), Goal: 13896705, Increment: 95735
get_sync_status
Returns the operating status of the event sync - RUNNING: event sync is running - STOPPING: event sync is stopping. If the sync takes too long to stop then something is likely wrong - CRASH: event sync thread crashed. - DEAD: event sync is dead/stopped.
[22]:
sync_status = dai_monitor.get_sync_status()
sync_status
[22]:
'DEAD'
sync
This function runs the main loop for syncing
WARNING: It is highly recomended that you only interact with this function through the start_sync() and stop_sync() functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script.
[ ]:
# dai_monitor.sync(0, 100)
Event Handler
start_event_handler
Start the event handler in a dedicated thread. The handler thread will continue to run until stop_handler() is called. The handler thread can be accessed with self.handler_thread.
NOTE: this is automatically called with the start_monitor() and start_sync() functions. You should not have to call this function
[ ]:
dai_monitor.start_event_handler()
stop_event_handler
Stop the event handler thread. This function will set an internal flag in the EventMonitor which tells the handler thread to exit its loop. The sync thread will not stop until it finishes the current loop and reaches the top again.
NOTE: The event handler thread will run until all events have been handled, you should be able to let this thread run until completion
[21]:
dai_monitor.stop_event_handler()
get_event_handler_status
Returns the operating status of the event handler
RUNNING: event handler is running
STOPPING: event handler is stopping. If the handler takes too long to stop then something is likely wrong
CRASH: event handler thread crashed.
DEAD: event handler is dead/stopped.
[11]:
event_handler_status = dai_monitor.get_event_handler_status()
event_handler_status
[11]:
'DEAD'
event_handler
This function runs the main loop for event handling
WARNING: It is highly recomended that you only interact with this function through the start_event_handler() and stop_event_handler() functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script.
[23]:
# dai_monitor.event_handler()
handle_event
WARNING: It is highly recomended that you do not interact with this function. However if you so chose, this function could be overridden to define custom behavior for handling events
NOTE: expecting returns from functions called on a w3.eth.filter class
[1]:
# dai_monitor.handle_event(event)
Helpers
get_events_df
Returns processed events as a DataFrame
[28]:
events_df = dai_monitor.get_events_df()
events_df
[28]:
| args | event | transaction | log_index | transaction_index | address | block_number | block | ||
|---|---|---|---|---|---|---|---|---|---|
| block_number | log_index | ||||||||
| 7710833 | 69 | {'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9... | Mint | 0xa1b27194b198762eaa631564fea76008b363c157a1cc... | 69 | 104 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 7710833 | 0x0ed263de26d3c6dc118d44e8d2b75a8aa9684fbccc13... |
| 7710847 | 27 | {'minter': '0xC8355D0E2C265B2Fe495EbBC0fc9AD99... | Mint | 0x1d2000c49507d94ef42ec995e1ea59b41e61bf0c63d4... | 27 | 53 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 7710847 | 0x973c89bdf256cea02cf6eef18fe04e9c4c709939ef38... |
| 7711094 | 64 | {'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9... | Mint | 0x0eda39d1cb1844e8c2f659219f5a414c0b8261e6dee5... | 64 | 32 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 7711094 | 0x8a239157dd06e0514690b8a833f1b2408368f9f049c5... |
| 7711797 | 87 | {'minter': '0x2025A9196d6Fa1011080845c6877f646... | Mint | 0x48ee0eb7b79498b39616c0b8453a15c6dfc04573a08d... | 87 | 140 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 7711797 | 0x752b239a445dd274c0971babd6b84944d379a39f3622... |
| 7712563 | 79 | {'minter': '0xBD9ED130A53CFaFcf81502e4D35329A6... | Mint | 0xc440184b091bcc099a18880caecbcb7d5c94228da33e... | 79 | 118 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 7712563 | 0x52cc53ce83b7b561a61041322e1c9d3d43d4e9055557... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 8246652 | 34 | {'minter': '0xE82941E727d84F99329b94381E67A945... | Mint | 0x88864e21d8377a179cb90999a332c6fecee3e6051e77... | 34 | 45 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 8246652 | 0xf53b11b5ef4b70f57682facdb97f9b9543ec19995648... |
| 8246722 | 76 | {'minter': '0xAB61719309Bf30Cda379B45ac33326B2... | Mint | 0x88c292a8a4169383e0f5cefb0f98fb62e1754eef22fa... | 76 | 89 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 8246722 | 0xed71868e646b8a438d237d1b495730e7704b4a426228... |
| 8246729 | 118 | {'minter': '0xB435871B0959561226b4d903b1abf795... | Mint | 0x2fa76eefb5f261ddb6f2d6c905324f7080cee69194d0... | 118 | 48 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 8246729 | 0x68f79c3f252ae2534b9837fdfe78eeae5b3085feaa38... |
| 8246795 | 41 | {'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c... | Mint | 0xfb432a1a866d437a3c0750ae21a05208a19438ebc229... | 41 | 71 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 8246795 | 0x34ec0ffc36284a6a32e15a7836ddcf34bd2bd80dd6aa... |
| 8246822 | 53 | {'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c... | Mint | 0x33d4dac9341215e18a9c8fa27c9690ab1430b407d854... | 53 | 64 | 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | 8246822 | 0x4944f98a016863441798622dbe3283a162be4362b65b... |
7569 rows × 8 columns
get_events_list
Returns process events as a List
[12]:
events_list = dai_monitor.get_events_list()
events_list[:2]
[12]:
[{'args': {'src': '0xe3eF4F25F436be04Bb45613cC0101b60251996D5',
'dst': '0x27239549DD40E1D60F5B80B0C4196923745B1FD2',
'wad': 7536618188544577904079},
'event': 'Transfer',
'transaction': '0x0cb8e8ddf2c09e27d57b7a70ec8582958f1463518d6668d4d03ff424690ced6a',
'log_index': 319,
'transaction_index': 219,
'address': '0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb',
'block_number': 13896436,
'block': '0xbec26c962fe2fc4b75233b426882b3006ecf1035bf731cca308df333cec26de6'},
{'args': {'src': '0xCba27C8e7115b4Eb50Aa14999BC0866674a96eCB',
'dst': '0x27239549DD40E1D60F5B80B0C4196923745B1FD2',
'wad': 5979084303158062514},
'event': 'Transfer',
'transaction': '0x0cb8e8ddf2c09e27d57b7a70ec8582958f1463518d6668d4d03ff424690ced6a',
'log_index': 320,
'transaction_index': 219,
'address': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'block_number': 13896436,
'block': '0xbec26c962fe2fc4b75233b426882b3006ecf1035bf731cca308df333cec26de6'}]
get_queue_size
Returns the size of the event handler queue. This number represents the amounts of unprocessed events which will be processed so long as EventMonitor.get_handler_status() == 'RUNNING'
[37]:
event_queue_size = dai_monitor.get_queue_size()
event_queue_size
[37]:
1278015
get_contract_events
This function is used internally for mapping ethereum event topics (HEX) to human readable event names. It can be interesting to see the kinds of events for contracts used to initalize the EventMonitor class
[17]:
contract_events = dai_monitor.get_contract_events()
contract_events
[17]:
| 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 | ||||
|---|---|---|---|---|
| name | text | keccak | inputs | |
| 0 | AccrueInterest | AccrueInterest(uint256,uint256,uint256) | 0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470c... | [{'indexed': False, 'name': 'interestAccumulat... |
| 1 | Mint | Mint(address,uint256,uint256) | 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c... | [{'indexed': False, 'name': 'minter', 'type': ... |
| 2 | Redeem | Redeem(address,uint256,uint256) | 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c... | [{'indexed': False, 'name': 'redeemer', 'type'... |
| 3 | Borrow | Borrow(address,uint256,uint256,uint256) | 0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea... | [{'indexed': False, 'name': 'borrower', 'type'... |
| 4 | RepayBorrow | RepayBorrow(address,address,uint256,uint256,ui... | 0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dca... | [{'indexed': False, 'name': 'payer', 'type': '... |
| 5 | LiquidateBorrow | LiquidateBorrow(address,address,uint256,addres... | 0x298637f684da70674f26509b10f07ec2fbc77a335ab1... | [{'indexed': False, 'name': 'liquidator', 'typ... |
| 6 | NewPendingAdmin | NewPendingAdmin(address,address) | 0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9... | [{'indexed': False, 'name': 'oldPendingAdmin',... |
| 7 | NewAdmin | NewAdmin(address,address) | 0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f... | [{'indexed': False, 'name': 'oldAdmin', 'type'... |
| 8 | NewComptroller | NewComptroller(address,address) | 0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540... | [{'indexed': False, 'name': 'oldComptroller', ... |
| 9 | NewMarketInterestRateModel | NewMarketInterestRateModel(address,address) | 0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c419... | [{'indexed': False, 'name': 'oldInterestRateMo... |
| 10 | NewReserveFactor | NewReserveFactor(uint256,uint256) | 0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b... | [{'indexed': False, 'name': 'oldReserveFactorM... |
| 11 | ReservesReduced | ReservesReduced(address,uint256,uint256) | 0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92... | [{'indexed': False, 'name': 'admin', 'type': '... |
| 12 | Failure | Failure(uint256,uint256,uint256) | 0x45b96fe442630264581b197e84bbada861235052c5a1... | [{'indexed': False, 'name': 'error', 'type': '... |
| 13 | Transfer | Transfer(address,address,uint256) | 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4... | [{'indexed': True, 'name': 'from', 'type': 'ad... |
| 14 | Approval | Approval(address,address,uint256) | 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2... | [{'indexed': True, 'name': 'owner', 'type': 'a... |