MCPcopy Create free account
hub / github.com/enviodev/hypersync-client-python / analyze_events

Function analyze_events

examples/top_usdt.py:64–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62 await client.collect_parquet("data", query, config)
63
64def analyze_events():
65 # read raw logs
66 logs = polars.read_parquet(
67 "data/logs.parquet",
68 )
69
70 # read transactions
71 transactions = polars.read_parquet(
72 "data/transactions.parquet",
73 )
74
75 # read decoded logs and join(stack) the rows with raw logs.
76 # then join transactions using the tx hash column from raw logs table.
77 data = polars.read_parquet(
78 "data/decoded_logs.parquet"
79 ).hstack(logs).join(
80 other=transactions,
81 left_on=polars.col("transaction_hash"),
82 right_on=polars.col("hash"),
83 ).group_by(
84 polars.col("from")
85 ).agg(
86 polars.col("value").sum().alias("total_value_sent"),
87 polars.col("gas_used").sum().alias("total_gas_used"),
88 ).sort(
89 polars.col("total_value_sent"),
90 descending=True
91 ).limit(10)
92
93 polars.Config.set_ascii_tables()
94 polars.Config.set_tbl_width_chars(100)
95 polars.Config.set_fmt_str_lengths(50)
96
97 print(data)
98
99asyncio.run(collect_events())
100analyze_events()

Callers 1

top_usdt.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected