Skip to main content

Migrate to the Cloud portal

For users on Solana

Portal is currently in beta. Please report any bugs or suggestions to the SQD Portal Beta chat or to Squid Devs.
The newest version of Portal serves real time data. It can replace both gateways of the open private version of SQD Network and RPC endpoints. Currently it only supports Solana (more on Solana indexing in SQD).
We’re currently experimenting with tightening the data request complexity limits. If you see an HTTP 400 error with a message like this:
Couldn't parse query: query contains X item requests, but only 50 is allowed
where X is some number above 50, or any other HTTP 400 response, please let us know.
Here are the steps to migrate:

Step 0: Procur a portal endpoint URL

You want
https://portal.sqd.dev/datasets/solana-beta
Dedicated Cloud Solana portal with real time support is TBA.

Step 1: Install @portal-api packages

A. Enter your squid’s folder. B. Remove both your lock file and the node_modules folder:
<Tabs queryString="package-manager">
<Tab value="npm" label="NPM">
rm -r node_modules package-lock.json
</Tab>
<Tab value="yarn" label="Yarn">
rm -r node_modules yarn.lock
</Tab>
<Tab value="pnpm" label="PNPM">
rm -r node_modules pnpm-lock.yaml
</Tab>
</Tabs>
C. Upgrade all SQD packages that have a @portal-api version to it:
npx --yes npm-check-updates --filter "@subsquid/*" --target "@portal-api" --upgrade
D. Freeze the versions of @portal-api packages by removing any version range specifiers (^, ~, <, >, >=, <=) preceding the package versions. Here’s a script:
sed -i -e 's/[\^~=<>]*\([0-9\.]*-portal-api\.[0-9a-f]\{6\}\)/\1/g' package.json
E. Install the dependencies:
<Tabs queryString="package-manager">
<Tab value="npm" label="NPM">
npm install
</Tab>
<Tab value="yarn" label="Yarn">
yarn install
</Tab>
<Tab value="pnpm" label="PNPM">
pnpm install
</Tab>
</Tabs>

Step 2: Update your code

A. Replace all exising data sources with the portal:
+  .setPortal('https://portal.tethys.sqd.dev/datasets/solana-beta')
-  .setGateway('https://v2.archive.subsquid.io/network/solana-mainnet')
-  .setRpc({
-    client: new SolanaRpcClient({
-      url: process.env.SOLANA_NODE
-    })
-  })
Also, please remove any mentions of SolanaRpcClient, for example:
-import \{DataSourceBuilder, SolanaRpcClient\} from '@subsquid/solana-stream'
+import \{DataSourceBuilder\} from '@subsquid/solana-stream'
B. Replace any block height literals with slot number literals.
+  .setBlockRange(\{from: 325000000\})
-  .setBlockRange(\{from: 303262650\})
TBA add a convenient converter C. If you used the slot field of block headers anywhere in your code, replace it with .number:
-  slot: block.header.slot,
+  slot: block.header.number,
D. If you need the block height (for example to stay compatible with your old code) request it in the .setFields call:
   .setFields({
     block: { // block header fields
       timestamp: true,
+      height: true
     },
Your squid is ready to use.

Step 3: testing

We highly recommend that all Portal Beta users test their migrated squids by re-syncing them. This will allow you to make sure that everything works as expected for the whole length of the chain and catch any bugs early. To resync your squid, follow the zero-downtime update procedure:
  1. Deploy your squid into a new slot.
  2. Wait for it to sync, observing the improved data fetching.
  3. Assign your production tag to the new deployment to redirect the GraphQL requests there.
See this section for details.

What’s next?

Take a look at the Soldexer project for a peek at the new client architecture and the most detailed and up-to-date documentation on the updated Portal API.