> ## 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.

# Handling Tron data

> Work with Tron transactions, logs, internal calls, and value types.

The Tron query builder exposes transactions, event logs, internal transactions, and block headers. Filters and returned fields use the same formats as the Tron Portal API.

## Address and hex formats

Tron Portal hex strings are bare, without `0x`.

* Transaction filters and fields use 21-byte addresses beginning with `41`, for example `41a614f8...`.
* Log filters and `log.address` use the lower 20 bytes, without `41`, for example `a614f8...`.
* Log topics are 32-byte ABI words. An indexed address occupies the final 20 bytes.

Using the `41...` USDT address in a log filter returns no matches. Use the 20-byte form for `addLogRequest()`.

## Decode TRC-20 transfers

TRC-20 logs use the same ABI event layout as ERC-20 logs, but the hex strings are not `0x`-prefixed. Decode them explicitly:

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

const USDT = 'a614f803b6fd780986a42c78ec9c7f77e6ded13c'
const TRANSFER_TOPIC = 'ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

export const usdtTransfers = tronQuery()
  .addFields({
    block: { number: true, timestamp: true },
    log: { transactionIndex: true, logIndex: true, topics: true, data: true },
  })
  .addLogRequest({
    range: { from: 84_000_000 },
    request: { address: [USDT], topic0: [TRANSFER_TOPIC] },
  })
  .build()
  .pipe((blocks) =>
    blocks.flatMap((block) =>
      block.logs.flatMap((log) => {
        if (!log.data || !log.topics?.[1] || !log.topics[2]) return []

        return [{
          block: block.header.number,
          timestamp: block.header.timestamp,
          from: `41${log.topics[1].slice(-40)}`,
          to: `41${log.topics[2].slice(-40)}`,
          amount: BigInt(`0x${log.data}`),
        }]
      }),
    ),
  )
```

`evmEventDecoder()` cannot be reused for these logs because EVM Portal data uses `0x`-prefixed hex.

## Transaction request families

| Method | Data selected |
| - | - |
| `addTransactionRequest()` | Transactions filtered by contract `type`. |
| `addTransferTransactionRequest()` | Native TRX transfers. |
| `addTransferAssetTransactionRequest()` | TRC-10 asset transfers. |
| `addTriggerSmartContractTransactionRequest()` | Smart-contract calls filtered by owner, contract, or method selector. |
| `addLogRequest()` | TVM event logs. |
| `addInternalTransactionRequest()` | Contract-internal calls and value movements. |

Transaction request methods accept `logs: true` and `internalTransactions: true`. Log and internal-transaction requests accept `transaction: true`. Join the returned collections with `transactionIndex`.

## Value types

* Transaction amounts and resource fields such as `feeLimit`, `fee`, `energyUsageTotal`, and `netFee` are `bigint`. The wire values are signed decimal strings.
* Block and transaction timestamps are Unix milliseconds represented as `number`.
* `parameter`, `ret`, and `callValueInfo` are raw JSON. Their shapes depend on the transaction type.

See the [query builder reference](../../reference/basic-components/query-builder) for the complete field and filter list.


## Related topics

- [Tron query builder](/en/sdk/pipes-sdk/tron/reference/basic-components/query-builder.md)
- [Handling Bitcoin data](/en/sdk/pipes-sdk/bitcoin/guides/basic-development/handling-bitcoin-data.md)
- [Block data for Tron](/en/sdk/squid-sdk/tron/reference/tron-processor/context-interfaces.md)
- [Error handling](/en/portal/introduction/error-handling.md)
- [Fork handling](/en/sdk/pipes-sdk/evm/guides/architecture-deep-dives/fork-handling.md)


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