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

# Logs

> Subscribe to Tron event logs with addLog(): filter by contract address and topics.

<h4 id="add-log">
  `addLog(options)`
</h4>

Get event logs emitted by some *or all* contracts in the network. `options` has the following structure:

```typescript theme={"system"}
{
  where?: {
    address?: string[]
    topic0?: string[]
    topic1?: string[]
    topic2?: string[]
    topic3?: string[]
  }
  include?: {
    transaction?: boolean
  }
  range?: {
    from: number
    to?: number
  }
}
```

**Data requests** are located in the `where` field:

* `address`: the set of addresses of contracts emitting the logs. Omit to subscribe to events from all contracts in the network.
* `topicN`: the set of values of topicN.

Omit the `where` field to subscribe to all logs network-wide.

**Related data** can be requested via the `include` field:

* `transaction = true`: will retrieve the parent transaction for each selected log.

The data will be added to the `.transactions` iterable within [block data](./context-interfaces) and made available via the `.transaction` field of each log item.

Note that logs can also be requested by the other `TronBatchProcessor` methods as related data.

Selection of the exact fields to be retrieved for each log item and the optional parent transactions is done with the `setFields()` method documented on the [Field selection](./field-selection) page.

#### Example

Request all `Transfer(address,address,uint256)` event logs emitted by the USDT smart contract, include parent txs.

```ts theme={"system"}
const USDT_ADDRESS = 'a614f803b6fd780986a42c78ec9c7f77e6ded13c'
const TRANSFER_TOPIC = 'ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

processor.addLog({
  where: {
    address: [USDT_ADDRESS],
    topic0: [TRANSFER_TOPIC]
  },
  include: {
    transaction: true
  }
})
```


## Related topics

- [Event logs](/en/sdk/squid-sdk/evm/reference/evm-stream/logs.md)
- [View Logs](/en/cloud/reference/cli/logs.md)
- [Log messages](/en/sdk/squid-sdk/solana/reference/solana-stream/logs.md)
- [Inspect logs](/en/cloud/resources/logging.md)
- [Query Event Logs](/en/portal/evm/examples/query-logs.md)


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