Analyze one day of token transfers
Read one day of ERC-20 token transfers with SQL and find who received the most.
Goal
Read every PENDLE token transfer on Ethereum on 6 January 2024, then rank the five addresses that received the most. The day runs from 00:00 to 24:00 UTC, so the result is the same in every time zone.
PENDLE is an ERC-20 token with 18 decimals. To use another token, change its address and its decimals.
Before you begin
Use an Ethereum client that serves historical logs for the requested date.
Each cell includes a saved result. Select Run all to query the provider.
1. Resolve the UTC day
Use block_range to get the block interval for
2024-01-06. The interval’s to_block is exclusive, but BETWEEN includes
its upper bound, so the queries below use to_block - 1.
2. Fetch and decode transfer logs
get_logs takes the token address and the
Transfer event signature. The join’s block_number BETWEEN condition bounds the
read: the node receives the day’s blocks, not the whole chain. The query returns
each matching log with decoded sender, recipient, and value fields.
3. Aggregate top recipients
Count transfers and sum the amount received by each recipient. Return the five recipients with the largest totals.