newBlockTraces - EVM Data Stream

The newBlockTraces topic sends one notification per block, carrying the block's identity and an array of call traces for the transactions that match your filters. It carries the same trace data as newMinedTransactionsTraces, grouped by block.

WebSocket-only topic. Subscribe with getblock_subscribe on any network endpoint.

Without filters, every notification carries the trace of every transaction in the block, which can be several megabytes on Ethereum. Filter by address or call type unless you are building a full trace index.

Parameters

ParameterTypeRequiredDescription
filters.transactionHashstring or arrayNoOne transaction hash, or an array of hashes.
filters.fromAddressstring or arrayNoMatch traces with any call frame from these addresses.
filters.toAddressstring or arrayNoMatch traces with any call frame to these addresses.
filters.callTypestring or arrayNoMatch frames of these types: call, delegatecall, staticcall, create, or create2.
filters.statusstringNosuccess or failed: match traces that contain a frame with this status.

Filters match on any frame in the call tree, not only the top-level call. A transaction that touches a contract through an internal call matches toAddress for that contract, and status: "failed" matches a transaction with a failed internal call even when its top-level call succeeded. Check error on each frame to see which call failed.

Request Example

bash# WebSocket-only. Connect first:
wscat -c 'wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream' -H 'Authorization: Bearer <API-KEY>'

# Then send:
{"jsonrpc":"2.0","id":1,"method":"getblock_subscribe","params":[{"topic":"newBlockTraces","filters":{"toAddress":"0xdAC17F958D2ee523a2206206994597C13D831ec7"}}]}
javascript// npm install ws
import WebSocket from 'ws';

const ws = new WebSocket('wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream', {
  headers: { Authorization: 'Bearer <API-KEY>' }
});

ws.on('open', () => {
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getblock_subscribe',
    params: [{
      topic: 'newBlockTraces',
      filters: {
        toAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
      }
    }]
  }));
});

ws.on('message', (raw) => {
  const msg = JSON.parse(raw);

  // First reply is the subscription ID (or an error)
  if (msg.id !== undefined) {
    console.log(msg.error ?? `Subscribed: ${msg.result}`);
    return;
  }

  const { removed, data } = msg.params.result;
  console.log(removed ? 'REVERTED' : 'block', parseInt(data.blockNumber, 16), `${data.traces.length} matching traces`);
});
python# pip install "websockets>=14"
import asyncio, json, websockets

URL = "wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream"
HEADERS = {"Authorization": "Bearer <API-KEY>"}

async def main():
    # ping_interval=None: the server sends its own keepalive pings (see Connection keepalive)
    async with websockets.connect(URL, additional_headers=HEADERS, ping_interval=None) as ws:
        await ws.send(json.dumps({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "getblock_subscribe",
            "params": [{
                "topic": "newBlockTraces",
                "filters": {
                    "toAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
                }
            }]
        }))

        async for message in ws:
            msg = json.loads(message)

            # First reply is the subscription ID (or an error)
            if "id" in msg:
                print(msg.get("error") or f"Subscribed: {msg['result']}")
                continue

            event = msg["params"]["result"]
            removed, data = event["removed"], event["data"]
            print('REVERTED' if removed else 'block', int(data['blockNumber'], 16), len(data['traces']), 'matching traces')

asyncio.run(main())

Response Example

The first reply is the subscription ID:

json{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x23053ab0cfd75fdbae902fbb73dd1ae9"
}

Every later message is an event notification (traces shortened to one entry):

json{
  "jsonrpc": "2.0",
  "method": "getblock_subscribe",
  "params": {
    "subscription": "0x23053ab0cfd75fdbae902fbb73dd1ae9",
    "result": {
      "eventId": "eth:mainnet:traces:0x19ddc6864bd5ec1cdbd493e3d3653b529d79293a67735…",
      "removed": false,
      "revision": 116876400,
      "data": {
        "blockHash": "0x19ddc6864bd5ec1cdbd493e3d3653b529d79293a6773517018153cdff6ac0be2",
        "blockNumber": "0x18d1e1e",
        "traces": [
          {
            "txHash": "0x6b362543c83c1d18b27701235338c05a7e04c2e5098bed46d60afe9a0f17d2a1",
            "result": {
              "from": "0x4b3dd3690ba06b2a73089e02381d0eba9a7dbca5",
              "gas": "0xb435",
              "gasUsed": "0xa15d",
              "to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
              "input": "0xa9059cbb000000000000000000000000a2050435e59f41300b7787808e976255faa198e50000000000000000000000000000000000000000000000000000000006f4b360",
              "value": "0x0",
              "type": "CALL"
            }
          },
          "…"
        ]
      }
    }
  }
}

Response Parameters

The result object contains the event envelope and the payload in data.

FieldTypeDescription
eventIdstringStable event identifier. A reorg correction reuses it.
removedbooleantrue when a reorg removed this previously delivered event.
revisionnumberEvent version. For one eventId, a greater revision is newer.
data.blockHashstringBlock hash.
data.blockNumberstringBlock number, hex-encoded.
data.tracesarrayTraces of the matching transactions, in block order.
data.traces[].txHashstringTransaction hash.
data.traces[].resultobjectTop-level call frame. Its fields are below.
data.traces[].result.typestringFrame type: CALL, DELEGATECALL, STATICCALL, CREATE, CREATE2, or SELFDESTRUCT.
data.traces[].result.fromstringCaller address.
data.traces[].result.tostringCallee address, or the created contract.
data.traces[].result.valuestringNative value sent with the call in wei, hex-encoded.
data.traces[].result.gasstringGas available to the frame, hex-encoded.
data.traces[].result.gasUsedstringGas used by the frame, hex-encoded.
data.traces[].result.inputstringCall data.
data.traces[].result.outputstringReturn data, when there is any.
data.traces[].result.errorstringError message when the frame failed, for example execution reverted.
data.traces[].result.revertReasonstringDecoded revert reason, when available.
data.traces[].result.callsarrayChild frames, each with the same fields, recursively.

Traces use the node's callTracer format (as debug_traceTransaction returns it), so fields can vary by network client. For example, Robinhood Mainnet frames also include beforeEVMTransfers and afterEVMTransfers. Trace availability also depends on the network.

Use Cases

  • Building a trace or internal-transaction index block by block
  • Per-block analytics of contract interactions
  • Reconciling all internal transfers of a block in one atomic update

Error Handling

CodeMessageCause
-32602filters.status must be success or failedstatus has an unsupported value.
-32602unsupported filters.callType "…"callType has an unsupported value.
-32602invalid filters.toAddress address "…"An address filter is not a 20-byte hex address. The same applies to fromAddress.
-32602invalid newBlockTraces request: json: unknown field "…"The request has a field this topic does not accept.
-32001subscription limit exceededYou already have 15 active or pending subscriptions.