Migrate to ArrowSquid (Substrate)
This is a Substrate guide. EVM guide is available here. ArrowSquid refers to@subsquid/substrate-processor versions 3.x and above. It is not compatible with the FireSquid archive endpoints. Instead, the new version uses SQD Network gateways. See the Supported networks page.
The main feature introduced by the ArrowSquid update is the new ability of the processor to ingest unfinalized blocks directly from a network node, instead of waiting for an archive to ingest and serve it first. The processor can now handle forks and rewrite the contents of its database if it happens to have indexed orphaned blocks. This allows SQD-based APIs to become near real-time and respond to the on-chain activity with subsecond latency.
Other new features include the new streamlined processor configuration interface and automatic retrieval of execution traces. On the implementation side, the way in which data is fetched has been made more efficient.
End-to-end Substrate ArrowSquid examples:
Here is a step-by-step guide for migrating a squid built with an older SDK version to the post-ArrowSquid tooling.
Step 1
Update all packages affected by the update:file-store, please update any related packages to the @latest version.
Step 2
Replace the oldsetDataSource() processor configuration call with a combination of setGateway() and setRpcEndpoint(). Use a public SQD Network gateway URL for your network. If your squid did not use an RPC endpoint before, find one for your network and set it with setRpcEndpoint(). For Aleph Zero your edit might look like this:
Step 3
Next, we have to account for the changes in signatures of the data requesting processor methodsaddEvent(),addCall(),addEvmLog(),addEthereumTransaction(),addContractsContractEmitted(),addGearMessageQueued(),addGearUserMessageSent(),
call flag for event-requesting methods). Field selection is now done by the new setFields() method on a per-item-type basis: once for all Calls, once for all Events etc. The setting is processor-wide: for example, all Calls returned by the processor will have the same set of available fields, regardless of whether they were requested directly or as related data.
Begin migrating to the new interface by finding all calls to these methods and combining all the field selectors into processor-wide event, call and extrinsic field selectors that request all fields previously requested by individual selectors. Note that call.args and event.args are now requested by default and can be omitted. When done, add a call to setFields() supplying it with the new field selectors.
The new field selector format is fully documented on the Field selection page.
Blanket field selections like
\{data: \{event: \{extrinsic: true\}\}\} are not supported in ArrowSquid. If you used one of these, please find out which exact fields you use in the batch handler and specifically request them.Step 4
Replace the old calls to the data requesting processor methods with calls using the new signatures. Old data request calls will be erased during the process. Make sure to request the appropriate related data with the boolean flags (call for event-requesting methods, events for call-requesting methods and extrinsic, stack for both).
Interfaces of data request methods are documented on the Data requests reference page:
addEvent(),addCall(),addEvmLog(),addEthereumTransaction(),addContractsContractEmitted(),addGearMessageQueued(),addGearUserMessageSent().
Step 5
Finally, update the batch handler to use the new batch context. The main change here is that nowblock.items is split into three separate iterables: block.calls, block.events and block.extrinsics. There are two ways to migrate:
-
If you’re in a hurry, use the
orderItems(block: Block)function from this snippet:src/main.ts - Alternatively, rewrite your batch handler using the new batch context interface.
Step 6
Rewrite yourtypegen.json in the new style. Here is an example:
- Archive URL as
"specVersions"is replaced with an URL of our new metadata service ("https://v2.archive.subsquid.io/metadata/kusama") - Requests for data wrappers are now made on a per-pallet basis.
typegen.json, regenerate the wrapper classes with
Step 7
Iteratively reconcile any type errors arising when building your squid (e.g. withnpm run build). If you need to specify the field selection generic type argument explicitly, get it as a typeof of the setFields argument value:

