Skip to main content
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 use where for filters, include for relations, and an optional range.
Methodwhere filtersinclude relations
addLog()address, topic0 through topic3transaction
addTransaction()typelogs, internalTransactions
addTransferTransaction()owner, tologs, internalTransactions
addTransferAssetTransaction()owner, to, assetlogs, internalTransactions
addTriggerSmartContractTransaction()owner, contract, sighashlogs, internalTransactions
addInternalTransaction()caller, transferTotransaction
Tron hexadecimal addresses and hashes do not use a 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:
Use 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:
Each block contains 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

Use setPrometheusServer(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.