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

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# Tron query builder

> Fields, filters, and ranges supported by TronQueryBuilder.

`tronQuery()` returns a typed `TronQueryBuilder`. Add the fields you need, then add one or more range-scoped requests.

```ts theme={"system"}
import { tronQuery } from '@subsquid/pipes/tron'

const query = tronQuery()
  .addFields({
    block: { number: true, timestamp: true },
    log: { address: true, topics: true, data: true },
  })
  .addLogRequest({
    range: { from: 84_000_000 },
    request: { address: ['a614f803b6fd780986a42c78ec9c7f77e6ded13c'] },
  })
```

## Methods

```ts theme={"system"}
class TronQueryBuilder<F extends FieldSelection = {}> {
  addFields<T>(fields: T): TronQueryBuilder<F & T>
  addTransactionRequest(options: RequestOptions<TransactionRequest>): this
  addTransferTransactionRequest(options: RequestOptions<TransferTransactionRequest>): this
  addTransferAssetTransactionRequest(options: RequestOptions<TransferAssetTransactionRequest>): this
  addTriggerSmartContractTransactionRequest(options: RequestOptions<TriggerSmartContractTransactionRequest>): this
  addLogRequest(options: RequestOptions<LogRequest>): this
  addInternalTransactionRequest(options: RequestOptions<InternalTransactionRequest>): this
  includeAllBlocks(range?: Range): this
  addRange(range: PortalRange): this
  merge(query?: TronQueryBuilder<F>): this
  build(options?: { setupQuery?: SetupQueryFn<TronQueryBuilder<F>> }): QueryAwareTransformer
}
```

`addFields()` narrows both the TypeScript output and the fields requested from Portal. The stream always adds `block.number` and `block.hash` for cursor handling.

## Field groups

| Group | Fields |
| - | - |
| `block` | `number`, `hash`, `parentHash`, `txTrieRoot`, `version`, `timestamp`, `witnessAddress`, `witnessSignature` |
| `transaction` | `transactionIndex`, `hash`, `ret`, `signature`, `type`, `parameter`, `permissionId`, `refBlockBytes`, `refBlockHash`, `feeLimit`, `expiration`, `timestamp`, `rawDataHex`, `fee`, `contractResult`, `contractAddress`, `resMessage`, `withdrawAmount`, `unfreezeAmount`, `withdrawExpireAmount`, `cancelUnfreezeV2Amount`, `result`, `energyFee`, `energyUsage`, `energyUsageTotal`, `netUsage`, `netFee`, `originEnergyUsage`, `energyPenaltyTotal` |
| `log` | `transactionIndex`, `logIndex`, `address`, `data`, `topics` |
| `internalTransaction` | `transactionIndex`, `internalTransactionIndex`, `hash`, `callerAddress`, `transferToAddress`, `callValueInfo`, `note`, `rejected`, `extra` |

## Request filters

| Method | Filters |
| - | - |
| `addTransactionRequest()` | `type`, `logs`, `internalTransactions` |
| `addTransferTransactionRequest()` | `owner`, `to`, `logs`, `internalTransactions` |
| `addTransferAssetTransactionRequest()` | `owner`, `to`, `asset`, `logs`, `internalTransactions` |
| `addTriggerSmartContractTransactionRequest()` | `owner`, `contract`, `sighash`, `logs`, `internalTransactions` |
| `addLogRequest()` | `address`, `topic0`, `topic1`, `topic2`, `topic3`, `transaction` |
| `addInternalTransactionRequest()` | `caller`, `transferTo`, `transaction` |

Values inside a filter list are ORed. Different fields in one request are ANDed. Separate request clauses are combined across their ranges.

The `asset` filter uses the bare-hex value stored by Portal, not the decimal TRC-10 token ID. Encode the ASCII digits before filtering. For example, token ID `1005157` is `31303035313537`:

```ts theme={"system"}
import { tronQuery } from '@subsquid/pipes/tron'

const asset = Buffer.from('1005157').toString('hex')

tronQuery().addTransferAssetTransactionRequest({
  range: { from: 84_000_000, to: 84_000_000 },
  request: { asset: [asset] },
})
```

## Ranges

Request ranges accept block numbers, formatted block-number strings, ISO dates, `Date` objects, and `'latest'` for `from`.

```ts theme={"system"}
type PortalRange = {
  from?: number | string | 'latest' | Date
  to?: number | string | Date
}
```

Dates are resolved through the dataset's timestamp endpoint before streaming. Resolution is at Portal chunk granularity, so a date is a coarse starting point rather than an exact timestamp boundary. Use numeric block bounds when the range must be precise. If `from` is `'latest'`, `to` must be a block number.

## Tron-specific formats

* Hex strings do not have a `0x` prefix.
* Transaction-level addresses use the 21-byte `41...` form.
* Log addresses use the 20-byte form without `41`.
* Large signed integer fields are returned as `bigint`.

See [Handling Tron data](../../guides/basic-development/handling-tron-data) for decoding examples.


## Related topics

- [Handling Tron data](/en/sdk/pipes-sdk/tron/guides/basic-development/handling-tron-data.md)
- [Tron portal stream](/en/sdk/pipes-sdk/tron/reference/basic-components/source.md)
- [Query builder](/en/sdk/pipes-sdk/solana/reference/basic-components/query-builder.md)
- [Bitcoin query builder](/en/sdk/pipes-sdk/bitcoin/reference/basic-components/query-builder.md)
- [Hyperliquid fills query builder](/en/sdk/pipes-sdk/hyperliquid/reference/basic-components/query-builder.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.