.setGateway(), .setArchive() or .setDataSource({archive})) to SQD Portal. It is mostly a configuration change: @subsquid/substrate-processor 9 replaces the gateway with .setPortal() and keeps the rest of the API, so your handlers, types and database stay as they are. One change in request matching can affect handlers; see Behaviour differences.
The chain RPC endpoint keeps its role. SubstrateBatchProcessor still needs it for runtime metadata, and it still serves the blocks above the Portal’s finalized head, so a real-time squid stays real-time.
Prerequisites
- A squid based on
@subsquid/substrate-processor8.x that calls.setGateway(),.setArchive()or.setDataSource() - Node.js 22+
- An archive RPC endpoint for your chain, as before
- The Portal dataset of your network:
https://portal.sqd.dev/datasets/<slug>. The slug is the network name of the old gateway URL; check that the network has a dataset on the Substrate networks page.
Migration steps
Jump to: Networks without a Portal dataset · Behaviour differences · Typegen metadata · Common errors1
Upgrade the processor
From your squid’s folder, install the 9.x release:Version 9 removes
.setGateway(), .setArchive(), .setDataSource() and the GatewaySettings/ArchiveSettings/DataSource types, 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:
A Portal that expects a key takes it as a header:
Using the deprecated .setDataSource()? Split it in two.
Using the deprecated .setDataSource()? Split it in two.
.setDataSource() is gone in version 9. Its chain setting becomes .setRpcEndpoint():Passing gateway settings (apiKey, requestTimeout)? Use PortalSettings.
Passing gateway settings (apiKey, requestTimeout)? Use PortalSettings.
.setPortal() accepts a URL or a PortalSettings object. PortalSettings has no apiKey setting, and the processor no longer reads SQD_API_KEY, so drop both: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.If your squid processes finalized blocks only (.setRpcDataIngestionSettings({disabled: true}) or .useArchiveOnly())
If your squid processes finalized blocks only (.setRpcDataIngestionSettings({disabled: true}) or .useArchiveOnly())
Nothing changes. With RPC ingestion disabled, the processor handles only the finalized blocks served by the Portal and keeps following the Portal’s finalized head. The RPC endpoint is still required for runtime metadata.
3
Build and smoke-test
Build the squid and run it locally: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.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, you can also deploy into a new slot first and switch the production tag once it’s ready; see the slots and tags guide.
Networks without a Portal dataset
If the Substrate networks page has no Portal dataset for your network, drop the gateway call and keep.setRpcEndpoint(). The processor then reads every block from the chain RPC:
.setRpcDataIngestionSettings({disabled: true}) or .useArchiveOnly(), remove that call too: with RPC ingestion disabled the processor requires a Portal and stops with Portal is required when RPC data ingestion is disabled.
A synced squid continues from where it stopped. Syncing a new squid this way takes much longer than from a Portal, since every historical block is fetched over RPC.
Behaviour differences
- Typed requests without filters. In version 9,
addEvmLog({}),addEthereumTransaction({})andaddContractsContractEmitted({})without filters select onlyEVM.Logevents,Ethereum.transactcalls andContracts.ContractEmittedevents respectively, from the Portal and from RPC alike. In version 8, RPC ingestion matched every event or call for them. If your handler relied on those extra items, request them explicitly withaddEvent()oraddCall(). - Gear
MessageQueuedrequests with program ids. ForaddGearMessageQueued({programId}), the processor requests allGear.MessageQueuedevents of the matching blocks from the Portal and filters them by program id itself. The result is the same as from RPC ingestion, but the squid downloads the messages of other programs too. - Field selection. The Portal returns only the selected fields. The processor always selects the fields it needs internally, so your field selection stays the same.
Typegen metadata
ThespecVersions setting of squid-substrate-typegen often points at a metadata service on the v2 gateway host (https://v2.archive.subsquid.io/metadata/<network>). To stop depending on it, generate the spec versions file from your chain RPC with the metadata explorer and point specVersions at the file. Typegen only runs at development time, so this doesn’t affect a running squid.
Common errors (Substrate)
Reference template (Substrate)
squid-substrate-template
Kusama transfers squid with a Portal data source and RPC, the setup this guide produces
Next steps (Substrate)
General settings
All
SubstrateBatchProcessor data source settingsUnfinalized blocks
How the processor follows the chain head through RPC