> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chaintable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Index ERC-20 transfers

> Create an event table for USDC, run a Pipeline in a Notebook, and backfill a short range of transfer history.

This tutorial builds an event table of USDC transfers on Ethereum mainnet, recording the sender, recipient, amount, and transaction hash.

<div className="doc-flow">
  `chain.event.eth` → Filter USDC Transfer events → Extract transfer fields → Transfer event table
</div>

Sign in to the [Chaintable console](https://chaintable.com/spaces) and open your Space. This tutorial uses `demo`; replace it with your Space ID.

## 1. Create a transfer event table

In **Tables**, create a table named `usdc_transfers`, select **Block Event**, and choose **Ethereum**. The resulting table ID is `demo.usdc_transfers.eth`.

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/create-table.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=93ac5e746fe567553a5d8a568a30a56c" alt="Create an Ethereum Block Event Table in Tables" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/create-table.png" />
</Frame>

Add the following fields in **Schema**, keeping the system fields and other defaults:

| Field          | Type      | Content                     |
| -------------- | --------- | --------------------------- |
| `tx_id`        | `TXID`    | Transaction hash            |
| `from_address` | `ADDRESS` | Sender address              |
| `to_address`   | `ADDRESS` | Recipient address           |
| `amount`       | `UINT256` | Raw integer transfer amount |

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/table-schema.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=2c2e30160cd63d91e97891cd831ac538" alt="Transfer table schema with default configuration retained" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/table-schema.png" />
</Frame>

## 2. Run the Pipeline

### Configure the Pipeline

In **Notebooks**, create `backfill_usdc_transfers` and enter the following code. Replace `SPACE` with your Space ID:

```python theme={null}
from blockdb import Column, filter
from blockx import Pipeline, Trigger, SOURCE_ROW

SPACE = 'demo'


def parse_usdc_transfer(event):
    sender, recipient, amount = event['params']
    return {
        'id': event['id'],
        'tx_id': event['tx_id'],
        'from_address': sender,
        'to_address': recipient,
        'amount': amount,
    }


pipeline = Pipeline(
    triggers=[
        Trigger(
            table='chain.event.eth',
            func=parse_usdc_transfer,
            params=[SOURCE_ROW],
            operator=filter(
                (Column('contract_id') == '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
                & (Column('name') == 'Transfer')
            ),
        ),
    ],
    target_table=f'{SPACE}.usdc_transfers.eth',
)

pipeline.backfill(block_start=25939925, block_end=25939934)
```

The code processes data as follows:

* `Trigger` selects USDC Transfer events.
* `SOURCE_ROW` passes each selected event to the function.
* `parse_usdc_transfer` extracts the sender, recipient, and amount from decoded `params`.
* The Pipeline writes returned records to the transfer table specified by `target_table`.

This example defines the function directly in the Notebook. You can also set `func` to an existing Function ID.

### Run the backfill

Save and click **Run**. View progress and results in **Output**.

`backfill()` processes the specified 10 blocks, including both boundary heights, then exits.

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/notebook-backfill.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=bb8e1975722c208d8981ac90f225b8fd" alt="Backfill call and completed output in backfill_usdc_transfers" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/notebook-backfill.png" />
</Frame>

## 3. View transfer data

Return to `usdc_transfers.eth` and check the processed blocks in **Overview**. This run backfills only a limited range; earlier history is still missing.

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/table-overview.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=cb27c8fd2402dc50afde6b666c04945f" alt="Transfer table progress with default settings and the event subtable entry" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/table-overview.png" />
</Frame>

Open **event** under **Subtables** to view transfer records.

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/table-result.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=69f3c25c7c1096d40e9f919418f24ff5" alt="Actual USDC transfer records in the event subtable" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/table-result.png" />
</Frame>

Each record uses the source event's `id`. The Pipeline fills in block fields automatically.

`amount` retains the raw integer value. Divide it by `10^6` to get the USDC amount.

## Optional: keep the table updated

Create a Notebook named `update_usdc_transfers`, copy the code above, and replace the final `pipeline.backfill(...)` line with the following call. Save and run:

```python theme={null}
pipeline.update()
```

By default, `update()` fills history from the earliest unfinished block, then keeps updating after reaching the latest block.

For a large backlog, you can also run `backfill()` in another Notebook at the same time to speed up historical processing.

<Frame>
  <img src="https://mintcdn.com/opcodelabspteltd/TOA0bb8_WqdBuVVN/images/quickstart/index-erc20-transfers/notebook-update.png?fit=max&auto=format&n=TOA0bb8_WqdBuVVN&q=85&s=e1e48ca7c22c67ece066b21aa329b124" alt="Continuous update call and historical processing logs in update_usdc_transfers" width="1920" height="1080" data-path="images/quickstart/index-erc20-transfers/notebook-update.png" />
</Frame>

Select **Switch to Background** to run in the background. Cancel the instance in the account's **Instances** page to stop it. Data already written is retained.
