TronBatchProcessor from @subsquid/tron-processor retrieves Tron blocks from the SQD Network v2 gateway, the Tron HTTP API, or both.
Data sources
Configure at least one data source. Use both for fast historical sync plus recent blocks.setGateway() also accepts a URL string. In that form the API key defaults to process.env.SQD_API_KEY. GatewaySettings supports url, apiKey, and requestTimeout.
Requests
Request objects usewhere for filters, include for relations, and an optional range.
| Method | where filters | include relations |
|---|---|---|
addLog() | address, topic0 through topic3 | transaction |
addTransaction() | type | logs, internalTransactions |
addTransferTransaction() | owner, to | logs, internalTransactions |
addTransferAssetTransaction() | owner, to, asset | logs, internalTransactions |
addTriggerSmartContractTransaction() | owner, contract, sighash | logs, internalTransactions |
addInternalTransaction() | caller, transferTo | transaction |
0x prefix.
includeAllBlocks(range?) includes blocks without matching items. setBlockRange({from, to?}) applies a global bound.
Field selection
The top-level selector keys are singular:log, not logs. The plural key is ignored because it is not part of FieldSelection.
Handler context and block data
processor.run(database, handler) calls the handler with:
header, transactions, logs, and internalTransactions. Logs and internal transactions expose an optional transaction plus getTransaction(). Transactions expose related logs and internalTransactions collections when requested.
Use TronBatchProcessorFields<typeof processor> to derive the selected field type.
Prometheus
UsesetPrometheusServer(server) for a custom server. setPrometheusPort() is deprecated and throws if a server was already configured. Without an explicit port, PROCESSOR_PROMETHEUS_PORT takes precedence over PROMETHEUS_PORT; otherwise the processor selects an ephemeral port.