Analyze ERC-20 transfers for a UTC day
Fetch ERC-20 Transfer logs for one UTC day and query the decoded rows with SQL.
Goal
Fetch and decode one UTC day of ERC-20 Transfer logs, then rank recipients by
the total amount received. The runnable example uses PENDLE on Ethereum mainnet,
so the SQL uses its contract address and 18-decimal formatting.
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
get_logs expects an inclusive upper bound. The
query passes to_block - 1.
2. Fetch and decode transfer logs
get_logs takes the token address, Transfer event
signature, and block range. 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.