Skip to main content

Documentation Index

Fetch the complete documentation index at: https://beta.docs.sqd.dev/llms.txt

Use this file to discover all available pages before exploring further.

← Back to Portal Setup

Return to the Portal setup overview to explore other deployment options.
The newest version of the SQD Network portal serves real-time data. It can replace both gateways of the open private version of SQD Network and RPC endpoints.

Prerequisites

  • An existing Squid SDK-based Solana squid using @subsquid/solana-stream with .setGateway() and/or .setRpc()

Migration steps

1

Install @portal-api packages

A. Enter your squid’s folder.B. Remove both your lock file and the node_modules folder:
rm -r node_modules package-lock.json
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
Here’s an example edit:
   "dependencies": {
-    "@subsquid/batch-processor": "^1.0.0-portal-api.18ef40",
+    "@subsquid/batch-processor": "1.0.0-portal-api.18ef40",
     "@subsquid/borsh": "^0.2.0",
-    "@subsquid/solana-objects": ">=0.0.3-portal-api.18ef40",
-    "@subsquid/solana-stream": "<1.0.0-portal-api.18ef40",
+    "@subsquid/solana-objects": "0.0.3-portal-api.18ef40",
+    "@subsquid/solana-stream": "1.0.0-portal-api.18ef40",
     "@subsquid/typeorm-migration": "^1.3.0",
-    "@subsquid/typeorm-store": "~1.6.0-portal-api.18ef40",
+    "@subsquid/typeorm-store": "1.6.0-portal-api.18ef40",
     "dotenv": "^16.4.7",
     "pg": "^8.13.1",
     "typeorm": "^0.3.20"
   },
   "devDependencies": {
-    "@subsquid/solana-typegen": "^0.4.1-portal-api.18ef40",
+    "@subsquid/solana-typegen": "0.4.1-portal-api.18ef40",
     "@types/node": "^22.13.1",
     "typescript": "~5.7.3"
   }
E. Install the dependencies:
npm install
2

Update your code

A. Replace all existing data sources with the portal:
+  .setPortal({
+    url: 'https://portal.sqd.dev/datasets/solana-mainnet',
+      http: {
+        retryAttempts: Infinity
+      }
+   })
-  .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})
Use this converter to translate block heights into slot numbers. It bisects the chain through the public Portal: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
     },
3

Test by re-syncing

We highly recommend that all squids migrated to Portal are tested 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 the slots and tags guide for details.
Your squid is now configured to source data from Portal.

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.