This guide covers configuring and building the subgraph, deploying a development version to Goldsky, and running the subgraph-client app against it.
Production releases follow the canonical Subgraph Release Process and are tracked per version with the release issue template. Release Please publishes versioned subgraphs; after they finish indexing and pass verification, the release owner moves the Goldsky prod tags to the new version.
- Node.js and npm: Node.js version 20.18.1 or higher. Download from nodejs.org.
- Goldsky account: Sign up at goldsky.com. Manual development deploys require a login.
- Goldsky CLI: Follow the Goldsky documentation to install it.
The Graph CLI (@graphprotocol/graph-cli) is a regular dependency of subgraph/package.json, so npm install is enough to get it. You don't need a separate global install unless you want to run graph commands directly outside the npm scripts below.
Network-specific values (contract addresses, start blocks, proving-period parameters) live in subgraph/config/network.json, not in source files:
{
"networks": {
"calibration": {
"name": "filecoin-testnet",
"PDPVerifier": { "address": "0x...", "startBlock": 3140755 },
"FWSS": { "maxProvingPeriod": "240", "challengeWindowSize": "20" }
},
"mainnet": {
"name": "filecoin",
"PDPVerifier": { "address": "0x...", "startBlock": 5441432 },
"FWSS": { "maxProvingPeriod": "2880", "challengeWindowSize": "60" }
}
}
}Building for a network runs mustache templates against this file to produce subgraph.yaml (from templates/subgraph.template.yaml) and src/generated/constants.ts (from templates/constants.template.ts) before invoking graph codegen and graph build. Change network.json, not the generated files, when a network value changes.
cd subgraph
npm install
# Build for calibration (generates constants + subgraph.yaml, then graph codegen && graph build)
npm run build:calibration
# Build for mainnet
npm run build:mainnetEvery PR touching subgraph/** runs this same sequence, plus npm test for the Matchstick unit tests, in .github/workflows/subgraph-ci.yml before it can merge.
For local iteration outside the release flow:
cd subgraph
goldsky login # paste your Goldsky API key when prompted
# Calibration dev deploy
NETWORK=calibration npm run build
NETWORK=calibration npm run deploy:dev
# Mainnet-config dev deploy
NETWORK=mainnet npm run build
NETWORK=mainnet npm run deploy:devdeploy:dev runs predeploy:dev, which regenerates config and constants for NETWORK before deploying to pdp-explorer/dev. It does not run graph build, so build the same network first.
The subgraph-client is a Vite app that queries the deployed subgraph directly from the browser.
-
Navigate to the client directory:
cd subgraph-client -
Copy
.env.exampleto.envand fill in the environment variables:VITE_SUBGRAPH_URL_MAINNET= # mainnet subgraph URL VITE_SUBGRAPH_URL_CALIBRATION= # calibration subgraph URL VITE_MAINNET_PDP_VERIFIER= # mainnet PDP verifier contract address (optional) VITE_MAINNET_PDP_SERVICE= # mainnet PDP simple service contract address (optional) VITE_CALIBRATION_PDP_VERIFIER= # calibration PDP verifier contract address (optional) VITE_CALIBRATION_PDP_SERVICE= # calibration PDP simple service contract address (optional)
-
Install dependencies and start the app:
npm install npm run dev
The app lets users switch between mainnet and calibration client-side (see src/contexts/NetworkContext.tsx). There is a single deployed app instance, not separate sites per network.
- Edit
schema.graphql(entities),subgraph/config/network.json(network parameters),templates/*.template.*(manifest/constants shape), orsrc/*.ts(event handlers) as needed. - From
subgraph/, runnpm testlocally andnpm run build:calibration && npm run build:mainnetto confirm both networks still build. - Open a PR with a Conventional Commits type (
fix:,feat:, etc.). CI runs the same tests and builds automatically. - Once merged to
main, Release Please opens or updates the rolling release PR. - Follow the Subgraph Release Process. Merging the release PR publishes a GitHub Release and versioned Goldsky deployments for both networks, then automatically opens a release issue to track indexing, verification, and
prodpromotion.
- AssemblyScript: Subgraph mappings are written in AssemblyScript, a subset of TypeScript that compiles to Wasm. See assemblyscript.org.
- The Graph Documentation: thegraph.com/docs.
- Goldsky Documentation: docs.goldsky.com.
For more information on queries used in the subgraph client, see subgraph-client/src/utility/queries.ts. For the GraphQL schema and example queries, see the GraphQL API Reference.