Intermediate⏱ 25 min8 steps

Query Decoded ERC-20 Transfer Events

Learn to query token transfers directly: find the decoded Transfer events table, filter by token contract, handle decimals, and rank the biggest movers.

Wevr Guides ·

Every ERC-20 token on Ethereum — stablecoins, governance tokens, wrapped assets — reports its movements the same way: by emitting a Transfer event whenever tokens change hands. Once you can query those events, you can answer almost any token question with a few lines of SQL: who received the most, how much moved per day, which wallets are accumulating.

This tutorial assumes you have run at least one query before. If not, start with our first-query lesson and come back. You will need the Wevr query editor, which runs ClickHouse SQL over decoded on-chain data.

Understand what a Transfer event contains

The ERC-20 standard defines the event like this:

Transfer(address indexed from, address indexed to, uint256 value)

Three fields, plus the context every event carries: which contract emitted it, in which transaction, in which block, at what time. Decoding turns the raw log into named columns, so instead of parsing hexadecimal topics you query from, to and value directly.

Two details matter before you write anything:

  • The emitting contract is the token. To ask about USDC, you filter on events emitted by the USDC contract address — not by the token's name, which anyone can copy.
  • value is a raw integer. Tokens store amounts in their smallest unit. USDC uses 6 decimals, so a value of 1,000,000 means 1 USDC. Most tokens use 18 decimals.

Find the right table

In the tables catalog, look for the decoded ERC-20 transfer events table. Naming follows the platform's convention for decoded events — something like erc20_evt_transfer — but always confirm the exact table and column names in the tables catalog before running a query. You are looking for columns covering the token contract address, from, to, value and block_timestamp.

Run a tiny exploratory query first to see the shape of the data:

SELECT *
FROM erc20_evt_transfer
ORDER BY block_timestamp DESC
LIMIT 10;

Ten rows is enough to learn the column names and see what values look like. Adjust the table name to match the catalog if it differs.

Filter to one token

Now narrow down to a single token by its contract address. For USDC on Ethereum, the contract is 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48. Addresses are often stored lowercase, so compare in lowercase:

SELECT block_timestamp, "from", "to", value / 1e6 AS usdc
FROM erc20_evt_transfer
WHERE contract_address = lower('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
  AND block_timestamp >= now() - INTERVAL 1 DAY
ORDER BY usdc DESC
LIMIT 20;

A few things are happening here. from and to are quoted because they are SQL keywords. Dividing value by 1e6 converts USDC's raw amount into whole tokens. And the time filter keeps the scan small, which makes the query fast.

The result is the twenty largest USDC transfers of the past day — a genuinely useful list.

Aggregate by day

Individual transfers are interesting; totals are informative. Group by day to see how much USDC moved each day over the last month:

SELECT toDate(block_timestamp) AS day,
       count() AS transfers,
       sum(value) / 1e6 AS usdc_moved
FROM erc20_evt_transfer
WHERE contract_address = lower('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
  AND block_timestamp >= now() - INTERVAL 30 DAY
GROUP BY day
ORDER BY day;

Chart usdc_moved by day and you will see the rhythm of the token: weekday peaks, weekend lulls, and the occasional spike worth investigating.

Rank the biggest receivers

To see who is accumulating, group by recipient instead:

SELECT "to" AS receiver,
       sum(value) / 1e6 AS usdc_received,
       count() AS transfers
FROM erc20_evt_transfer
WHERE contract_address = lower('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
  AND block_timestamp >= now() - INTERVAL 7 DAY
GROUP BY receiver
ORDER BY usdc_received DESC
LIMIT 25;

Expect the top of the list to be dominated by exchanges, bridges and DeFi contracts. That is normal — they handle enormous volume on behalf of many users. Paste any unfamiliar address into Footprint to see who it belongs to.

Avoid the common mistakes

  • Wrong decimals. Dividing an 18-decimal token by 1e6 produces nonsense. Check the token's decimals before converting.
  • Matching by symbol. Never identify a token by its name or symbol. Lookalike tokens exist precisely to exploit that.
  • Unbounded scans. Always add a time filter while exploring. A query over all history can be slow and is rarely what you need.
  • Mints and burns. Transfers from the zero address are mints; transfers to it are burns. Exclude or isolate them depending on your question.

Troubleshooting your queries

Empty results. The usual cause is an address mismatch. Make sure you are comparing lowercase to lowercase, that the address has no stray spaces, and that you are querying the right chain — the same token often has a different contract address on each network.

Absurd amounts. If transfers look trillions of tokens large, you forgot to divide by the token's decimals, or divided by the wrong power of ten.

Slow queries. Tighten the time filter first. Then make sure your WHERE clause filters on the token contract before any grouping — filtering early keeps the engine scanning only the rows you need.

Where to go next

You now have three templates — largest transfers, daily totals, top receivers — that work for any ERC-20 token once you swap the contract address and decimals. Save each one in the editor so you can reuse them.

From here, try joining transfers against a list of known exchange addresses to estimate exchange inflows for a token, or comparing the same token's activity on Ethereum and Base. Same events, same queries, a different chain — and a much richer picture of where the token actually lives.