> ## 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 110+ 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.
> For Portal availability errors, stalled streams, or rate limiting, read https://status.sqd.dev/status.md. The status index at https://status.sqd.dev/llms.txt explains network and plan filters.
> Every page on this site is available as Markdown by appending .md to its URL.

# Migrate a squid to Portal

> Move a Tron squid from the v2 gateway to Portal with tron-processor 1.0.

This guide moves a Tron squid that reads historical data through the v2 gateway (`.setGateway()`) to SQD Portal. It is a configuration change: `@subsquid/tron-processor` 1.0 replaces the gateway with `.setPortal()` and keeps the rest of the API. Data requests, field selection, the data model and your handlers stay as they are.

The HTTP API endpoint keeps its role: it serves the blocks above the Portal's finalized head, so a real-time squid stays real-time.

## Prerequisites

* A squid based on `@subsquid/tron-processor` 0.x that calls `.setGateway()`
* Node.js 22+
* The Portal dataset: `https://portal.sqd.dev/datasets/tron-mainnet` (see the [Tron network page](https://docs.sqd.dev/en/data/tron/tron-mainnet.md))

## Migration steps

**Jump to:** [Choosing an HTTP API endpoint](#choosing-an-http-api-endpoint) · [Common errors](#common-errors-tron)

**1. Upgrade the processor**

From your squid's folder, install the 1.x release:

```bash theme={"system"}
npm install @subsquid/tron-processor@^1
```

Version 1 removes `.setGateway()` and the `GatewaySettings` type, so the project won't compile until the next step is done.

**2. Replace the gateway with Portal**

Point the processor at the Portal dataset instead of the gateway:

```diff theme={"system"}
 const processor = new TronBatchProcessor()
-  .setGateway('https://v2.archive.subsquid.io/network/tron-mainnet')
+  .setPortal('https://portal.sqd.dev/datasets/tron-mainnet')
   .setHttpApi({
     url: 'https://tron-rpc.publicnode.com',
     strideConcurrency: 1,
     strideSize: 1,
   })
```

> [accordion] Passing gateway settings (apiKey, requestTimeout)? Use PortalSettings.
>
> `.setPortal()` accepts a URL or a [`PortalSettings`](../../reference/tron-processor/general#set-portal) object. `PortalSettings` has no `apiKey` setting, and the processor no longer reads `SQD_API_KEY`, so drop both:
>
> ```diff theme={"system"}
> -  .setGateway({
> -    url: 'https://v2.archive.subsquid.io/network/tron-mainnet',
> -    apiKey: process.env.SQD_API_KEY,
> -  })
> +  .setPortal('https://portal.sqd.dev/datasets/tron-mainnet')
> ```
>
> A Portal that expects a key takes it as a header: `headers: {'x-api-key': process.env.PORTAL_API_KEY}`. The public Portal is shared capacity. If you need guaranteed capacity, ask in the [SquidDevs Telegram chat](https://t.me/HydraDevs).

> [accordion] If your squid has no .setHttpApi() (finalized blocks only)
>
> Nothing changes: without an HTTP API endpoint the processor handles only the finalized blocks served by the Portal and keeps following the Portal's finalized head.

**3. Build and smoke-test**

Build the squid and run it locally:

```bash theme={"system"}
npm run build
node -r dotenv/config lib/main.js
```

The processor logs `using archive data source` while it reads from the Portal, then `using chain RPC data source` once it reaches the Portal's head and switches to the HTTP API.

**4. Deploy**

A squid that already synced from the gateway does **not** need a re-sync: the processor state in the database doesn't depend on the data source, and the Portal serves the same blocks and items. Deploy the new version over the old one.

If your squid is deployed to the [Cloud](https://docs.sqd.dev/en/cloud), you can also deploy into a new slot first and switch the production tag once it's ready; see [the slots and tags guide](https://docs.sqd.dev/en/cloud/resources/slots-and-tags.md#zero-downtime-updates).

## Choosing an HTTP API endpoint

The HTTP API endpoint now serves only the last blocks above the Portal's head, so the request load on it drops sharply. Two things still matter when choosing one:

* Keyless public endpoints are heavily rate-limited, and some refuse keyless requests altogether. Use a private endpoint in production.
* [Internal transactions](https://docs.sqd.dev/en/sdk/squid-sdk/tron/reference/tron-processor/internal-transactions.md) come from the HTTP API above the Portal's head. Many public nodes are not configured to record them and return none, so a squid that relies on internal transactions needs a node that records them.

## Common errors (Tron)

| Symptom | Root cause | Fix |
| - | - | - |
| `Property 'setGateway' does not exist on type 'TronBatchProcessor'` | Version 1 replaced the gateway with Portal | Use `.setPortal()` (see *Replace the gateway with Portal*) |
| `Module '"@subsquid/tron-processor"' has no exported member 'GatewaySettings'` | Same | Use `PortalSettings` |
| `Object literal may only specify known properties, and 'apiKey' does not exist in type 'PortalSettings'` | `PortalSettings` has no `apiKey` setting | Drop `apiKey`; a Portal that expects a key takes `headers: {'x-api-key': ...}` |
| `No data source was specified` | Neither a Portal nor an HTTP API endpoint is set | Add `.setPortal()` and/or `.setHttpApi()` |
| HTTP 403 or 429 from the HTTP API endpoint | The public endpoint refuses or rate-limits keyless requests | Use another endpoint, ideally a private one |

## Reference template (Tron)

> [card] [tron-example](https://github.com/subsquid-labs/tron-example)
>
> USDT transfers squid with a Portal data source and an HTTP API endpoint, the setup this guide produces

## Next steps (Tron)

> [card] [General settings](https://docs.sqd.dev/en/sdk/squid-sdk/tron/reference/tron-processor/general.md)
>
> All `TronBatchProcessor` data source settings

> [card] [Logs](https://docs.sqd.dev/en/sdk/squid-sdk/tron/reference/tron-processor/logs.md)
>
> Log requests and the address formats they use


## Related topics

- [Migrate a squid to Portal](https://docs.sqd.dev/en/sdk/squid-sdk/evm/guides/migration/gateway-to-portal.md)
- [How to use your dedicated Portal with a key](https://docs.sqd.dev/en/sdk/squid-sdk/evm/guides/migration/portal-api-key.md)
- [EVM Portal stream](https://docs.sqd.dev/en/sdk/squid-sdk/evm/reference/evm-stream.md)
- [Quickstart](https://docs.sqd.dev/en/sdk/squid-sdk/solana/quickstart.md)
- [Changelog](https://docs.sqd.dev/changelog.md)


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