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

# Token Transfers

> Subscribe to real-time token transfer events.

## Overview

* **Dataset ID:** [`0304 - Token Transfers`](/data-catalog/evm/transfers/token-transfers)
* **Description:** Token transfer events (native ETH, ERC-20, ERC-721, ERC-1155) produced by TokenTransfersEngine from transactions, internal transactions, and transfer logs.
* **Sample:** [Hugging Face Sample](https://huggingface.co/datasets/BlockDB/Token-Transfers-Ethereum-And-EVM-Cryptocurrency-Data)

## Subscription Parameters

<ParamField body="chain_id" type="number" required>
  Target EVM network. *See the [Chain](/api-reference/enumerations/chain) enumeration.*
</ParamField>

<ParamField body="from_addresses" type="string[]">
  Optional filter: sender addresses (hex, no `0x`).
</ParamField>

<ParamField body="to_addresses" type="string[]">
  Optional filter: recipient addresses (hex, no `0x`).
</ParamField>

<ParamField body="token_addresses" type="string[]">
  Optional filter: token contract addresses (hex, no `0x`); omit for native transfers where applicable.
</ParamField>

<ParamField body="transfer_types" type="string[]">
  Optional filter: transfer kinds (e.g. `native`, `erc20`, `erc721`, `erc1155`).
</ParamField>

## Message Fields

<ResponseField name="block_number" type="number">
  Block containing the transfer.
</ResponseField>

<ResponseField name="block_time" type="string">
  Block time (ISO-8601).
</ResponseField>

<ResponseField name="tx_index" type="number">
  Transaction index within the block.
</ResponseField>

<ResponseField name="log_index" type="number | null">
  Log index when sourced from a log; null when not applicable.
</ResponseField>

<ResponseField name="trace_address" type="string | null">
  Trace address for internal tx transfers (e.g. `"0"`, `"0.1"`); null for other types.
</ResponseField>

<ResponseField name="from_address" type="string">
  Sender address (hex).
</ResponseField>

<ResponseField name="to_address" type="string">
  Recipient address (hex).
</ResponseField>

<ResponseField name="token_address" type="string | null">
  Token contract; null for native ETH transfers.
</ResponseField>

<ResponseField name="amount_raw" type="string">
  Raw amount (integer string in token/native units).
</ResponseField>

<ResponseField name="amount_adj" type="string | null">
  Decimal-adjusted amount; null if decimals unknown or NFT.
</ResponseField>

<ResponseField name="token_id" type="string | null">
  NFT / ERC-1155 id when applicable.
</ResponseField>

<ResponseField name="transfer_type" type="integer">
  Transfer mechanism as integer enum (see [Transfer Type](/api-reference/enumerations/transfer-type)).
</ResponseField>

<ResponseField name="_tracing_id" type="string">
  Row lineage id (hex).
</ResponseField>

<ResponseField name="_parent_tracing_ids" type="string[]">
  Parent lineage ids (hex).
</ResponseField>

<ResponseField name="_created_at" type="string">
  Record creation time (ISO-8601).
</ResponseField>

<ResponseField name="_updated_at" type="string">
  Record last update time (ISO-8601).
</ResponseField>

## Subscription Example

<CodeGroup>
  ```bash bash theme={null}
  # Use wscat to connect and subscribe
  wscat -c wss://api.blockdb.io/v1/evm/ \
    -H "Authorization: Bearer $BLOCKDB_API_KEY" \
    -x '{"action": "subscribe", "dataset_id": "0304", "chain_id": 1, "params": {}}'
  ```

  ```c C theme={null}
  #include <libwebsockets.h>
  #include <string.h>
  #include <stdio.h>

  static int callback_blockdb(struct lws *wsi, enum lws_callback_reasons reason,
                              void *user, void *in, size_t len) {
      switch (reason) {
          case LWS_CALLBACK_CLIENT_ESTABLISHED:
              lws_callback_on_writable(wsi);
              break;
          case LWS_CALLBACK_CLIENT_RECEIVE:
              printf("Received: %s\n", (char *)in);
              break;
          case LWS_CALLBACK_CLIENT_WRITEABLE: {
              unsigned char buf[LWS_PRE + 1024];
              unsigned char *p = &buf[LWS_PRE];
              size_t n = sprintf((char *)p, "{\"action\": \"subscribe\", \"dataset_id\": \"0304\", \"chain_id\": 1, \"params\": {}}");
              lws_write(wsi, p, n, LWS_WRITE_TEXT);
              break;
          }
      }
      return 0;
  }
  ```

  ```csharp .NET theme={null}
  using System;
  using System.Net.WebSockets;
  using System.Text;
  using System.Threading;
  using System.Threading.Tasks;

  class Program {
      static async Task Main() {
          using var ws = new ClientWebSocket();
          ws.Options.SetRequestHeader("Authorization", $"Bearer {Environment.GetEnvironmentVariable("BLOCKDB_API_KEY")}");
          await ws.ConnectAsync(new Uri("wss://api.blockdb.io/v1/evm/"), CancellationToken.None);

          var subMsg = "{\"action\": \"subscribe\", \"dataset_id\": \"0304\", \"chain_id\": 1, \"params\": {}}";
          await ws.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(subMsg)), WebSocketMessageType.Text, true, CancellationToken.None);

          var buffer = new byte[1024 * 4];
          while (ws.State == WebSocketState.Open) {
              var result = await ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
              Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, result.Count));
          }
      }
  }
  ```

  ```python Python theme={null}
  import websocket
  import json
  import os

  def on_message(ws, message):
      print(f"Received: {message}")

  def on_open(ws):
      msg = {
          "action": "subscribe",
          "dataset_id": "0304",
          "chain_id": 1,
          "params": {}
      }
      ws.send(json.dumps(msg))

  ws = websocket.WebSocketApp(
      "wss://api.blockdb.io/v1/evm/",
      header={"Authorization": f"Bearer {os.getenv('BLOCKDB_API_KEY')}"},
      on_message=on_message,
      on_open=on_open
  )
  ws.run_forever()
  ```

  ```javascript Node.js theme={null}
  const WebSocket = require('ws');

  const ws = new WebSocket('wss://api.blockdb.io/v1/evm/', {
    headers: { 'Authorization': `Bearer ${process.env.BLOCKDB_API_KEY}` }
  });

  ws.on('open', () => {
    ws.send(JSON.stringify({
      action: 'subscribe',
      dataset_id: '0304',
      chain_id: 1,
      params: {}
    }));
  });

  ws.on('message', (data) => {
    console.log('Received:', JSON.parse(data));
  });
  ```

  ```go Go theme={null}
  package main

  import (
  	"fmt"
  	"log"
  	"net/http"
  	"os"
  	"github.com/gorilla/websocket"
  )

  func main() {
  	header := http.Header{"Authorization": []string{"Bearer " + os.Getenv("BLOCKDB_API_KEY")}}
  	c, _, err := websocket.DefaultDialer.Dial("wss://api.blockdb.io/v1/evm/", header)
  	if err != nil {
  		log.Fatal("dial:", err)
  	}
  	defer c.Close()

  	sub := `{"action": "subscribe", "dataset_id": "0304", "chain_id": 1, "params": {}}`
  	err = c.WriteMessage(websocket.TextMessage, []byte(sub))
  	if err != nil {
  		log.Fatal("write:", err)
  	}

  	for {
  		_, message, err := c.ReadMessage()
  		if err != nil {
  			log.Fatal("read:", err)
  		}
  		fmt.Printf("Received: %s\n", message)
  	}
  }
  ```
</CodeGroup>

## Response Example

<CodeGroup>
  ```json Response theme={null}
  {
    "chain_id": 1,
    "dataset_id": "0304",
    "is_reorg": false,
    "data": {
      "block_number": 12345680,
      "block_time": "2025-10-29T00:01:23Z",
      "tx_index": 5,
      "log_index": 2,
      "trace_address": null,
      "from_address": "0000000000000000000000000000000000000000",
      "to_address": "0000000000000000000000000000000000000001",
      "token_address": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "amount_raw": "1000000000000000000",
      "amount_adj": "1.0",
      "token_id": null,
      "transfer_type": 2,
      "_tracing_id": "0304000000000000000000000000000000000001",
      "_parent_tracing_ids": [
        "0102000000000000000000000000000000000001",
        "0201000000000000000000000000000000000001"
      ],
      "_created_at": "2025-11-11T18:42:15.123Z",
      "_updated_at": "2025-11-11T18:42:15.123Z"
    }
  }
  ```
</CodeGroup>


## AsyncAPI

````yaml specs/wss/evm/transfers/token-transfers.yaml token-transfers
id: token-transfers
title: Token-transfers
description: ''
servers:
  - id: production
    protocol: wss
    host: api.blockdb.io/v1/evm/
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_2
    id: onSubscribe
    title: On subscribe
    type: receive
    messages:
      - &ref_5
        id: subscribe
        payload:
          - name: subscribe
            type: object
            properties:
              - name: action
                type: string
                description: subscribe
                required: true
              - name: chain_id
                type: integer
                required: true
              - name: dataset_id
                type: string
                description: '0304'
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: from_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: to_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: token_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: transfer_types
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            action:
              type: string
              const: subscribe
              x-parser-schema-id: <anonymous-schema-2>
            chain_id:
              type: integer
              x-parser-schema-id: <anonymous-schema-3>
            dataset_id:
              type: string
              const: '0304'
              x-parser-schema-id: <anonymous-schema-4>
            params:
              type: object
              properties:
                from_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-7>
                  x-parser-schema-id: <anonymous-schema-6>
                to_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-9>
                  x-parser-schema-id: <anonymous-schema-8>
                token_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-11>
                  x-parser-schema-id: <anonymous-schema-10>
                transfer_types:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-13>
                  x-parser-schema-id: <anonymous-schema-12>
              x-parser-schema-id: <anonymous-schema-5>
          required:
            - action
            - chain_id
            - dataset_id
            - params
          x-parser-schema-id: <anonymous-schema-1>
        title: Subscribe
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe
          - id: x-parser-message-name
            value: subscribe
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: token-transfers
  - &ref_3
    id: onUnsubscribe
    title: On unsubscribe
    type: receive
    messages:
      - &ref_6
        id: unsubscribe
        payload:
          - name: unsubscribe
            type: object
            properties:
              - name: action
                type: string
                description: unsubscribe
                required: true
              - name: chain_id
                type: integer
                required: true
              - name: dataset_id
                type: string
                description: '0304'
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            action:
              type: string
              const: unsubscribe
              x-parser-schema-id: <anonymous-schema-15>
            chain_id:
              type: integer
              x-parser-schema-id: <anonymous-schema-16>
            dataset_id:
              type: string
              const: '0304'
              x-parser-schema-id: <anonymous-schema-17>
          required:
            - action
            - chain_id
            - dataset_id
          x-parser-schema-id: <anonymous-schema-14>
        title: Unsubscribe
        example: |-
          {
            "action": "<string>",
            "chain_id": 123,
            "dataset_id": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribe
          - id: x-parser-message-name
            value: unsubscribe
    bindings: []
    extensions: *ref_0
  - &ref_4
    id: emitUpdates
    title: Emit updates
    type: send
    messages:
      - &ref_7
        id: subscribe_response
        payload:
          - name: subscribe_response
            type: object
            properties:
              - name: action
                type: string
                description: subscribe
                required: true
              - name: chain_id
                type: integer
                required: true
              - name: dataset_id
                type: string
                description: '0304'
                required: true
              - name: status
                type: string
                enumValues:
                  - success
                  - error
                required: true
              - name: error
                type: object
                required: false
                properties:
                  - name: code
                    type: string
                    required: true
                  - name: message
                    type: string
                    required: true
                  - name: severity
                    type: string
                    enumValues:
                      - info
                      - warning
                      - error
                      - critical
                    required: true
                  - name: retryable
                    type: boolean
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            action:
              type: string
              const: subscribe
              x-parser-schema-id: <anonymous-schema-19>
            chain_id:
              type: integer
              x-parser-schema-id: <anonymous-schema-20>
            dataset_id:
              type: string
              const: '0304'
              x-parser-schema-id: <anonymous-schema-21>
            status:
              type: string
              enum:
                - success
                - error
              x-parser-schema-id: <anonymous-schema-22>
            error: &ref_1
              type: object
              properties:
                code:
                  type: string
                  x-parser-schema-id: <anonymous-schema-23>
                message:
                  type: string
                  x-parser-schema-id: <anonymous-schema-24>
                severity:
                  type: string
                  enum:
                    - info
                    - warning
                    - error
                    - critical
                  x-parser-schema-id: <anonymous-schema-25>
                retryable:
                  type: boolean
                  x-parser-schema-id: <anonymous-schema-26>
              required:
                - code
                - message
                - severity
                - retryable
              x-parser-schema-id: ErrorObject
          required:
            - action
            - chain_id
            - dataset_id
            - status
          x-parser-schema-id: <anonymous-schema-18>
        title: Subscribe_response
        example: |-
          {
            "action": "<string>",
            "chain_id": 123,
            "dataset_id": "<string>",
            "status": "<string>",
            "error": {
              "code": "<string>",
              "message": "<string>",
              "severity": "<string>",
              "retryable": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe_response
          - id: x-parser-message-name
            value: subscribe_response
      - &ref_8
        id: unsubscribe_response
        payload:
          - name: unsubscribe_response
            type: object
            properties:
              - name: action
                type: string
                description: unsubscribe
                required: true
              - name: chain_id
                type: integer
                required: true
              - name: dataset_id
                type: string
                description: '0304'
                required: true
              - name: status
                type: string
                enumValues:
                  - success
                  - error
                required: true
              - name: error
                type: object
                required: false
                properties:
                  - name: code
                    type: string
                    required: true
                  - name: message
                    type: string
                    required: true
                  - name: severity
                    type: string
                    enumValues:
                      - info
                      - warning
                      - error
                      - critical
                    required: true
                  - name: retryable
                    type: boolean
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            action:
              type: string
              const: unsubscribe
              x-parser-schema-id: <anonymous-schema-28>
            chain_id:
              type: integer
              x-parser-schema-id: <anonymous-schema-29>
            dataset_id:
              type: string
              const: '0304'
              x-parser-schema-id: <anonymous-schema-30>
            status:
              type: string
              enum:
                - success
                - error
              x-parser-schema-id: <anonymous-schema-31>
            error: *ref_1
          required:
            - action
            - chain_id
            - dataset_id
            - status
          x-parser-schema-id: <anonymous-schema-27>
        title: Unsubscribe_response
        example: |-
          {
            "action": "<string>",
            "chain_id": 123,
            "dataset_id": "<string>",
            "status": "<string>",
            "error": {
              "code": "<string>",
              "message": "<string>",
              "severity": "<string>",
              "retryable": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribe_response
          - id: x-parser-message-name
            value: unsubscribe_response
      - &ref_9
        id: update
        payload:
          - name: update
            type: object
            properties:
              - name: chain_id
                type: integer
                required: true
              - name: dataset_id
                type: string
                description: '0304'
                required: true
              - name: is_reorg
                type: boolean
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: block_number
                    type: integer
                    required: false
                  - name: tx_index
                    type: integer
                    required: false
                  - name: from_address
                    type: string
                    required: false
                  - name: to_address
                    type: string
                    required: false
                  - name: token_address
                    type: string
                    required: false
                  - name: transfer_type
                    type: string
                    required: false
                  - name: amount_raw
                    type: string
                    required: false
                  - name: _tracing_id
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            chain_id:
              type: integer
              x-parser-schema-id: <anonymous-schema-33>
            dataset_id:
              type: string
              const: '0304'
              x-parser-schema-id: <anonymous-schema-34>
            is_reorg:
              type: boolean
              x-parser-schema-id: <anonymous-schema-35>
            data:
              type: object
              properties:
                block_number:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-37>
                tx_index:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-38>
                from_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-39>
                to_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-40>
                token_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-41>
                transfer_type:
                  type: string
                  x-parser-schema-id: <anonymous-schema-42>
                amount_raw:
                  type: string
                  x-parser-schema-id: <anonymous-schema-43>
                _tracing_id:
                  type: string
                  x-parser-schema-id: <anonymous-schema-44>
              x-parser-schema-id: <anonymous-schema-36>
          required:
            - chain_id
            - dataset_id
            - is_reorg
            - data
          x-parser-schema-id: <anonymous-schema-32>
        title: Update
        example: |-
          {
            "chain_id": 123,
            "dataset_id": "<string>",
            "is_reorg": true,
            "data": {
              "block_number": 123,
              "tx_index": 123,
              "from_address": "<string>",
              "to_address": "<string>",
              "token_address": "<string>",
              "transfer_type": "<string>",
              "amount_raw": "<string>",
              "_tracing_id": "<string>"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: update
          - id: x-parser-message-name
            value: update
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_2
  - *ref_3
receiveOperations:
  - *ref_4
sendMessages:
  - *ref_5
  - *ref_6
receiveMessages:
  - *ref_7
  - *ref_8
  - *ref_9
extensions:
  - id: x-parser-unique-object-id
    value: token-transfers
securitySchemes: []

````